Zoltan Hudak / UsbHostMAX3421E

Dependents:   UsbHostMAX3421E_Hello

Embed: (wiki syntax)

« Back to documentation index

XBOXOLD Class Reference

This class implements support for a the original Xbox controller via USB. More...

#include <XBOXOLD.h>

Inherits USBDeviceConfig.

Public Member Functions

 XBOXOLD (Usb *pUsb)
 Constructor for the XBOXOLD class.
USBDeviceConfig implementation
uint8_t Init (uint8_t parent, uint8_t port, bool lowspeed)
 Initialize the Xbox Controller.
uint8_t Release ()
 Release the USB device.
uint8_t Poll ()
 Poll the USB Input endpoins and run the state machines.
virtual uint8_t GetAddress ()
 Get the device address.
virtual bool isReady ()
 Used to check if the controller has been initialized.
virtual bool VIDPIDOK (uint16_t vid, uint16_t pid)
 Used by the USB core to check what this driver support.
Xbox Controller functions
uint8_t getButtonPress (ButtonEnum b)
 getButtonPress(ButtonEnum b) will return true as long as the button is held down.
bool getButtonClick (ButtonEnum b)
int16_t getAnalogHat (AnalogHatEnum a)
 Return the analog value from the joysticks on the controller.
void setRumbleOff ()
 Turn rumble off the controller.
void setRumbleOn (uint8_t lValue, uint8_t rValue)
 Turn rumble on.
void attachOnInit (void(*funcOnInit)(void))
 Used to call your own function when the controller is successfully initialized.

Data Fields

bool XboxConnected
 True if a Xbox controller is connected.

Protected Attributes

Usb * pUsb
 Pointer to USB class instance.
uint8_t bAddress
 Device address.
EpInfo epInfo [XBOX_MAX_ENDPOINTS]
 Endpoint info structure.

Detailed Description

This class implements support for a the original Xbox controller via USB.

Definition at line 46 of file XBOXOLD.h.


Constructor & Destructor Documentation

XBOXOLD ( Usb *  pUsb )

Constructor for the XBOXOLD class.

Parameters:
pUsbPointer to USB class instance.

Definition at line 47 of file XBOXOLD.cpp.


Member Function Documentation

void attachOnInit ( void(*)(void)  funcOnInit )

Used to call your own function when the controller is successfully initialized.

Parameters:
funcOnInitFunction to call.

Definition at line 139 of file XBOXOLD.h.

virtual uint8_t GetAddress (  ) [virtual]

Get the device address.

Returns:
The device address.

Definition at line 78 of file XBOXOLD.h.

int16_t getAnalogHat ( AnalogHatEnum  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 317 of file XBOXOLD.cpp.

uint8_t getButtonPress ( ButtonEnum  b )

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

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

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

Parameters:
bButtonEnum to read.
Returns:
getButtonClick(ButtonEnum b) will return a bool, while getButtonPress(ButtonEnum b) will return a byte if reading L2 or R2.

Definition at line 295 of file XBOXOLD.cpp.

uint8_t Init ( uint8_t  parent,
uint8_t  port,
bool  lowspeed 
)

Initialize the Xbox Controller.

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

Definition at line 63 of file XBOXOLD.cpp.

virtual bool isReady (  ) [virtual]

Used to check if the controller has been initialized.

Returns:
True if it's ready.

Definition at line 86 of file XBOXOLD.h.

uint8_t Poll (  )

Poll the USB Input endpoins and run the state machines.

Returns:
0 on success.

Definition at line 245 of file XBOXOLD.cpp.

uint8_t Release (  )

Release the USB device.

Returns:
0 on success.

Definition at line 237 of file XBOXOLD.cpp.

void setRumbleOff (  )

Turn rumble off the controller.

Definition at line 125 of file XBOXOLD.h.

void 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 327 of file XBOXOLD.cpp.

virtual bool VIDPIDOK ( uint16_t  vid,
uint16_t  pid 
) [virtual]

Used by the USB core to check what this driver support.

Parameters:
vidThe device's VID.
pidThe device's PID.
Returns:
Returns true if the device's VID and PID matches this driver.

Definition at line 96 of file XBOXOLD.h.


Field Documentation

uint8_t bAddress [protected]

Device address.

Definition at line 151 of file XBOXOLD.h.

EpInfo epInfo[XBOX_MAX_ENDPOINTS] [protected]

Endpoint info structure.

Definition at line 153 of file XBOXOLD.h.

Usb* pUsb [protected]

Pointer to USB class instance.

Definition at line 149 of file XBOXOLD.h.

True if a Xbox controller is connected.

Definition at line 141 of file XBOXOLD.h.