USB Host Shield 2.0
Public Member Functions | Public Attributes | List of all members
PS5Parser Class Referenceabstract

#include <PS5Parser.h>

Inheritance diagram for PS5Parser:
Inheritance graph
[legend]
Collaboration diagram for PS5Parser:
Collaboration graph
[legend]

Public Member Functions

 PS5Parser ()
 

Public Attributes

PS5Trigger leftTrigger
 
PS5Trigger rightTrigger
 

PS5 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)
 
uint16_t getY (uint8_t finger=0)
 
bool isTouching (uint8_t finger=0)
 
uint8_t getTouchCounter (uint8_t finger=0)
 
float getAngle (AngleEnum a)
 
int16_t getSensor (SensorEnum s)
 
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 setPlayerLedOff ()
 
void setPlayerLed (uint8_t mask)
 
void setMicLedOff ()
 
void setMicLed (bool on)
 
uint16_t getMessageCounter ()
 
void Parse (uint8_t len, uint8_t *buf)
 
void Reset ()
 
virtual void sendOutputReport (PS5Output *output)=0
 

Detailed Description

This class parses all the data sent by the PS5 controller

Definition at line 149 of file PS5Parser.h.

Constructor & Destructor Documentation

◆ PS5Parser()

PS5Parser::PS5Parser ( )
inline

Constructor for the PS5Parser class.

Definition at line 152 of file PS5Parser.h.

Member Function Documentation

◆ getButtonPress()

bool PS5Parser::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
bButtonEnum to read.
Returns
getButtonPress(ButtonEnum b) will return a true as long as a button is held down, while getButtonClick(ButtonEnum b) will return true once for each button press.

Definition at line 60 of file PS5Parser.cpp.

◆ getButtonClick()

bool PS5Parser::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).

Parameters
bButtonEnum to read.
Returns
getButtonPress(ButtonEnum b) will return a true as long as a button is held down, while getButtonClick(ButtonEnum b) will return true once for each button press.

Definition at line 68 of file PS5Parser.cpp.

◆ getAnalogButton()

uint8_t PS5Parser::getAnalogButton ( ButtonEnum  b)

Used to get the analog value from button presses.

Parameters
bThe ButtonEnum to read. The supported buttons are: L2 and R2.
Returns
Analog value in the range of 0-255.

Definition at line 76 of file PS5Parser.cpp.

◆ getAnalogHat()

uint8_t PS5Parser::getAnalogHat ( AnalogHatEnum  a)

Used to read the analog joystick.

Parameters
aLeftHatX, LeftHatY, RightHatX, and RightHatY.
Returns
Return the analog value in the range of 0-255.

Definition at line 85 of file PS5Parser.cpp.

◆ getX()

uint16_t PS5Parser::getX ( uint8_t  finger = 0)
inline

Get the x-coordinate of the touchpad. Position 0 is in the top left.

Parameters
finger0 = first finger, 1 = second finger. If omitted, then 0 will be used.

Definition at line 194 of file PS5Parser.h.

◆ getY()

uint16_t PS5Parser::getY ( uint8_t  finger = 0)
inline

Get the y-coordinate of the touchpad. Position 0 is in the top left.

Parameters
finger0 = first finger, 1 = second finger. If omitted, then 0 will be used.
Returns
Returns the y-coordinate of the finger.

Definition at line 203 of file PS5Parser.h.

◆ isTouching()

bool PS5Parser::isTouching ( uint8_t  finger = 0)
inline

Returns whenever the user is toucing the touchpad.

Parameters
finger0 = first finger, 1 = second finger. If omitted, then 0 will be used.
Returns
Returns true if the specific finger is touching the touchpad.

Definition at line 212 of file PS5Parser.h.

◆ getTouchCounter()

uint8_t PS5Parser::getTouchCounter ( uint8_t  finger = 0)
inline

This counter increments every time a finger touches the touchpad.

Parameters
finger0 = first finger, 1 = second finger. If omitted, then 0 will be used.
Returns
Return the value of the counter, note that it is only a 7-bit value.

Definition at line 221 of file PS5Parser.h.

◆ getAngle()

float PS5Parser::getAngle ( AngleEnum  a)
inline

Get the angle of the controller calculated using the accelerometer.

