27 for (uint8_t i = 0; i < len; i++) {
28 D_PrintHex<uint8_t > (buf[i], 0x80);
32 memcpy(&psbuzzButtons, buf + 2, min((uint8_t)(len - 2),
MFK_CASTUINT8T sizeof(psbuzzButtons)));
34 if (psbuzzButtons.
val != oldButtonState.
val) {
35 buttonClickState.
val = psbuzzButtons.
val & ~oldButtonState.
val;
36 oldButtonState.
val = psbuzzButtons.
val;
52 int8_t PSBuzz::getButtonIndexBuzz(
ButtonEnum b) {
54 if (index > 4)
return -1;
59 const int8_t index = getButtonIndexBuzz(b);
if (index < 0)
return 0;
60 return psbuzzButtons.
val & (1UL << (index + 5 * controller));
64 const int8_t index = getButtonIndexBuzz(b);
if (index < 0)
return 0;
65 uint32_t mask = (1UL << (index + 5 * controller));
66 bool click = buttonClickState.
val & mask;
67 buttonClickState.
val &= ~mask;
73 ledState[controller] = value;
77 buf[1] = ledState[0] ? 0xFF : 0x00;
78 buf[2] = ledState[1] ? 0xFF : 0x00;
79 buf[3] = ledState[2] ? 0xFF : 0x00;
80 buf[4] = ledState[3] ? 0xFF : 0x00;
84 PSBuzz_Command(buf,
sizeof(buf));
87 void PSBuzz::PSBuzz_Command(uint8_t *data, uint16_t nbytes) {
89 pUsb->
ctrlReq(
bAddress,
epInfo[0].epAddr,
bmREQ_HID_OUT,
HID_REQUEST_SET_REPORT, 0x00, 0x02, 0x00, nbytes, nbytes, data, NULL);
EpInfo epInfo[totalEndpoints]
bool getButtonPress(ButtonEnum b, uint8_t controller=0)
void ParseHIDData(USBHID *hid, bool is_rpt_id, uint8_t len, uint8_t *buf)
bool getButtonClick(ButtonEnum b, uint8_t controller=0)
uint8_t OnInitSuccessful()
void setLedRaw(bool value, uint8_t controller=0)
uint8_t ctrlReq(uint8_t addr, uint8_t ep, uint8_t bmReqType, uint8_t bRequest, uint8_t wValLo, uint8_t wValHi, uint16_t wInd, uint16_t total, uint16_t nbytes, uint8_t *dataptr, USBReadParser *p)
constexpr int8_t ButtonIndex(ButtonEnum key)
#define HID_REQUEST_SET_REPORT