USB Host Shield 2.0
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Public Member Functions | Public Attributes | Protected Attributes | List of all members
XBOXUSB Class Reference

#include <XBOXUSB.h>

Inheritance diagram for XBOXUSB:
Inheritance graph
[legend]
Collaboration diagram for XBOXUSB:
Collaboration graph
[legend]

Public Member Functions

 XBOXUSB (USB *pUsb)
 
USBDeviceConfig implementation
virtual uint8_t Init (uint8_t parent, uint8_t port, bool lowspeed)
 
virtual uint8_t Release ()
 
virtual uint8_t Poll ()
 
virtual uint8_t GetAddress ()
 
virtual bool isReady ()
 
Xbox Controller functions
uint8_t getButtonPress (Button b)
 
bool getButtonClick (Button b)
 
int16_t getAnalogHat (AnalogHat a)
 
void setAllOff ()
 
void setRumbleOff ()
 
void setRumbleOn (uint8_t lValue, uint8_t rValue)
 
void setLedRaw (uint8_t value)
 
void setLedOff ()
 
void setLedOn (LED l)
 
void setLedBlink (LED l)
 
void setLedMode (LEDMode lm)
 

Public Attributes

bool Xbox360Connected
 

Protected Attributes

USBpUsb
 
uint8_t bAddress
 
EpInfo epInfo [XBOX_MAX_ENDPOINTS]
 

Detailed Description

This class implements support for a Xbox wired controller via USB.

Definition at line 59 of file XBOXUSB.h.

Constructor & Destructor Documentation

XBOXUSB::XBOXUSB ( USB pUsb)

Constructor for the XBOXUSB class.

Parameters
pUsbPointer to USB class instance.

Definition at line 23 of file XBOXUSB.cpp.

Member Function Documentation

uint8_t XBOXUSB::Init ( uint8_t  parent,
uint8_t  port,
bool  lowspeed 
)
virtual

Initialize the Xbox Controller.

Parameters
parentHub number.
portPort number on the hub.
lowspeedSpeed of the device.
Returns
0 on success.

Implements USBDeviceConfig.

Definition at line 38 of file XBOXUSB.cpp.

uint8_t XBOXUSB::Release ( )
virtual

Release the USB device.

Returns
0 on success.

Implements USBDeviceConfig.

Definition at line 220 of file XBOXUSB.cpp.

uint8_t XBOXUSB::Poll ( )
virtual

Poll the USB Input endpoins and run the state machines.

Returns
0 on success.

Implements USBDeviceConfig.

Definition at line 227 of file XBOXUSB.cpp.

virtual uint8_t XBOXUSB::GetAddress ( )
inlinevirtual

Get the device address.

Returns
The device address.

Implements USBDeviceConfig.

Definition at line 90 of file XBOXUSB.h.

virtual bool XBOXUSB::isReady ( )
inlinevirtual

Used to check if the controller has been initialized.

Returns
True if it's ready.

Definition at line 95 of file XBOXUSB.h.

uint8_t XBOXUSB::getButtonPress ( Button  b)

getButtonPress(uint8_t controller, Button b) will return true as long as the button is held down.

While getButtonClick(uint8_t controller, Button b) will only return it once.

So you instance if you need to increase a variable once you would use getButtonClick(uint8_t controller, Button b), but if you need to drive a robot forward you would use getButtonPress(uint8_t controller, Button b).

Parameters
bButton to read.
Returns
getButtonClick(uint8_t controller, Button b) will return a bool, but getButtonPress(uint8_t controller, Button b) will return a byte if reading L2 or R2.

Definition at line 278 of file XBOXUSB.cpp.

bool XBOXUSB::getButtonClick ( Button  b)

getButtonPress(uint8_t controller, Button b) will return true as long as the button is held down.

While getButtonClick(uint8_t controller, Button b) will only return it once.

So you instance if you need to increase a variable once you would use getButtonClick(uint8_t controller, Button b), but if you need to drive a robot forward you would use getButtonPress(uint8_t controller, Button b).

Parameters
bButton to read.
Returns
getButtonClick(uint8_t controller, Button b) will return a bool, but getButtonPress(uint8_t controller, Button b) will return a byte if reading L2 or R2.

Definition at line 285 of file XBOXUSB.cpp.

int16_t XBOXUSB::getAnalogHat ( AnalogHat  a)

Return the analog value from the joysticks on the controller.

Parameters
aEither LeftHatX, LeftHatY, RightHatX or RightHatY.
Returns
Returns a signed 16-bit integer.

Definition at line 305 of file XBOXUSB.cpp.

void XBOXUSB::setAllOff ( )
inline

Turn rumble off and all the LEDs on the controller.

Definition at line 123 of file XBOXUSB.h.

void XBOXUSB::setRumbleOff ( )
inline

Turn rumble off the controller.

Definition at line 125 of file XBOXUSB.h.

void XBOXUSB::setRumbleOn ( uint8_t  lValue,
uint8_t  rValue 
)

Turn rumble on.

Parameters
lValueLeft motor (big weight) inside the controller.
rValueRight motor (small weight) inside the controller.

Definition at line 331 of file XBOXUSB.cpp.

void XBOXUSB::setLedRaw ( uint8_t  value)

Set LED value. Without using the LED or LEDMode enum.

Parameters
valueSee: setLedOff(uint8_t controller), setLedOn(uint8_t controller, LED l), setLedBlink(uint8_t controller, LED l), and setLedMode(uint8_t controller, LEDMode lm).

Definition at line 314 of file XBOXUSB.cpp.

void XBOXUSB::setLedOff ( )
inline

Turn all LEDs off the controller.

Definition at line 140 of file XBOXUSB.h.

void XBOXUSB::setLedOn ( LED  l)

Turn on a LED by using the LED enum.

Parameters
lLED1, LED2, LED3 and LED4 is supported by the Xbox controller.

Definition at line 321 of file XBOXUSB.cpp.

void XBOXUSB::setLedBlink ( LED  l)

Turn on a LED by using the LED enum.

Parameters
lALL, LED1, LED2, LED3 and LED4 is supported by the Xbox controller.

Definition at line 325 of file XBOXUSB.cpp.

void XBOXUSB::setLedMode ( LEDMode  lm)

Used to set special LED modes supported by the Xbox controller.

Parameters
controllerThe controller to write to.
lmSee LEDMode.

Definition at line 328 of file XBOXUSB.cpp.

Member Data Documentation

bool XBOXUSB::Xbox360Connected

True if a Xbox 360 controller is connected.

Definition at line 160 of file XBOXUSB.h.

USB* XBOXUSB::pUsb
protected

Pointer to USB class instance.

Definition at line 164 of file XBOXUSB.h.

uint8_t XBOXUSB::bAddress
protected

Device address.

Definition at line 166 of file XBOXUSB.h.

EpInfo XBOXUSB::epInfo[XBOX_MAX_ENDPOINTS]
protected

Endpoint info structure.

Definition at line 168 of file XBOXUSB.h.


The documentation for this class was generated from the following files: