USB Host Shield 2.0
Public Member Functions | Public Attributes | Protected Attributes | List of all members
XBOXOLD Class Reference

#include <XBOXOLD.h>

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

Public Member Functions

 XBOXOLD (USB *pUsb)
 
USBDeviceConfig implementation
uint8_t Init (uint8_t parent, uint8_t port, bool lowspeed)
 
uint8_t Release ()
 
uint8_t Poll ()
 
virtual uint8_t GetAddress ()
 
virtual bool isReady ()
 
virtual bool VIDPIDOK (uint16_t vid, uint16_t pid)
 
Xbox Controller functions
uint8_t getButtonPress (ButtonEnum b)
 
bool getButtonClick (ButtonEnum b)
 
int16_t getAnalogHat (AnalogHatEnum a)
 
void setRumbleOff ()
 
void setRumbleOn (uint8_t lValue, uint8_t rValue)
 
void attachOnInit (void(*funcOnInit)(void))
 
- Public Member Functions inherited from USBDeviceConfig
virtual uint8_t ConfigureDevice (uint8_t parent, uint8_t port, bool lowspeed)
 
virtual void ResetHubPort (uint8_t port)
 
virtual bool DEVCLASSOK (uint8_t klass)
 
virtual bool DEVSUBCLASSOK (uint8_t subklass)
 

Public Attributes

bool XboxConnected
 

Protected Attributes

USBpUsb
 
uint8_t bAddress
 
EpInfo epInfo [XBOX_MAX_ENDPOINTS]
 

Detailed Description

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

Definition at line 48 of file XBOXOLD.h.

Constructor & Destructor Documentation

◆ XBOXOLD()

XBOXOLD::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

◆ Init()

uint8_t XBOXOLD::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.

Reimplemented from USBDeviceConfig.

Definition at line 63 of file XBOXOLD.cpp.

◆ Release()

uint8_t XBOXOLD::Release ( )
virtual

Release the USB device.

Returns
0 on success.

Reimplemented from USBDeviceConfig.

Definition at line 237 of file XBOXOLD.cpp.

◆ Poll()

uint8_t XBOXOLD::Poll ( )
virtual

Poll the USB Input endpoins and run the state machines.

Returns
0 on success.

Reimplemented from USBDeviceConfig.

Definition at line 245 of file XBOXOLD.cpp.

◆ GetAddress()

virtual uint8_t XBOXOLD::GetAddress ( )
inlinevirtual

Get the device address.

Returns
The device address.

Reimplemented from USBDeviceConfig.

Definition at line 80 of file XBOXOLD.h.

◆ isReady()

virtual bool XBOXOLD::isReady ( )
inlinevirtual

Used to check if the controller has been initialized.

Returns
True if it's ready.

Definition at line 88 of file XBOXOLD.h.

◆ VIDPIDOK()

virtual bool XBOXOLD::VIDPIDOK ( uint16_t  vid,
uint16_t  pid 
)
inlinevirtual

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.

Reimplemented from USBDeviceConfig.

Definition at line 98 of file XBOXOLD.h.

◆ getButtonPress()

uint8_t XBOXOLD::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 348 of file XBOXOLD.cpp.

◆ getButtonClick()

bool XBOXOLD::getButtonClick ( 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 362 of file XBOXOLD.cpp.

◆ getAnalogHat()

int16_t XBOXOLD::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 382 of file XBOXOLD.cpp.

◆ setRumbleOff()

void XBOXOLD::setRumbleOff ( )
inline

Turn rumble off the controller.

Definition at line 127 of file XBOXOLD.h.

◆ setRumbleOn()

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

◆ attachOnInit()

void XBOXOLD::attachOnInit ( void(*)(void)  funcOnInit)
inline

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

Parameters
funcOnInitFunction to call.

Definition at line 141 of file XBOXOLD.h.

Member Data Documentation

◆ XboxConnected

bool XBOXOLD::XboxConnected

True if a Xbox controller is connected.

Definition at line 147 of file XBOXOLD.h.

◆ pUsb

USB* XBOXOLD::pUsb
protected

Pointer to USB class instance.

Definition at line 151 of file XBOXOLD.h.

◆ bAddress

uint8_t XBOXOLD::bAddress
protected

Device address.

Definition at line 153 of file XBOXOLD.h.

◆ epInfo

EpInfo XBOXOLD::epInfo[XBOX_MAX_ENDPOINTS]
protected

Endpoint info structure.

Definition at line 155 of file XBOXOLD.h.


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