USB device stack that isn't working
Fork of USBDevice by
Diff: USBHID/USBKeyboard.cpp
- Revision:
- 72:330159d8553d
- Parent:
- 70:2c525a50f1b6
- Child:
- 73:6fb59df5258d
--- a/USBHID/USBKeyboard.cpp Thu Jul 27 12:14:04 2017 +0100 +++ b/USBHID/USBKeyboard.cpp Fri Jan 12 19:11:17 2018 +0000 @@ -442,10 +442,10 @@ return keyCode(c, keymap[c].modifier); } + bool USBKeyboard::keyCode(uint8_t key, uint8_t modifier) { - // Send a simulated keyboard keypress. Returns true if successful. HID_REPORT report; - + report.data[0] = REPORT_ID_KEYBOARD; report.data[1] = modifier; report.data[2] = 0; @@ -455,23 +455,51 @@ report.data[6] = 0; report.data[7] = 0; report.data[8] = 0; - + report.length = 9; - + if (!send(&report)) { return false; } - + report.data[1] = 0; report.data[3] = 0; + + return send(&report); +} - if (!send(&report)) { - return false; - } +bool USBKeyboard::keyPress(uint8_t key, uint8_t modifier) { + HID_REPORT report; + + report.data[0] = REPORT_ID_KEYBOARD; + report.data[1] = modifier; + report.data[2] = 0; + report.data[3] = keymap[key].usage; + report.data[4] = 0; + report.data[5] = 0; + report.data[6] = 0; + report.data[7] = 0; + report.data[8] = 0; + + return send(&report); +} - return true; +bool USBKeyboard::keyRelease() { + HID_REPORT report; + + report.data[0] = REPORT_ID_KEYBOARD; + report.data[1] = 0; + report.data[2] = 0; + report.data[3] = 0; + report.data[4] = 0; + report.data[5] = 0; + report.data[6] = 0; + report.data[7] = 0; + report.data[8] = 0; + + return send(&report); +} -} bool USBKeyboard::mediaControl(MEDIA_KEY key) {