USB Device for NUCLEO-F103RB, STM32F103C8T6 and Maple Mini boards
Dependents: MapleMini_USBSerial STM32F103C8T6_USBKeyboard firstDelta STM32F103C8T6_USBSerial ... more
Fork of L152RE_USBDevice by
Revision 70:a6dcac43ceaf, committed 2020-03-16
- Comitter:
- hudakz
- Date:
- Mon Mar 16 15:03:30 2020 +0000
- Parent:
- 69:faedf6c65e43
- Commit message:
- USBDevice support for STM32F103 chips when building with Mbed OS 2 - Added key release flag.
Changed in this revision
USBHID/USBKeyboard.cpp | Show annotated file Show diff for this revision Revisions of this file |
USBHID/USBKeyboard.h | Show annotated file Show diff for this revision Revisions of this file |
diff -r faedf6c65e43 -r a6dcac43ceaf USBHID/USBKeyboard.cpp --- a/USBHID/USBKeyboard.cpp Wed Feb 20 12:41:13 2019 +0000 +++ b/USBHID/USBKeyboard.cpp Mon Mar 16 15:03:30 2020 +0000 @@ -442,7 +442,7 @@ return keyCode(c, keymap[c].modifier); } -bool USBKeyboard::keyCode(uint8_t key, uint8_t modifier) { +bool USBKeyboard::keyCode(uint8_t key, uint8_t modifier /* = 0 */, bool release /* = true */) { // Send a simulated keyboard keypress. Returns true if successful. HID_REPORT report; @@ -462,18 +462,18 @@ return false; } - report.data[1] = 0; - report.data[3] = 0; + if (release) { + report.data[1] = 0; + report.data[3] = 0; - if (!send(&report)) { - return false; + if (!send(&report)) { + return false; + } } return true; - } - bool USBKeyboard::mediaControl(MEDIA_KEY key) { HID_REPORT report;
diff -r faedf6c65e43 -r a6dcac43ceaf USBHID/USBKeyboard.h --- a/USBHID/USBKeyboard.h Wed Feb 20 12:41:13 2019 +0000 +++ b/USBHID/USBKeyboard.h Mon Mar 16 15:03:30 2020 +0000 @@ -118,9 +118,11 @@ * * @param modifier bit 0: KEY_CTRL, bit 1: KEY_SHIFT, bit 2: KEY_ALT (default: 0) * @param key character to send + * @param holdDown true when the key shall be released in this function + * false when the key shall be released in the application program * @returns true if there is no error, false otherwise */ - bool keyCode(uint8_t key, uint8_t modifier = 0); + bool keyCode(uint8_t key, uint8_t modifier = 0, bool release = true); /** * Send a character