USB Host Shield 2.0
|
#include <XBOXRECV.h>
Public Member Functions | |
XBOXRECV (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 () |
Xbox Controller functions | |
uint8_t | getButtonPress (uint8_t controller, Button b) |
bool | getButtonClick (uint8_t controller, Button b) |
int16_t | getAnalogHat (uint8_t controller, AnalogHat a) |
void | setAllOff (uint8_t controller) |
void | setRumbleOff (uint8_t controller) |
void | setRumbleOn (uint8_t controller, uint8_t lValue, uint8_t rValue) |
void | setLedRaw (uint8_t controller, uint8_t value) |
void | setLedOff (uint8_t controller) |
void | setLedOn (uint8_t controller, LED l) |
void | setLedBlink (uint8_t controller, LED l) |
void | setLedMode (uint8_t controller, LEDMode lm) |
uint8_t | getBatteryLevel (uint8_t controller) |
bool | buttonChanged (uint8_t controller) |
Public Attributes | |
bool | XboxReceiverConnected |
uint8_t | Xbox360Connected [4] |
Protected Attributes | |
USB * | pUsb |
uint8_t | bAddress |
EpInfo | epInfo [XBOX_MAX_ENDPOINTS] |
This class implements support for a Xbox Wireless receiver.
Up to four controllers can connect to one receiver, if more is needed one can use a second receiver via the USBHub class.
Definition at line 63 of file XBOXRECV.h.
XBOXRECV::XBOXRECV | ( | USB * | pUsb | ) |
Constructor for the XBOXRECV class.
pUsb | Pointer to USB class instance. |
Definition at line 25 of file XBOXRECV.cpp.
|
virtual |
Initialize the Xbox wireless receiver.
parent | Hub number. |
port | Port number on the hub. |
lowspeed | Speed of the device. |
Implements USBDeviceConfig.
Definition at line 40 of file XBOXRECV.cpp.
|
virtual |
Release the USB device.
Implements USBDeviceConfig.
Definition at line 246 of file XBOXRECV.cpp.
|
virtual |
Poll the USB Input endpoins and run the state machines.
Implements USBDeviceConfig.
Definition at line 256 of file XBOXRECV.cpp.
|
inlinevirtual |
Get the device address.
Implements USBDeviceConfig.
Definition at line 95 of file XBOXRECV.h.
|
inlinevirtual |
Used to check if the controller has been initialized.
Definition at line 103 of file XBOXRECV.h.
uint8_t XBOXRECV::getButtonPress | ( | uint8_t | controller, |
Button | b | ||
) |
getButtonPress(uint8_t controller, Button b) will return true as long as the button is held down.
While getButtonClick(uint8_t controller, Button b) will only return it once.
So you instance if you need to increase a variable once you would use getButtonClick(uint8_t controller, Button b), but if you need to drive a robot forward you would use getButtonPress(uint8_t controller, Button b).
controller | The controller to read from. |
b | Button to read. |
Definition at line 384 of file XBOXRECV.cpp.
bool XBOXRECV::getButtonClick | ( | uint8_t | controller, |
Button | b | ||
) |
getButtonPress(uint8_t controller, Button b) will return true as long as the button is held down.
While getButtonClick(uint8_t controller, Button b) will only return it once.
So you instance if you need to increase a variable once you would use getButtonClick(uint8_t controller, Button b), but if you need to drive a robot forward you would use getButtonPress(uint8_t controller, Button b).
controller | The controller to read from. |
b | Button to read. |
Definition at line 392 of file XBOXRECV.cpp.
int16_t XBOXRECV::getAnalogHat | ( | uint8_t | controller, |
AnalogHat | a | ||
) |
|
inline |
Turn rumble off and all the LEDs on the specific controller.
controller | The controller to write to. |
Definition at line 138 of file XBOXRECV.h.
|
inline |
Turn rumble off the specific controller.
controller | The controller to write to. |
Definition at line 147 of file XBOXRECV.h.
void XBOXRECV::setRumbleOn | ( | uint8_t | controller, |
uint8_t | lValue, | ||
uint8_t | rValue | ||
) |
Turn rumble on.
controller | The controller to write to. |
lValue | Left motor (big weight) inside the controller. |
rValue | Right motor (small weight) inside the controller. |
Definition at line 513 of file XBOXRECV.cpp.
void XBOXRECV::setLedRaw | ( | uint8_t | controller, |
uint8_t | value | ||
) |
Set LED value. Without using the LED or LEDMode enum.
controller | The controller to write to. |
value | See: setLedOff(uint8_t controller), setLedOn(uint8_t controller, LED l), setLedBlink(uint8_t controller, LED l), and setLedMode(uint8_t controller, LEDMode lm). |
Definition at line 465 of file XBOXRECV.cpp.
|
inline |
Turn all LEDs off the specific controller.
controller | The controller to write to. |
Definition at line 170 of file XBOXRECV.h.
void XBOXRECV::setLedOn | ( | uint8_t | controller, |
LED | l | ||
) |
void XBOXRECV::setLedBlink | ( | uint8_t | controller, |
LED | l | ||
) |
void XBOXRECV::setLedMode | ( | uint8_t | controller, |
LEDMode | lm | ||
) |
Used to set special LED modes supported by the Xbox controller.
controller | The controller to write to. |
lm | See LEDMode. |
Definition at line 483 of file XBOXRECV.cpp.
uint8_t XBOXRECV::getBatteryLevel | ( | uint8_t | controller | ) |
Used to get the battery level from the controller.
controller | The controller to read from. |
Definition at line 441 of file XBOXRECV.cpp.
bool XBOXRECV::buttonChanged | ( | uint8_t | controller | ) |
Used to check if a button has changed.
controller | The controller to read from. |
Definition at line 416 of file XBOXRECV.cpp.
bool XBOXRECV::XboxReceiverConnected |
True if a wireless receiver is connected.
Definition at line 206 of file XBOXRECV.h.
uint8_t XBOXRECV::Xbox360Connected[4] |
Variable used to indicate if the XBOX 360 controller is successfully connected.
Definition at line 208 of file XBOXRECV.h.
|
protected |
Pointer to USB class instance.
Definition at line 212 of file XBOXRECV.h.
|
protected |
Device address.
Definition at line 214 of file XBOXRECV.h.
|
protected |
Endpoint info structure.
Definition at line 216 of file XBOXRECV.h.