code clean up and added comments

This commit is contained in:
2025-05-30 09:17:55 -04:00
parent 5184d5c744
commit 94ea767285
8 changed files with 104 additions and 93 deletions
+5 -8
View File
@@ -9,6 +9,8 @@ uint8_t parse_mod(char * key);
typedef struct { char * key; uint8_t val; } keycode_dict;
// modifier key bit codes
#define KEY_MOD_LCTRL 0x01
#define KEY_MOD_LSHIFT 0x02
#define KEY_MOD_LALT 0x04
@@ -18,14 +20,7 @@ typedef struct { char * key; uint8_t val; } keycode_dict;
#define KEY_MOD_RALT 0x40
#define KEY_MOD_RMETA 0x80
/**
* Scan codes - last N slots in the HID report (usually 6).
* 0x00 if no key pressed.
*
* If more than N keys are pressed, the HID reports
* KEY_ERR_OVF in all slots to indicate this condition.
*/
// list of USB scan codes for individual keys
#define KEY_NONE 0x00 // No key pressed
#define KEY_ERR_OVF 0x01 // Keyboard Error Roll Over - used for all slots if too many keys are pressed ("Phantom key")
// 0x02 // Keyboard POST Fail
@@ -277,6 +272,7 @@ typedef struct { char * key; uint8_t val; } keycode_dict;
#define KEY_MEDIA_REFRESH 0xfa
#define KEY_MEDIA_CALC 0xfb
// dictionary converting Javascript key code strings to USB scan codes
static keycode_dict keytable[] = {
{"KeyA", KEY_A},
{"KeyB", KEY_B},
@@ -376,6 +372,7 @@ static keycode_dict keytable[] = {
{"WakeUp", KEY_POWER}
};
// dictionary for Javascript key code strings to USB keyboard modifier bits
static keycode_dict modtable[] = {
{"ControlLeft", KEY_MOD_LCTRL},
{"ShiftLeft", KEY_MOD_LSHIFT},