2015-04-09 12:32:04 -04:00
|
|
|
#include "parser.h"
|
|
|
|
|
#include "usb_hid.h"
|
|
|
|
|
|
2019-09-18 02:29:38 -04:00
|
|
|
#include "print.h"
|
2015-04-09 12:32:04 -04:00
|
|
|
|
|
|
|
|
|
2018-10-30 02:50:51 -04:00
|
|
|
void KBDReportParser::Parse(USBHID *hid, bool is_rpt_id, uint8_t len, uint8_t *buf)
|
2015-04-09 12:32:04 -04:00
|
|
|
{
|
2019-09-18 02:29:38 -04:00
|
|
|
xprintf("input %d:", hid->GetAddress());
|
2018-07-13 22:55:58 -04:00
|
|
|
for (uint8_t i = 0; i < len; i++) {
|
2019-09-18 02:29:38 -04:00
|
|
|
xprintf(" %02X", buf[i]);
|
2015-07-15 03:02:20 -04:00
|
|
|
}
|
2019-09-18 02:29:38 -04:00
|
|
|
xprintf("\r\n");
|
2018-07-13 22:55:58 -04:00
|
|
|
|
2019-05-09 21:37:19 -04:00
|
|
|
// Rollover error
|
|
|
|
|
// Cherry: 0101010101010101
|
2018-07-13 22:55:58 -04:00
|
|
|
// https://geekhack.org/index.php?topic=69169.msg2638223#msg2638223
|
2019-05-09 21:37:19 -04:00
|
|
|
// Apple: 0000010101010101
|
|
|
|
|
// https://geekhack.org/index.php?topic=69169.msg2760969#msg2760969
|
|
|
|
|
if (buf[2] == 0x01) {
|
2019-09-18 02:29:38 -04:00
|
|
|
xprintf("Rollover error: ignored\r\n");
|
2018-07-13 22:55:58 -04:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
::memcpy(&report, buf, sizeof(report_keyboard_t));
|
|
|
|
|
time_stamp = millis();
|
2015-04-09 12:32:04 -04:00
|
|
|
}
|