USB Host Shield 2.0
|
#include <PS3USB.h>
Public Member Functions | |
PS3USB (USB *pUsb, uint8_t btadr5=0, uint8_t btadr4=0, uint8_t btadr3=0, uint8_t btadr2=0, uint8_t btadr1=0, uint8_t btadr0=0) | |
void | setBdaddr (uint8_t *bdaddr) |
void | getBdaddr (uint8_t *bdaddr) |
void | setMoveBdaddr (uint8_t *bdaddr) |
void | getMoveBdaddr (uint8_t *bdaddr) |
void | getMoveCalibration (uint8_t *data) |
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 boolean | VIDPIDOK (uint16_t vid, uint16_t pid) |
PS3 Controller functions | |
bool | getButtonPress (Button b) |
bool | getButtonClick (Button b) |
uint8_t | getAnalogButton (Button a) |
uint8_t | getAnalogHat (AnalogHat a) |
uint16_t | getSensor (Sensor a) |
double | getAngle (Angle a) |
bool | getStatus (Status c) |
String | getStatusString () |
void | setAllOff () |
void | setRumbleOff () |
void | setRumbleOn (Rumble mode) |
void | setRumbleOn (uint8_t rightDuration, uint8_t rightPower, uint8_t leftDuration, uint8_t leftPower) |
void | setLedRaw (uint8_t value) |
void | setLedOff () |
void | setLedOff (LED a) |
void | setLedOn (LED a) |
void | setLedToggle (LED a) |
void | moveSetBulb (uint8_t r, uint8_t g, uint8_t b) |
void | moveSetBulb (Colors color) |
void | moveSetRumble (uint8_t rumble) |
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 boolean | DEVCLASSOK (uint8_t klass) |
Public Attributes | |
bool | PS3Connected |
bool | PS3MoveConnected |
bool | PS3NavigationConnected |
Protected Attributes | |
USB * | pUsb |
uint8_t | bAddress |
EpInfo | epInfo [PS3_MAX_ENDPOINTS] |
This class implements support for all the official PS3 Controllers: Dualshock 3, Navigation or a Motion controller via USB.
One can only set the color of the bulb, set the rumble, set and get the bluetooth address and calibrate the magnetometer via USB on the Move controller.
Information about the protocol can be found at the wiki: https://github.com/felis/USB_Host_Shield_2.0/wiki/PS3-Information.
PS3USB::PS3USB | ( | USB * | pUsb, |
uint8_t | btadr5 = 0 , |
||
uint8_t | btadr4 = 0 , |
||
uint8_t | btadr3 = 0 , |
||
uint8_t | btadr2 = 0 , |
||
uint8_t | btadr1 = 0 , |
||
uint8_t | btadr0 = 0 |
||
) |
Constructor for the PS3USB class.
pUsb | Pointer to USB class instance. |
btadr5,btadr4,btadr3,btadr2,btadr1,btadr0 | Pass your dongles Bluetooth address into the constructor, so you are able to pair the controller with a Bluetooth dongle. |
Definition at line 23 of file PS3USB.cpp.
|
virtual |
Initialize the PS3 Controller.
parent | Hub number. |
port | Port number on the hub. |
lowspeed | Speed of the device. |
Reimplemented from USBDeviceConfig.
Definition at line 46 of file PS3USB.cpp.
|
virtual |
Release the USB device.
Reimplemented from USBDeviceConfig.
Definition at line 258 of file PS3USB.cpp.
|
virtual |
Poll the USB Input endpoins and run the state machines.
Reimplemented from USBDeviceConfig.
Definition at line 268 of file PS3USB.cpp.
|
inlinevirtual |
|
inlinevirtual |
|
inlinevirtual |
Used by the USB core to check what this driver support.
vid | The device's VID. |
pid | The device's PID. |
Reimplemented from USBDeviceConfig.
void PS3USB::setBdaddr | ( | uint8_t * | bdaddr | ) |
Used to set the Bluetooth address inside the Dualshock 3 and Navigation controller. Set using LSB first.
bdaddr | Your dongles Bluetooth address. |
Definition at line 458 of file PS3USB.cpp.
void PS3USB::getBdaddr | ( | uint8_t * | bdaddr | ) |
Used to get the Bluetooth address inside the Dualshock 3 and Navigation controller. Will return LSB first.
bdaddr | Your dongles Bluetooth address. |
Definition at line 471 of file PS3USB.cpp.
void PS3USB::setMoveBdaddr | ( | uint8_t * | bdaddr | ) |
Used to set the Bluetooth address inside the Move controller. Set using LSB first.
bdaddr | Your dongles Bluetooth address. |
Definition at line 520 of file PS3USB.cpp.
void PS3USB::getMoveBdaddr | ( | uint8_t * | bdaddr | ) |
Used to get the Bluetooth address inside the Move controller. Will return LSB first.
bdaddr | Your dongles Bluetooth address. |
Definition at line 536 of file PS3USB.cpp.
void PS3USB::getMoveCalibration | ( | uint8_t * | data | ) |
Used to get the calibration data inside the Move controller.
data | Buffer to store data in. Must be at least 147 bytes |
Definition at line 546 of file PS3USB.cpp.
bool PS3USB::getButtonPress | ( | Button | b | ) |
getButtonPress(Button b) will return true as long as the button is held down.
While getButtonClick(Button b) will only return it once.
So you instance if you need to increase a variable once you would use getButtonClick(Button b), but if you need to drive a robot forward you would use getButtonPress(Button b).
Definition at line 312 of file PS3USB.cpp.
bool PS3USB::getButtonClick | ( | Button | b | ) |
getButtonPress(Button b) will return true as long as the button is held down.
While getButtonClick(Button b) will only return it once.
So you instance if you need to increase a variable once you would use getButtonClick(Button b), but if you need to drive a robot forward you would use getButtonPress(Button b).
Definition at line 316 of file PS3USB.cpp.
uint8_t PS3USB::getAnalogButton | ( | Button | a | ) |
uint8_t PS3USB::getAnalogHat | ( | AnalogHat | a | ) |
uint16_t PS3USB::getSensor | ( | Sensor | a | ) |
Used to read the sensors inside the Dualshock 3 controller.
a | The Dualshock 3 has a 3-axis accelerometer and a 1-axis gyro inside. |
Definition at line 331 of file PS3USB.cpp.
double PS3USB::getAngle | ( | Angle | a | ) |
bool PS3USB::getStatus | ( | Status | c | ) |
Get the Status from the controller.
c | The Status you want to read. |
Definition at line 358 of file PS3USB.cpp.
String PS3USB::getStatusString | ( | ) |
Read all the available Status from the controller.
Definition at line 362 of file PS3USB.cpp.
void PS3USB::setAllOff | ( | ) |
Used to set all LEDs and Rumble off.
Definition at line 403 of file PS3USB.cpp.
void PS3USB::setRumbleOff | ( | ) |
Turn off Rumble.
Definition at line 410 of file PS3USB.cpp.
void PS3USB::setRumbleOn | ( | Rumble | mode | ) |
Turn on Rumble.
mode | Either RumbleHigh or RumbleLow. |
Definition at line 419 of file PS3USB.cpp.
void PS3USB::setRumbleOn | ( | uint8_t | rightDuration, |
uint8_t | rightPower, | ||
uint8_t | leftDuration, | ||
uint8_t | leftPower | ||
) |
Turn on Rumble using custom duration and power.
rightDuration | The duration of the right/low rumble effect. |
rightPower | The intensity of the right/low rumble effect. |
leftDuration | The duration of the left/high rumble effect. |
leftPower | The intensity of the left/high rumble effect. |
Definition at line 430 of file PS3USB.cpp.
void PS3USB::setLedRaw | ( | uint8_t | value | ) |
Set LED value without using the LED enum.
value | See: LED enum. |
Definition at line 438 of file PS3USB.cpp.
void PS3USB::setLedOff | ( | LED | a | ) |
Turn the specific LED off.
a | The LED to turn off. |
Definition at line 443 of file PS3USB.cpp.
void PS3USB::setLedOn | ( | LED | a | ) |
Turn the specific LED on.
a | The LED to turn on. |
Definition at line 448 of file PS3USB.cpp.
void PS3USB::setLedToggle | ( | LED | a | ) |
void PS3USB::moveSetBulb | ( | uint8_t | r, |
uint8_t | g, | ||
uint8_t | b | ||
) |
Use this to set the Color using RGB values.
r,g,b | RGB value. |
Definition at line 497 of file PS3USB.cpp.
void PS3USB::moveSetBulb | ( | Colors | color | ) |
Use this to set the color using the predefined colors in Colors.
color | The desired color. |
Definition at line 506 of file PS3USB.cpp.
void PS3USB::moveSetRumble | ( | uint8_t | rumble | ) |
Set the rumble value inside the Move controller.
rumble | The desired value in the range from 64-255. |
Definition at line 510 of file PS3USB.cpp.
|
inline |
bool PS3USB::PS3Connected |
bool PS3USB::PS3MoveConnected |
bool PS3USB::PS3NavigationConnected |
|
protected |