]> git.donarmstrong.com Git - qmk_firmware.git/blob - tmk_core/protocol/usb_hid/parser.cpp
Remove Let’s Split plate files
[qmk_firmware.git] / tmk_core / 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("KBDReport: %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 }