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

#include <XBOXONE.h>

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

Public Member Functions

 XBOXONE (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 ()
 
virtual bool VIDPIDOK (uint16_t vid, uint16_t pid)
 
Xbox Controller functions
uint16_t getButtonPress (ButtonEnum b)
 
bool getButtonClick (ButtonEnum b)
 
int16_t getAnalogHat (AnalogHatEnum a)
 
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 XboxOneConnected
 

Protected Attributes

USBpUsb
 
uint8_t bAddress
 
EpInfo epInfo [XBOX_MAX_ENDPOINTS]
 

Detailed Description

This class implements support for a Xbox ONE controller connected via USB.

Definition at line 46 of file XBOXONE.h.

Constructor & Destructor Documentation

XBOXONE::XBOXONE ( USB pUsb)

Constructor for the XBOXONE class.

Parameters
pUsbPointer to USB class instance.

Definition at line 27 of file XBOXONE.cpp.

Member Function Documentation

uint8_t XBOXONE::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 43 of file XBOXONE.cpp.

uint8_t XBOXONE::Release ( )
virtual

Release the USB device.

Returns
0 on success.

Reimplemented from USBDeviceConfig.

Definition at line 226 of file XBOXONE.cpp.

uint8_t XBOXONE::Poll ( )
virtual

Poll the USB Input endpoins and run the state machines.

Returns
0 on success.

Reimplemented from USBDeviceConfig.

Definition at line 237 of file XBOXONE.cpp.

virtual uint8_t XBOXONE::GetAddress ( )
inlinevirtual

Get the device address.

Returns
The device address.

Reimplemented from USBDeviceConfig.

Definition at line 78 of file XBOXONE.h.

virtual bool XBOXONE::isReady ( )
inlinevirtual

Used to check if the controller has been initialized.

Returns
True if it's ready.

Definition at line 86 of file XBOXONE.h.

virtual bool XBOXONE::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 96 of file XBOXONE.h.

uint16_t XBOXONE::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 word if reading L2 or R2.

Definition at line 316 of file XBOXONE.cpp.

bool XBOXONE::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 word if reading L2 or R2.

Definition at line 324 of file XBOXONE.cpp.

int16_t XBOXONE::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 344 of file XBOXONE.cpp.

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

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

Parameters
funcOnInitFunction to call.

Definition at line 126 of file XBOXONE.h.

Member Data Documentation

bool XBOXONE::XboxOneConnected

True if a Xbox ONE controller is connected.

Definition at line 128 of file XBOXONE.h.

USB* XBOXONE::pUsb
protected

Pointer to USB class instance.

Definition at line 136 of file XBOXONE.h.

uint8_t XBOXONE::bAddress
protected

Device address.

Definition at line 138 of file XBOXONE.h.

EpInfo XBOXONE::epInfo[XBOX_MAX_ENDPOINTS]
protected

Endpoint info structure.

Definition at line 140 of file XBOXONE.h.


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