USB Host Shield 2.0
|
#include <PS4Parser.h>
Public Member Functions | |
PS4Parser () | |
PS4 Controller functions | |
bool | getButtonPress (ButtonEnum b) |
bool | getButtonClick (ButtonEnum b) |
uint8_t | getAnalogButton (ButtonEnum b) |
uint8_t | getAnalogHat (AnalogHatEnum a) |
uint16_t | getX (uint8_t finger=0, uint8_t xyId=0) |
uint16_t | getY (uint8_t finger=0, uint8_t xyId=0) |
bool | isTouching (uint8_t finger=0, uint8_t xyId=0) |
uint8_t | getTouchCounter (uint8_t finger=0, uint8_t xyId=0) |
double | getAngle (AngleEnum a) |
int16_t | getSensor (SensorEnum s) |
uint8_t | getBatteryLevel () |
bool | getUsbStatus () |
bool | getAudioStatus () |
bool | getMicStatus () |
void | setAllOff () |
void | setRumbleOff () |
void | setRumbleOn (RumbleEnum mode) |
void | setRumbleOn (uint8_t bigRumble, uint8_t smallRumble) |
void | setLedOff () |
void | setLed (uint8_t r, uint8_t g, uint8_t b) |
void | setLed (ColorsEnum color) |
void | setLedFlash (uint8_t flashOn, uint8_t flashOff) |
Protected Member Functions | |
void | Parse (uint8_t len, uint8_t *buf) |
void | Reset () |
virtual void | sendOutputReport (PS4Output *output)=0 |
This class parses all the data sent by the PS4 controller
Definition at line 136 of file PS4Parser.h.
|
inline |
Constructor for the PS4Parser class.
Definition at line 139 of file PS4Parser.h.
bool PS4Parser::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).
b | ButtonEnum to read. |
Definition at line 38 of file PS4Parser.cpp.
bool PS4Parser::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).
b | ButtonEnum to read. |
Definition at line 45 of file PS4Parser.cpp.
uint8_t PS4Parser::getAnalogButton | ( | ButtonEnum | b | ) |
uint8_t PS4Parser::getAnalogHat | ( | AnalogHatEnum | a | ) |
|
inline |
Get the x-coordinate of the touchpad. Position 0 is in the top left.
finger | 0 = first finger, 1 = second finger. If omitted, then 0 will be used. |
xyId | The controller sends out three packets with the same structure. The third one will contain the last measure, but if you read from the controller then there is only be data in the first one. For that reason it will be set to 0 if the argument is omitted. |
Definition at line 183 of file PS4Parser.h.
|
inline |
Get the y-coordinate of the touchpad. Position 0 is in the top left.
finger | 0 = first finger, 1 = second finger. If omitted, then 0 will be used. |
xyId | The controller sends out three packets with the same structure. The third one will contain the last measure, but if you read from the controller then there is only be data in the first one. For that reason it will be set to 0 if the argument is omitted. |
Definition at line 195 of file PS4Parser.h.
|
inline |
Returns whenever the user is toucing the touchpad.
finger | 0 = first finger, 1 = second finger. If omitted, then 0 will be used. |
xyId | The controller sends out three packets with the same structure. The third one will contain the last measure, but if you read from the controller then there is only be data in the first one. For that reason it will be set to 0 if the argument is omitted. |
Definition at line 207 of file PS4Parser.h.
|
inline |
This counter increments every time a finger touches the touchpad.
finger | 0 = first finger, 1 = second finger. If omitted, then 0 will be used. |
xyId | The controller sends out three packets with the same structure. The third one will contain the last measure, but if you read from the controller then there is only be data in the first one. For that reason it will be set to 0 if the argument is omitted. |
Definition at line 219 of file PS4Parser.h.
|
inline |
Get the angle of the controller calculated using the accelerometer.
Definition at line 228 of file PS4Parser.h.
|
inline |
Used to get the raw values from the 3-axis gyroscope and 3-axis accelerometer inside the PS4 controller.
s | The sensor to read. |
Definition at line 240 of file PS4Parser.h.
|
inline |
Return the battery level of the PS4 controller.
Definition at line 263 of file PS4Parser.h.
|
inline |
Use this to check if an USB cable is connected to the PS4 controller.
Definition at line 271 of file PS4Parser.h.
|
inline |
Use this to check if an audio jack cable is connected to the PS4 controller.
Definition at line 279 of file PS4Parser.h.
|
inline |
Use this to check if a microphone is connected to the PS4 controller.
Definition at line 287 of file PS4Parser.h.
|
inline |
Turn both rumble and the LEDs off.
Definition at line 292 of file PS4Parser.h.
|
inline |
Set rumble off.
Definition at line 298 of file PS4Parser.h.
|
inline |
Turn on rumble.
mode | Either RumbleHigh or RumbleLow. |
Definition at line 306 of file PS4Parser.h.
|
inline |
Turn on rumble.
bigRumble | Value for big motor. |
smallRumble | Value for small motor. |
Definition at line 318 of file PS4Parser.h.
|
inline |
Turn all LEDs off.
Definition at line 325 of file PS4Parser.h.
|
inline |
Use this to set the color using RGB values.
r,g,b | RGB value. |
Definition at line 333 of file PS4Parser.h.
|
inline |
Use this to set the color using the predefined colors in ColorsEnum.
color | The desired color. |
Definition at line 344 of file PS4Parser.h.
|
inline |
Set the LEDs flash time.
flashOn | Time to flash bright (255 = 2.5 seconds). |
flashOff | Time to flash dark (255 = 2.5 seconds). |
Definition at line 353 of file PS4Parser.h.
|
protected |
Used to parse data sent from the PS4 controller.
len | Length of the data. |
buf | Pointer to the data buffer. |
Definition at line 64 of file PS4Parser.cpp.
|
inlineprotected |
Used to reset the different buffers to their default values
Definition at line 369 of file PS4Parser.h.
|
protectedpure virtual |