Keyboard firmwares for Atmel AVR and Cortex-M
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

parser.cpp 829B

123456789101112131415161718192021222324252627282930313233
  1. #include "parser.h"
  2. #include "usb_hid.h"
  3. #include "debug.h"
  4. report_keyboard_t usb_hid_keyboard_report;
  5. uint16_t usb_hid_time_stamp;
  6. void KBDReportParser::Parse(HID *hid, bool is_rpt_id, uint8_t len, uint8_t *buf)
  7. {
  8. bool is_error = false;
  9. report_keyboard_t *report = (report_keyboard_t *)buf;
  10. dprintf("keyboard input: %02X %02X", report->mods, report->reserved);
  11. for (uint8_t i = 0; i < KEYBOARD_REPORT_KEYS; i++) {
  12. if (IS_ERROR(report->keys[i])) {
  13. is_error = true;
  14. }
  15. dprintf(" %02X", report->keys[i]);
  16. }
  17. dprint("\r\n");
  18. // ignore error and not send report to computer
  19. if (is_error) {
  20. dprint("Error usage! \r\n");
  21. return;
  22. }
  23. ::memcpy(&usb_hid_keyboard_report, buf, sizeof(report_keyboard_t));
  24. usb_hid_time_stamp = millis();
  25. }