39 int8_t PS5Parser::getButtonIndexPS5(
ButtonEnum b) {
61 const int8_t index = getButtonIndexPS5(b);
if (index < 0)
return 0;
69 const int8_t index = getButtonIndexPS5(b);
if (index < 0)
return 0;
71 bool click = buttonClickState.
val & mask;
72 buttonClickState.
val &= ~mask;
77 const int8_t index = getButtonIndexPS5(b);
if (index < 0)
return 0;
94 for (uint8_t i = 0; i < len; i++) {
95 D_PrintHex<uint8_t > (buf[i], 0x80);
101 memcpy(&ps5Data, buf + 1, min((uint8_t)(len - 1),
MFK_CASTUINT8T sizeof(ps5Data)));
102 else if (buf[0] == 0x31) {
104 #ifdef DEBUG_USB_HOST
105 Notify(
PSTR(
"\r\nReport is too short: "), 0x80);
106 D_PrintHex<uint8_t > (len, 0x80);
110 memcpy(&ps5Data, buf + 2, min((uint8_t)(len - 2),
MFK_CASTUINT8T sizeof(ps5Data)));
112 #ifdef DEBUG_USB_HOST
113 Notify(
PSTR(
"\r\nUnknown report id: "), 0x80);
114 D_PrintHex<uint8_t > (buf[0], 0x80);
116 D_PrintHex<uint8_t > (len, 0x80);
121 if (ps5Data.
btn.
val != oldButtonState.
val) {
122 buttonClickState.
val = ps5Data.
btn.
val & ~oldButtonState.
val;
129 if (checkDpad(
RIGHT))
130 newDpad |= 1 <<
RIGHT;
132 newDpad |= 1 <<
DOWN;
134 newDpad |= 1 <<
LEFT;
135 if (newDpad != oldDpad) {
136 buttonClickState.
dpad = newDpad & ~oldDpad;
151 for (i = 0; i <
sizeof(ps5Data.
hatValue); i++)
154 oldButtonState.
val = 0;
155 for (i = 0; i <
sizeof(ps5Data.
trigger); i++)
157 for (i = 0; i <
sizeof(ps5Data.
xy.
finger)/
sizeof(ps5Data.
xy.
finger[0]); i++)
162 buttonClickState.
dpad = 0;
172 ps5Output.
r = ps5Output.
g = ps5Output.
b = 0;
const uint8_t PS5_BUTTONS[]
void Parse(uint8_t len, uint8_t *buf)
bool getButtonPress(ButtonEnum b)
bool getButtonClick(ButtonEnum b)
uint8_t getAnalogHat(AnalogHatEnum a)
virtual void sendOutputReport(PS5Output *output)=0
uint8_t getAnalogButton(ButtonEnum b)
constexpr int8_t ButtonIndex(ButtonEnum key)
struct ps5TouchpadXY::@31 finger[2]
#define pgm_read_byte(addr)