42 uint8_t button = pgm_read_byte(&
PS4_BUTTONS[(uint8_t)b]);
43 uint8_t index = button < 8 ? 0 : button < 16 ? 1 : 2;
44 uint8_t mask = 1 << (button - 8 * index);
45 return ps4Data.
btn.
val[index] & mask;
50 uint8_t mask, index = 0;
54 uint8_t button = pgm_read_byte(&
PS4_BUTTONS[(uint8_t)b]);
55 index = button < 8 ? 0 : button < 16 ? 1 : 2;
56 mask = 1 << (button - 8 * index);
59 bool click = buttonClickState.
val[index] & mask;
60 buttonClickState.
val[index] &= ~mask;
79 for (uint8_t i = 0; i < len; i++) {
80 D_PrintHex<uint8_t > (buf[i], 0x80);
83 Notify(PSTR(
"\r\n"), 0x80);
86 memcpy(&ps4Data, buf, min(len,
sizeof(ps4Data)));
89 Notify(PSTR(
"\r\nUnknown report id"), 0x80);
94 for (uint8_t i = 0; i <
sizeof(ps4Data.
btn); i++) {
95 if (ps4Data.
btn.
val[i] != oldButtonState.
val[i]) {
96 buttonClickState.
val[i] = ps4Data.
btn.
val[i] & ~oldButtonState.
val[i];
97 oldButtonState.
val[i] = ps4Data.
btn.
val[i];
102 if (checkDpad(
RIGHT))
103 newDpad |= 1 <<
RIGHT;
105 newDpad |= 1 <<
DOWN;
107 newDpad |= 1 <<
LEFT;
108 if (newDpad != oldDpad) {
109 buttonClickState.
dpad = newDpad & ~oldDpad;
bool getButtonPress(ButtonEnum b)
void Parse(uint8_t len, uint8_t *buf)
const uint8_t PS4_BUTTONS[]
uint8_t getAnalogButton(ButtonEnum b)
bool getButtonClick(ButtonEnum b)
uint8_t getAnalogHat(AnalogHatEnum a)