Skip to content

Commit df05338

Browse files
authored
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.
1 parent fb8531f commit df05338

File tree

1 file changed

+32
-12
lines changed

1 file changed

+32
-12
lines changed

libraries/USBHID/src/USBKeyboard.h

Lines changed: 32 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -60,18 +60,6 @@ enum FUNCTION_KEY {
6060
KEY_F10, /* F10 key */
6161
KEY_F11, /* F11 key */
6262
KEY_F12, /* F12 key */
63-
KEY_F13, /* F13 key */
64-
KEY_F14, /* F14 key */
65-
KEY_F15, /* F15 key */
66-
KEY_F16, /* F16 key */
67-
KEY_F17, /* F17 key */
68-
KEY_F18, /* F18 key */
69-
KEY_F19, /* F19 key */
70-
KEY_F20, /* F20 key */
71-
KEY_F21, /* F21 key */
72-
KEY_F22, /* F22 key */
73-
KEY_F23, /* F23 key */
74-
KEY_F24, /* F24 key */
7563

7664
KEY_PRINT_SCREEN, /* Print Screen key */
7765
KEY_SCROLL_LOCK, /* Scroll lock */
@@ -188,6 +176,37 @@ class USBKeyboard: public USBHID, public ::mbed::Stream {
188176
*/
189177
virtual int _putc(int c);
190178

179+
/**
180+
* Clear the persistent list of keys pressed.
181+
* Currently has a limit of 10 keys.
182+
*/
183+
void emptyButtonBuffer();
184+
185+
/**
186+
* Add a button to the persistent list of keys pressed.
187+
* Currently has a limit of 10 keys.
188+
*
189+
* @param c character to be added to the list.
190+
*/
191+
void press_button(uint8_t c);
192+
193+
/**
194+
* Send a report with all the pressed keys, then release them.
195+
* Currently has a limit of 10 keys.
196+
*
197+
* @returns true if there is no error, false otherwise
198+
*/
199+
bool sendReleaseAll();
200+
201+
/**
202+
* Send a report with the keys in the array, then release them.
203+
* Currently has a limit of 10 keys.
204+
*
205+
* @param keys_array Array containing the keys you want to send.
206+
* @returns true if there is no error, false otherwise
207+
*/
208+
bool sendReleaseKeys(uint8_t* keys_array);
209+
191210
/**
192211
* Control media keys
193212
*
@@ -231,6 +250,7 @@ class USBKeyboard: public USBHID, public ::mbed::Stream {
231250
//dummy otherwise it doesn't compile (we must define all methods of an abstract class)
232251
virtual int _getc();
233252

253+
uint8_t _keys_pressed[10];
234254
uint8_t _configuration_descriptor[41];
235255
uint8_t _lock_status;
236256
PlatformMutex _mutex;

0 commit comments

Comments
 (0)