]> git.gir.st - tmk_keyboard.git/blob - protocol/usb_hid/parser.cpp
Squashed 'tmk_core/' changes from 57d27a8..08ce4c3
[tmk_keyboard.git] / protocol / usb_hid / parser.cpp
1 #include "parser.h"
2 #include "usb_hid.h"
3
4 #include "debug.h"
5
6
7 report_keyboard_t usb_hid_keyboard_report;
8 uint16_t usb_hid_time_stamp;
9
10
11 void KBDReportParser::Parse(HID *hid, bool is_rpt_id, uint8_t len, uint8_t *buf)
12 {
13 bool is_error = false;
14 report_keyboard_t *report = (report_keyboard_t *)buf;
15
16 dprintf("keyboard input: %02X %02X", report->mods, report->reserved);
17 for (uint8_t i = 0; i < KEYBOARD_REPORT_KEYS; i++) {
18 if (IS_ERROR(report->keys[i])) {
19 is_error = true;
20 }
21 dprintf(" %02X", report->keys[i]);
22 }
23 dprint("\r\n");
24
25 // ignore error and not send report to computer
26 if (is_error) {
27 dprint("Error usage! \r\n");
28 return;
29 }
30
31 ::memcpy(&usb_hid_keyboard_report, buf, sizeof(report_keyboard_t));
32 usb_hid_time_stamp = millis();
33 }
Imprint / Impressum