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.
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:
-
pUsb Pointer to USB class instance.
Definition at line 47 of file XBOXOLD.cpp.
Member Function Documentation
| void attachOnInit | ( | void(*)(void) | funcOnInit ) |
| 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 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:
-
b ButtonEnum 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:
-
parent Hub number. port Port number on the hub. lowspeed Speed of the device.
- Returns:
- 0 on success.
Definition at line 63 of file XBOXOLD.cpp.
| virtual bool isReady | ( | ) | [virtual] |
| 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 | ( | ) |
| void setRumbleOn | ( | uint8_t | lValue, |
| uint8_t | rValue | ||
| ) |
Turn rumble on.
- Parameters:
-
lValue Left motor (big weight) inside the controller. rValue Right motor (small weight) inside the controller.
Definition at line 327 of file XBOXOLD.cpp.
| virtual bool VIDPIDOK | ( | uint16_t | vid, |
| uint16_t | pid | ||
| ) | [virtual] |
Field Documentation
EpInfo epInfo[XBOX_MAX_ENDPOINTS] [protected] |
| bool XboxConnected |
Generated on Thu Jul 14 2022 08:33:41 by
1.7.2