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;
53 return psbuzzButtons.
val & (1UL << (b + 5 * controller));
57 uint32_t mask = (1UL << (b + 5 * controller));
58 bool click = buttonClickState.
val & mask;
59 buttonClickState.
val &= ~mask;
65 ledState[controller] = value;
69 buf[1] = ledState[0] ? 0xFF : 0x00;
70 buf[2] = ledState[1] ? 0xFF : 0x00;
71 buf[3] = ledState[2] ? 0xFF : 0x00;
72 buf[4] = ledState[3] ? 0xFF : 0x00;
76 PSBuzz_Command(buf,
sizeof(buf));
79 void PSBuzz::PSBuzz_Command(uint8_t *data, uint16_t nbytes) {
81 pUsb->
ctrlReq(
bAddress,
epInfo[0].epAddr,
bmREQ_HID_OUT,
HID_REQUEST_SET_REPORT, 0x00, 0x02, 0x00, nbytes, nbytes, data, NULL);
void ParseHIDData(USBHID *hid, bool is_rpt_id, uint8_t len, uint8_t *buf)
bool getButtonClick(ButtonEnum b, 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)
bool getButtonPress(ButtonEnum b, uint8_t controller=0)
void setLedRaw(bool value, uint8_t controller=0)
uint8_t OnInitSuccessful()
#define HID_REQUEST_SET_REPORT
EpInfo epInfo[totalEndpoints]