From df05338583f88bd2c859a0c0449cb666c497059b Mon Sep 17 00:00:00 2001 From: Epipeppy <54874325+Epipeppy@users.noreply.github.com> Date: Wed, 10 May 2023 12:49:25 -0600 Subject: [PATCH] Update USBKeyboard.h Goes along with my changes to USBKeyboard.cpp. Added function prototypes and descriptions. Added a persistent array of keys which allow the user to send multiple keys (up to 10) in one report. --- libraries/USBHID/src/USBKeyboard.h | 44 ++++++++++++++++++++++-------- 1 file changed, 32 insertions(+), 12 deletions(-) diff --git a/libraries/USBHID/src/USBKeyboard.h b/libraries/USBHID/src/USBKeyboard.h index e9b3a401f..ddc2e50ad 100644 --- a/libraries/USBHID/src/USBKeyboard.h +++ b/libraries/USBHID/src/USBKeyboard.h @@ -60,18 +60,6 @@ enum FUNCTION_KEY { KEY_F10, /* F10 key */ KEY_F11, /* F11 key */ KEY_F12, /* F12 key */ - KEY_F13, /* F13 key */ - KEY_F14, /* F14 key */ - KEY_F15, /* F15 key */ - KEY_F16, /* F16 key */ - KEY_F17, /* F17 key */ - KEY_F18, /* F18 key */ - KEY_F19, /* F19 key */ - KEY_F20, /* F20 key */ - KEY_F21, /* F21 key */ - KEY_F22, /* F22 key */ - KEY_F23, /* F23 key */ - KEY_F24, /* F24 key */ KEY_PRINT_SCREEN, /* Print Screen key */ KEY_SCROLL_LOCK, /* Scroll lock */ @@ -188,6 +176,37 @@ class USBKeyboard: public USBHID, public ::mbed::Stream { */ virtual int _putc(int c); + /** + * Clear the persistent list of keys pressed. + * Currently has a limit of 10 keys. + */ + void emptyButtonBuffer(); + + /** + * Add a button to the persistent list of keys pressed. + * Currently has a limit of 10 keys. + * + * @param c character to be added to the list. + */ + void press_button(uint8_t c); + + /** + * Send a report with all the pressed keys, then release them. + * Currently has a limit of 10 keys. + * + * @returns true if there is no error, false otherwise + */ + bool sendReleaseAll(); + + /** + * Send a report with the keys in the array, then release them. + * Currently has a limit of 10 keys. + * + * @param keys_array Array containing the keys you want to send. + * @returns true if there is no error, false otherwise + */ + bool sendReleaseKeys(uint8_t* keys_array); + /** * Control media keys * @@ -231,6 +250,7 @@ class USBKeyboard: public USBHID, public ::mbed::Stream { //dummy otherwise it doesn't compile (we must define all methods of an abstract class) virtual int _getc(); + uint8_t _keys_pressed[10]; uint8_t _configuration_descriptor[41]; uint8_t _lock_status; PlatformMutex _mutex;