Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: UsbHostMAX3421E_Hello
XBOXONE Class Reference
This class implements support for a Xbox ONE controller connected via USB. More...
#include <XBOXONE.h>
Inherits USBDeviceConfig, and UsbConfigXtracter.
Public Member Functions | |
XBOXONE (Usb *pUsb) | |
Constructor for the XBOXONE class. | |
USBDeviceConfig implementation | |
virtual uint8_t | Init (uint8_t parent, uint8_t port, bool lowspeed) |
Initialize the Xbox Controller. | |
virtual uint8_t | Release () |
Release the USB device. | |
virtual 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. | |
uint8_t | readPollInterval () |
Read the poll interval taken from the endpoint descriptors. | |
virtual bool | VIDPIDOK (uint16_t vid, uint16_t pid) |
Used by the USB core to check what this driver support. | |
Xbox Controller functions | |
uint16_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 | attachOnInit (void(*funcOnInit)(void)) |
Used to call your own function when the controller is successfully initialized. | |
void | setRumbleOff () |
Used to set the rumble off. | |
void | setRumbleOn (uint8_t leftTrigger, uint8_t rightTrigger, uint8_t leftMotor, uint8_t rightMotor) |
Used to turn on rumble continuously. | |
Data Fields | |
bool | XboxOneConnected |
True if a Xbox ONE controller is connected. | |
Protected Member Functions | |
void | PrintEndpointDescriptor (const USB_ENDPOINT_DESCRIPTOR *ep_ptr) |
Used to print the USB Endpoint Descriptor. | |
UsbConfigXtracter implementation | |
void | EndpointXtract (uint8_t conf, uint8_t iface, uint8_t alt, uint8_t proto, const USB_ENDPOINT_DESCRIPTOR *ep) |
UsbConfigXtracter implementation, used to extract endpoint information. | |
Protected Attributes | |
Usb * | pUsb |
Pointer to USB class instance. | |
uint8_t | bAddress |
Device address. | |
EpInfo | epInfo [XBOX_ONE_MAX_ENDPOINTS] |
Endpoint info structure. | |
uint8_t | bConfNum |
Configuration number. | |
uint8_t | bNumEP |
Total number of endpoints in the configuration. | |
uint32_t | qNextPollTime |
Next poll time based on poll interval taken from the USB descriptor. |
Detailed Description
This class implements support for a Xbox ONE controller connected via USB.
Definition at line 66 of file XBOXONE.h.
Constructor & Destructor Documentation
XBOXONE | ( | Usb * | pUsb ) |
Constructor for the XBOXONE class.
- Parameters:
-
pUsb Pointer to USB class instance.
Definition at line 27 of file XBOXONE.cpp.
Member Function Documentation
void attachOnInit | ( | void(*)(void) | funcOnInit ) |
void EndpointXtract | ( | uint8_t | conf, |
uint8_t | iface, | ||
uint8_t | alt, | ||
uint8_t | proto, | ||
const USB_ENDPOINT_DESCRIPTOR * | ep | ||
) | [protected] |
UsbConfigXtracter implementation, used to extract endpoint information.
- Parameters:
-
conf Configuration value. iface Interface number. alt Alternate setting. proto Interface Protocol. ep Endpoint Descriptor.
virtual uint8_t GetAddress | ( | ) | [virtual] |
int16_t getAnalogHat | ( | AnalogHatEnum | a ) |
Return the analog value from the joysticks on the controller.
- Parameters:
-
a Either LeftHatX, LeftHatY, RightHatX or RightHatY.
- Returns:
- Returns a signed 16-bit integer.
Definition at line 408 of file XBOXONE.cpp.
uint16_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:
-
b ButtonEnum 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 380 of file XBOXONE.cpp.
uint8_t Init | ( | uint8_t | parent, |
uint8_t | port, | ||
bool | lowspeed | ||
) | [virtual] |
Initialize the Xbox Controller.
- Parameters:
-
parent Hub number. port Port number on the hub. lowspeed Speed of the device.
- Returns:
- 0 on success.
Definition at line 46 of file XBOXONE.cpp.
virtual bool isReady | ( | ) | [virtual] |
uint8_t Poll | ( | ) | [virtual] |
Poll the USB Input endpoins and run the state machines.
- Returns:
- 0 on success.
Definition at line 300 of file XBOXONE.cpp.
void PrintEndpointDescriptor | ( | const USB_ENDPOINT_DESCRIPTOR * | ep_ptr ) | [protected] |
Used to print the USB Endpoint Descriptor.
- Parameters:
-
ep_ptr Pointer to USB Endpoint Descriptor.
uint8_t readPollInterval | ( | ) |
uint8_t Release | ( | ) | [virtual] |
void setRumbleOff | ( | ) |
Used to set the rumble off.
Definition at line 450 of file XBOXONE.cpp.
void setRumbleOn | ( | uint8_t | leftTrigger, |
uint8_t | rightTrigger, | ||
uint8_t | leftMotor, | ||
uint8_t | rightMotor | ||
) |
Used to turn on rumble continuously.
- Parameters:
-
leftTrigger Left trigger force. rightTrigger Right trigger force. leftMotor Left motor force. rightMotor Right motor force.
Definition at line 472 of file XBOXONE.cpp.
virtual bool VIDPIDOK | ( | uint16_t | vid, |
uint16_t | pid | ||
) | [virtual] |
Field Documentation
uint8_t bNumEP [protected] |
EpInfo epInfo[XBOX_ONE_MAX_ENDPOINTS] [protected] |
uint32_t qNextPollTime [protected] |
bool XboxOneConnected |
Generated on Tue Jul 12 2022 18:12:05 by