Parameters
aEither Pitch or Roll.
Returns
Return the angle in the range of 0-360.

Definition at line 230 of file PS5Parser.h.

◆ getSensor()

int16_t PS5Parser::getSensor ( SensorEnum  s)
inline

Used to get the raw values from the 3-axis gyroscope and 3-axis accelerometer inside the PS5 controller.

Parameters
sThe sensor to read.
Returns
Returns the raw sensor reading.

Definition at line 242 of file PS5Parser.h.

◆ setAllOff()

void PS5Parser::setAllOff ( )
inline

Turn both rumble and the LEDs off.

Definition at line 298 of file PS5Parser.h.

◆ setRumbleOff()

void PS5Parser::setRumbleOff ( )
inline

Set rumble off.

Definition at line 304 of file PS5Parser.h.

◆ setRumbleOn() [1/2]

void PS5Parser::setRumbleOn ( RumbleEnum  mode)
inline

Turn on rumble.

Parameters
modeEither RumbleHigh or RumbleLow.

Definition at line 312 of file PS5Parser.h.

◆ setRumbleOn() [2/2]

void PS5Parser::setRumbleOn ( uint8_t  bigRumble,
uint8_t  smallRumble 
)
inline

Turn on rumble.

Parameters
bigRumbleValue for big motor.
smallRumbleValue for small motor.

Definition at line 324 of file PS5Parser.h.

◆ setLedOff()

void PS5Parser::setLedOff ( )
inline

Turn all LEDs off.

Definition at line 331 of file PS5Parser.h.

◆ setLed() [1/2]

void PS5Parser::setLed ( uint8_t  r,
uint8_t  g,
uint8_t  b 
)
inline

Use this to set the color using RGB values.

Parameters
r,g,bRGB value.

Definition at line 339 of file PS5Parser.h.

◆ setLed() [2/2]

void PS5Parser::setLed ( ColorsEnum  color)
inline

Use this to set the color using the predefined colors in ColorsEnum.

Parameters
colorThe desired color.

Definition at line 350 of file PS5Parser.h.

◆ setPlayerLedOff()

void PS5Parser::setPlayerLedOff ( )
inline

Turn all player LEDs off.

Definition at line 355 of file PS5Parser.h.

◆ setPlayerLed()

void PS5Parser::setPlayerLed ( uint8_t  mask)
inline

Use this to set five player LEDs.

Parameters
maskBit mask to set the five player LEDs. The first 5 bits represent a LED each.

Definition at line 363 of file PS5Parser.h.

◆ setMicLedOff()

void PS5Parser::setMicLedOff ( )
inline

Use to turn the microphone LED off.

Definition at line 369 of file PS5Parser.h.

◆ setMicLed()

void PS5Parser::setMicLed ( bool  on)
inline

Use this to turn the microphone LED on/off.

Parameters
onTurn the microphone LED on/off.

Definition at line 377 of file PS5Parser.h.

◆ getMessageCounter()

uint16_t PS5Parser::getMessageCounter ( )
inline

Get the incoming message count.

Definition at line 383 of file PS5Parser.h.

◆ Parse()

void PS5Parser::Parse ( uint8_t  len,
uint8_t *  buf 
)
protected

Used to parse data sent from the PS5 controller.

Parameters
lenLength of the data.
bufPointer to the data buffer.

Definition at line 89 of file PS5Parser.cpp.

◆ Reset()

void PS5Parser::Reset ( )
protected

Used to reset the different buffers to their default values

Definition at line 149 of file PS5Parser.cpp.

◆ sendOutputReport()

virtual void PS5Parser::sendOutputReport ( PS5Output output)
protectedpure virtual

Send the output to the PS5 controller. This is implemented in PS5BT.h and PS5USB.h.

Parameters
outputPointer to PS5Output buffer;

Implemented in PS5BT, and PS5USB.

Member Data Documentation

◆ leftTrigger

PS5Trigger PS5Parser::leftTrigger

Used these to manipulate the haptic triggers

Definition at line 154 of file PS5Parser.h.

◆ rightTrigger

PS5Trigger PS5Parser::rightTrigger

Definition at line 157 of file PS5Parser.h.


The documentation for this class was generated from the following files: