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 210 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 218 of file XBOXUSB.cpp.

virtual uint8_t XBOXUSB::GetAddress ( )
inlinevirtual

Get the device address.

Returns
The device address.

Implements USBDeviceConfig.

Definition at line 91 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 99 of file XBOXUSB.h.

uint8_t XBOXUSB::getButtonPress ( Button  b)

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

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

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

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

Definition at line 269 of file XBOXUSB.cpp.

bool XBOXUSB::getButtonClick ( Button  b)

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

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

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

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

Definition at line 277 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 297 of file XBOXUSB.cpp.

void XBOXUSB::setAllOff ( )
inline

Turn rumble off and all the LEDs on the controller.

Definition at line 129 of file XBOXUSB.h.

void XBOXUSB::setRumbleOff ( )
inline

Turn rumble off the controller.

Definition at line 135 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 328 of file XBOXUSB.cpp.

void XBOXUSB::setLedRaw ( uint8_t  value)

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

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

Definition at line 307 of file XBOXUSB.cpp.

void XBOXUSB::setLedOff ( )
inline

Turn all LEDs off the controller.

Definition at line 153 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 315 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 320 of file XBOXUSB.cpp.

void XBOXUSB::setLedMode ( LEDMode  lm)

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

Parameters
lmSee LEDMode.

Definition at line 324 of file XBOXUSB.cpp.

Member Data Documentation

bool XBOXUSB::Xbox360Connected

True if a Xbox 360 controller is connected.

Definition at line 174 of file XBOXUSB.h.

USB* XBOXUSB::pUsb
protected

Pointer to USB class instance.

Definition at line 178 of file XBOXUSB.h.

uint8_t XBOXUSB::bAddress
protected

Device address.

Definition at line 180 of file XBOXUSB.h.

EpInfo XBOXUSB::epInfo[XBOX_MAX_ENDPOINTS]
protected

Endpoint info structure.

Definition at line 182 of file XBOXUSB.h.


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