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
XBOXRECV Class Reference

#include <XBOXRECV.h>

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

Public Member Functions

 XBOXRECV (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 (uint8_t controller, Button b)
 
bool getButtonClick (uint8_t controller, Button b)
 
int16_t getAnalogHat (uint8_t controller, AnalogHat a)
 
void setAllOff (uint8_t controller)
 
void setRumbleOff (uint8_t controller)
 
void setRumbleOn (uint8_t controller, uint8_t lValue, uint8_t rValue)
 
void setLedRaw (uint8_t controller, uint8_t value)
 
void setLedOff (uint8_t controller)
 
void setLedOn (uint8_t controller, LED l)
 
void setLedBlink (uint8_t controller, LED l)
 
void setLedMode (uint8_t controller, LEDMode lm)
 
uint8_t getBatteryLevel (uint8_t controller)
 
bool buttonChanged (uint8_t controller)
 

Public Attributes

bool XboxReceiverConnected
 
uint8_t Xbox360Connected [4]
 

Protected Attributes

USBpUsb
 
uint8_t bAddress
 
EpInfo epInfo [XBOX_MAX_ENDPOINTS]
 

Detailed Description

This class implements support for a Xbox Wirless receiver.

Up to four controllers can connect to one receiver, if more is needed one can use a second receiver via the USBHub class.

Definition at line 71 of file XBOXRECV.h.

Constructor & Destructor Documentation

XBOXRECV::XBOXRECV ( USB pUsb)

Constructor for the XBOXRECV class.

Parameters
pUsbPointer to USB class instance.

Definition at line 56 of file XBOXRECV.cpp.

Member Function Documentation

bool XBOXRECV::buttonChanged ( uint8_t  controller)

Used to check if a button has changed.

Parameters
controllerThe controller to read from.
Returns
True if a button has changed.

Definition at line 440 of file XBOXRECV.cpp.

virtual uint8_t XBOXRECV::GetAddress ( )
inlinevirtual

Get the device address.

Returns
The device address.

Implements USBDeviceConfig.

Definition at line 102 of file XBOXRECV.h.

int16_t XBOXRECV::getAnalogHat ( uint8_t  controller,
AnalogHat  a 
)

Return the analog value from the joysticks on the controller.

Parameters
controllerThe controller to read from.
aEither LeftHatX, LeftHatY, RightHatX or RightHatY.
Returns
Returns a signed 16-bit integer.

Definition at line 437 of file XBOXRECV.cpp.

uint8_t XBOXRECV::getBatteryLevel ( uint8_t  controller)

Used to get the battery level from the controller.

Parameters
controllerThe controller to read from.
Returns
Returns the battery level in percentage in 33% steps.

Definition at line 464 of file XBOXRECV.cpp.

bool XBOXRECV::getButtonClick ( uint8_t  controller,
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
controllerThe controller to read from.
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 417 of file XBOXRECV.cpp.

uint8_t XBOXRECV::getButtonPress ( uint8_t  controller,
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
controllerThe controller to read from.
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 410 of file XBOXRECV.cpp.

uint8_t XBOXRECV::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 71 of file XBOXRECV.cpp.

virtual bool XBOXRECV::isReady ( )
inlinevirtual

Used to check if the controller has been initialized.

Returns
True if it's ready.

Definition at line 107 of file XBOXRECV.h.

uint8_t XBOXRECV::Poll ( )
virtual

Poll the USB Input endpoins and run the state machines.

Returns
0 on success.

Implements USBDeviceConfig.

Definition at line 294 of file XBOXRECV.cpp.

uint8_t XBOXRECV::Release ( )
virtual

Release the USB device.

Returns
0 on success.

Implements USBDeviceConfig.

Definition at line 285 of file XBOXRECV.cpp.

void XBOXRECV::setAllOff ( uint8_t  controller)
inline

Turn rumble off and all the LEDs on the specific controller.

Parameters
controllerThe controller to write to.

Definition at line 137 of file XBOXRECV.h.

void XBOXRECV::setLedBlink ( uint8_t  controller,
LED  l 
)

Turn on a LED by using the LED enum.

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

Definition at line 498 of file XBOXRECV.cpp.

void XBOXRECV::setLedMode ( uint8_t  controller,
LEDMode  lm 
)

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

Parameters
controllerThe controller to write to.
lmSee LEDMode.

Definition at line 501 of file XBOXRECV.cpp.

void XBOXRECV::setLedOff ( uint8_t  controller)
inline

Turn all LEDs off the specific controller.

Parameters
controllerThe controller to write to.

Definition at line 162 of file XBOXRECV.h.

void XBOXRECV::setLedOn ( uint8_t  controller,
LED  l 
)

Turn on a LED by using the LED enum.

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

Definition at line 494 of file XBOXRECV.cpp.

void XBOXRECV::setLedRaw ( uint8_t  controller,
uint8_t  value 
)

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

Parameters
controllerThe controller to write to.
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 486 of file XBOXRECV.cpp.

void XBOXRECV::setRumbleOff ( uint8_t  controller)
inline

Turn rumble off the specific controller.

Parameters
controllerThe controller to write to.

Definition at line 142 of file XBOXRECV.h.

void XBOXRECV::setRumbleOn ( uint8_t  controller,
uint8_t  lValue,
uint8_t  rValue 
)

Turn rumble on.

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

Definition at line 530 of file XBOXRECV.cpp.

Member Data Documentation

uint8_t XBOXRECV::bAddress
protected

Device address.

Definition at line 204 of file XBOXRECV.h.

EpInfo XBOXRECV::epInfo[XBOX_MAX_ENDPOINTS]
protected

Endpoint info structure.

Definition at line 206 of file XBOXRECV.h.

USB* XBOXRECV::pUsb
protected

Pointer to USB class instance.

Definition at line 202 of file XBOXRECV.h.

uint8_t XBOXRECV::Xbox360Connected[4]

Variable used to indicate if the XBOX 360 controller is successfully connected.

Definition at line 198 of file XBOXRECV.h.

bool XBOXRECV::XboxReceiverConnected

True if a wireless receiver is connected.

Definition at line 196 of file XBOXRECV.h.


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