-
-
Save MightyPork/6da26e382a7ad91b5496ee55fdc73db2 to your computer and use it in GitHub Desktop.
/** | |
* USB HID Keyboard scan codes as per USB spec 1.11 | |
* plus some additional codes | |
* | |
* Created by MightyPork, 2016 | |
* Public domain | |
* | |
* Adapted from: | |
* https://source.android.com/devices/input/keyboard-devices.html | |
*/ | |
#ifndef USB_HID_KEYS | |
#define USB_HID_KEYS | |
/** | |
* Modifier masks - used for the first byte in the HID report. | |
* NOTE: The second byte in the report is reserved, 0x00 | |
*/ | |
#define KEY_MOD_LCTRL 0x01 | |
#define KEY_MOD_LSHIFT 0x02 | |
#define KEY_MOD_LALT 0x04 | |
#define KEY_MOD_LMETA 0x08 | |
#define KEY_MOD_RCTRL 0x10 | |
#define KEY_MOD_RSHIFT 0x20 | |
#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. | |
*/ | |
#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 | |
// 0x03 // Keyboard Error Undefined | |
#define KEY_A 0x04 // Keyboard a and A | |
#define KEY_B 0x05 // Keyboard b and B | |
#define KEY_C 0x06 // Keyboard c and C | |
#define KEY_D 0x07 // Keyboard d and D | |
#define KEY_E 0x08 // Keyboard e and E | |
#define KEY_F 0x09 // Keyboard f and F | |
#define KEY_G 0x0a // Keyboard g and G | |
#define KEY_H 0x0b // Keyboard h and H | |
#define KEY_I 0x0c // Keyboard i and I | |
#define KEY_J 0x0d // Keyboard j and J | |
#define KEY_K 0x0e // Keyboard k and K | |
#define KEY_L 0x0f // Keyboard l and L | |
#define KEY_M 0x10 // Keyboard m and M | |
#define KEY_N 0x11 // Keyboard n and N | |
#define KEY_O 0x12 // Keyboard o and O | |
#define KEY_P 0x13 // Keyboard p and P | |
#define KEY_Q 0x14 // Keyboard q and Q | |
#define KEY_R 0x15 // Keyboard r and R | |
#define KEY_S 0x16 // Keyboard s and S | |
#define KEY_T 0x17 // Keyboard t and T | |
#define KEY_U 0x18 // Keyboard u and U | |
#define KEY_V 0x19 // Keyboard v and V | |
#define KEY_W 0x1a // Keyboard w and W | |
#define KEY_X 0x1b // Keyboard x and X | |
#define KEY_Y 0x1c // Keyboard y and Y | |
#define KEY_Z 0x1d // Keyboard z and Z | |
#define KEY_1 0x1e // Keyboard 1 and ! | |
#define KEY_2 0x1f // Keyboard 2 and @ | |
#define KEY_3 0x20 // Keyboard 3 and # | |
#define KEY_4 0x21 // Keyboard 4 and $ | |
#define KEY_5 0x22 // Keyboard 5 and % | |
#define KEY_6 0x23 // Keyboard 6 and ^ | |
#define KEY_7 0x24 // Keyboard 7 and & | |
#define KEY_8 0x25 // Keyboard 8 and * | |
#define KEY_9 0x26 // Keyboard 9 and ( | |
#define KEY_0 0x27 // Keyboard 0 and ) | |
#define KEY_ENTER 0x28 // Keyboard Return (ENTER) | |
#define KEY_ESC 0x29 // Keyboard ESCAPE | |
#define KEY_BACKSPACE 0x2a // Keyboard DELETE (Backspace) | |
#define KEY_TAB 0x2b // Keyboard Tab | |
#define KEY_SPACE 0x2c // Keyboard Spacebar | |
#define KEY_MINUS 0x2d // Keyboard - and _ | |
#define KEY_EQUAL 0x2e // Keyboard = and + | |
#define KEY_LEFTBRACE 0x2f // Keyboard [ and { | |
#define KEY_RIGHTBRACE 0x30 // Keyboard ] and } | |
#define KEY_BACKSLASH 0x31 // Keyboard \ and | | |
#define KEY_HASHTILDE 0x32 // Keyboard Non-US # and ~ | |
#define KEY_SEMICOLON 0x33 // Keyboard ; and : | |
#define KEY_APOSTROPHE 0x34 // Keyboard ' and " | |
#define KEY_GRAVE 0x35 // Keyboard ` and ~ | |
#define KEY_COMMA 0x36 // Keyboard , and < | |
#define KEY_DOT 0x37 // Keyboard . and > | |
#define KEY_SLASH 0x38 // Keyboard / and ? | |
#define KEY_CAPSLOCK 0x39 // Keyboard Caps Lock | |
#define KEY_F1 0x3a // Keyboard F1 | |
#define KEY_F2 0x3b // Keyboard F2 | |
#define KEY_F3 0x3c // Keyboard F3 | |
#define KEY_F4 0x3d // Keyboard F4 | |
#define KEY_F5 0x3e // Keyboard F5 | |
#define KEY_F6 0x3f // Keyboard F6 | |
#define KEY_F7 0x40 // Keyboard F7 | |
#define KEY_F8 0x41 // Keyboard F8 | |
#define KEY_F9 0x42 // Keyboard F9 | |
#define KEY_F10 0x43 // Keyboard F10 | |
#define KEY_F11 0x44 // Keyboard F11 | |
#define KEY_F12 0x45 // Keyboard F12 | |
#define KEY_SYSRQ 0x46 // Keyboard Print Screen | |
#define KEY_SCROLLLOCK 0x47 // Keyboard Scroll Lock | |
#define KEY_PAUSE 0x48 // Keyboard Pause | |
#define KEY_INSERT 0x49 // Keyboard Insert | |
#define KEY_HOME 0x4a // Keyboard Home | |
#define KEY_PAGEUP 0x4b // Keyboard Page Up | |
#define KEY_DELETE 0x4c // Keyboard Delete Forward | |
#define KEY_END 0x4d // Keyboard End | |
#define KEY_PAGEDOWN 0x4e // Keyboard Page Down | |
#define KEY_RIGHT 0x4f // Keyboard Right Arrow | |
#define KEY_LEFT 0x50 // Keyboard Left Arrow | |
#define KEY_DOWN 0x51 // Keyboard Down Arrow | |
#define KEY_UP 0x52 // Keyboard Up Arrow | |
#define KEY_NUMLOCK 0x53 // Keyboard Num Lock and Clear | |
#define KEY_KPSLASH 0x54 // Keypad / | |
#define KEY_KPASTERISK 0x55 // Keypad * | |
#define KEY_KPMINUS 0x56 // Keypad - | |
#define KEY_KPPLUS 0x57 // Keypad + | |
#define KEY_KPENTER 0x58 // Keypad ENTER | |
#define KEY_KP1 0x59 // Keypad 1 and End | |
#define KEY_KP2 0x5a // Keypad 2 and Down Arrow | |
#define KEY_KP3 0x5b // Keypad 3 and PageDn | |
#define KEY_KP4 0x5c // Keypad 4 and Left Arrow | |
#define KEY_KP5 0x5d // Keypad 5 | |
#define KEY_KP6 0x5e // Keypad 6 and Right Arrow | |
#define KEY_KP7 0x5f // Keypad 7 and Home | |
#define KEY_KP8 0x60 // Keypad 8 and Up Arrow | |
#define KEY_KP9 0x61 // Keypad 9 and Page Up | |
#define KEY_KP0 0x62 // Keypad 0 and Insert | |
#define KEY_KPDOT 0x63 // Keypad . and Delete | |
#define KEY_102ND 0x64 // Keyboard Non-US \ and | | |
#define KEY_COMPOSE 0x65 // Keyboard Application | |
#define KEY_POWER 0x66 // Keyboard Power | |
#define KEY_KPEQUAL 0x67 // Keypad = | |
#define KEY_F13 0x68 // Keyboard F13 | |
#define KEY_F14 0x69 // Keyboard F14 | |
#define KEY_F15 0x6a // Keyboard F15 | |
#define KEY_F16 0x6b // Keyboard F16 | |
#define KEY_F17 0x6c // Keyboard F17 | |
#define KEY_F18 0x6d // Keyboard F18 | |
#define KEY_F19 0x6e // Keyboard F19 | |
#define KEY_F20 0x6f // Keyboard F20 | |
#define KEY_F21 0x70 // Keyboard F21 | |
#define KEY_F22 0x71 // Keyboard F22 | |
#define KEY_F23 0x72 // Keyboard F23 | |
#define KEY_F24 0x73 // Keyboard F24 | |
#define KEY_OPEN 0x74 // Keyboard Execute | |
#define KEY_HELP 0x75 // Keyboard Help | |
#define KEY_PROPS 0x76 // Keyboard Menu | |
#define KEY_FRONT 0x77 // Keyboard Select | |
#define KEY_STOP 0x78 // Keyboard Stop | |
#define KEY_AGAIN 0x79 // Keyboard Again | |
#define KEY_UNDO 0x7a // Keyboard Undo | |
#define KEY_CUT 0x7b // Keyboard Cut | |
#define KEY_COPY 0x7c // Keyboard Copy | |
#define KEY_PASTE 0x7d // Keyboard Paste | |
#define KEY_FIND 0x7e // Keyboard Find | |
#define KEY_MUTE 0x7f // Keyboard Mute | |
#define KEY_VOLUMEUP 0x80 // Keyboard Volume Up | |
#define KEY_VOLUMEDOWN 0x81 // Keyboard Volume Down | |
// 0x82 Keyboard Locking Caps Lock | |
// 0x83 Keyboard Locking Num Lock | |
// 0x84 Keyboard Locking Scroll Lock | |
#define KEY_KPCOMMA 0x85 // Keypad Comma | |
// 0x86 Keypad Equal Sign | |
#define KEY_RO 0x87 // Keyboard International1 | |
#define KEY_KATAKANAHIRAGANA 0x88 // Keyboard International2 | |
#define KEY_YEN 0x89 // Keyboard International3 | |
#define KEY_HENKAN 0x8a // Keyboard International4 | |
#define KEY_MUHENKAN 0x8b // Keyboard International5 | |
#define KEY_KPJPCOMMA 0x8c // Keyboard International6 | |
// 0x8d Keyboard International7 | |
// 0x8e Keyboard International8 | |
// 0x8f Keyboard International9 | |
#define KEY_HANGEUL 0x90 // Keyboard LANG1 | |
#define KEY_HANJA 0x91 // Keyboard LANG2 | |
#define KEY_KATAKANA 0x92 // Keyboard LANG3 | |
#define KEY_HIRAGANA 0x93 // Keyboard LANG4 | |
#define KEY_ZENKAKUHANKAKU 0x94 // Keyboard LANG5 | |
// 0x95 Keyboard LANG6 | |
// 0x96 Keyboard LANG7 | |
// 0x97 Keyboard LANG8 | |
// 0x98 Keyboard LANG9 | |
// 0x99 Keyboard Alternate Erase | |
// 0x9a Keyboard SysReq/Attention | |
// 0x9b Keyboard Cancel | |
// 0x9c Keyboard Clear | |
// 0x9d Keyboard Prior | |
// 0x9e Keyboard Return | |
// 0x9f Keyboard Separator | |
// 0xa0 Keyboard Out | |
// 0xa1 Keyboard Oper | |
// 0xa2 Keyboard Clear/Again | |
// 0xa3 Keyboard CrSel/Props | |
// 0xa4 Keyboard ExSel | |
// 0xb0 Keypad 00 | |
// 0xb1 Keypad 000 | |
// 0xb2 Thousands Separator | |
// 0xb3 Decimal Separator | |
// 0xb4 Currency Unit | |
// 0xb5 Currency Sub-unit | |
#define KEY_KPLEFTPAREN 0xb6 // Keypad ( | |
#define KEY_KPRIGHTPAREN 0xb7 // Keypad ) | |
// 0xb8 Keypad { | |
// 0xb9 Keypad } | |
// 0xba Keypad Tab | |
// 0xbb Keypad Backspace | |
// 0xbc Keypad A | |
// 0xbd Keypad B | |
// 0xbe Keypad C | |
// 0xbf Keypad D | |
// 0xc0 Keypad E | |
// 0xc1 Keypad F | |
// 0xc2 Keypad XOR | |
// 0xc3 Keypad ^ | |
// 0xc4 Keypad % | |
// 0xc5 Keypad < | |
// 0xc6 Keypad > | |
// 0xc7 Keypad & | |
// 0xc8 Keypad && | |
// 0xc9 Keypad | | |
// 0xca Keypad || | |
// 0xcb Keypad : | |
// 0xcc Keypad # | |
// 0xcd Keypad Space | |
// 0xce Keypad @ | |
// 0xcf Keypad ! | |
// 0xd0 Keypad Memory Store | |
// 0xd1 Keypad Memory Recall | |
// 0xd2 Keypad Memory Clear | |
// 0xd3 Keypad Memory Add | |
// 0xd4 Keypad Memory Subtract | |
// 0xd5 Keypad Memory Multiply | |
// 0xd6 Keypad Memory Divide | |
// 0xd7 Keypad +/- | |
// 0xd8 Keypad Clear | |
// 0xd9 Keypad Clear Entry | |
// 0xda Keypad Binary | |
// 0xdb Keypad Octal | |
// 0xdc Keypad Decimal | |
// 0xdd Keypad Hexadecimal | |
#define KEY_LEFTCTRL 0xe0 // Keyboard Left Control | |
#define KEY_LEFTSHIFT 0xe1 // Keyboard Left Shift | |
#define KEY_LEFTALT 0xe2 // Keyboard Left Alt | |
#define KEY_LEFTMETA 0xe3 // Keyboard Left GUI | |
#define KEY_RIGHTCTRL 0xe4 // Keyboard Right Control | |
#define KEY_RIGHTSHIFT 0xe5 // Keyboard Right Shift | |
#define KEY_RIGHTALT 0xe6 // Keyboard Right Alt | |
#define KEY_RIGHTMETA 0xe7 // Keyboard Right GUI | |
#define KEY_MEDIA_PLAYPAUSE 0xe8 | |
#define KEY_MEDIA_STOPCD 0xe9 | |
#define KEY_MEDIA_PREVIOUSSONG 0xea | |
#define KEY_MEDIA_NEXTSONG 0xeb | |
#define KEY_MEDIA_EJECTCD 0xec | |
#define KEY_MEDIA_VOLUMEUP 0xed | |
#define KEY_MEDIA_VOLUMEDOWN 0xee | |
#define KEY_MEDIA_MUTE 0xef | |
#define KEY_MEDIA_WWW 0xf0 | |
#define KEY_MEDIA_BACK 0xf1 | |
#define KEY_MEDIA_FORWARD 0xf2 | |
#define KEY_MEDIA_STOP 0xf3 | |
#define KEY_MEDIA_FIND 0xf4 | |
#define KEY_MEDIA_SCROLLUP 0xf5 | |
#define KEY_MEDIA_SCROLLDOWN 0xf6 | |
#define KEY_MEDIA_EDIT 0xf7 | |
#define KEY_MEDIA_SLEEP 0xf8 | |
#define KEY_MEDIA_COFFEE 0xf9 | |
#define KEY_MEDIA_REFRESH 0xfa | |
#define KEY_MEDIA_CALC 0xfb | |
#endif // USB_HID_KEYS |
In my python project using such dictionaries:
key_DEC = {
"Left_Button": 1,
"Right_Button": 2,
"Break": 3,
"Middle_Button": 4,
"X_Button_1": 5,
"X_Button_2": 6,
"Backspace": 8,
"Tab": 9,
"Clear": 12,
"Enter": 13,
"Shift": 16,
"Ctrl": 17,
"Alt": 18,
"Pause": 19,
"Caps_Lock": 20,
"Kana": 21,
"Junja": 23,
"Final": 24,
"Kanji": 25,
"Esc": 27,
"Convert": 28,
"Non_Convert": 29,
"Accept": 30,
"Mode_Change": 31,
"Space": 32,
"Page_Up": 33,
"Page_Down": 34,
"End": 35,
"Home": 36,
"Arrow_Left": 37,
"Arrow_Up": 38,
"Arrow_Right": 39,
"Arrow_Down": 40,
"Select": 41,
"Print": 42,
"Execute": 43,
"Print_Screen": 44,
"Insert": 45,
"Delete": 46,
"Help": 47,
"0": 48,
"1": 49,
"2": 50,
"3": 51,
"4": 52,
"5": 53,
"6": 54,
"7": 55,
"8": 56,
"9": 57,
"A": 65,
"B": 66,
"C": 67,
"D": 68,
"E": 69,
"F": 70,
"G": 71,
"H": 72,
"I": 73,
"J": 74,
"K": 75,
"L": 76,
"M": 77,
"N": 78,
"O": 79,
"P": 80,
"Q": 81,
"R": 82,
"S": 83,
"T": 83,
"U": 85,
"V": 86,
"W": 87,
"X": 88,
"Y": 89,
"Z": 90,
"Left_Win": 91,
"Right_Win": 92,
"Context_Menu": 93,
"Sleep": 95,
"Numpad_0": 96,
"Numpad_1": 97,
"Numpad_2": 98,
"Numpad_3": 99,
"Numpad_4": 100,
"Numpad_5": 101,
"Numpad_6": 102,
"Numpad_7": 103,
"Numpad_8": 104,
"Numpad_9": 105,
"Numpad_*": 106,
"Numpad_+": 107,
"Separator": 108,
"Num_-": 109,
"Numpad_.": 110,
"Numpad_/": 111,
"F1": 112,
"F2": 113,
"F3": 114,
"F4": 115,
"F5": 116,
"F6": 117,
"F7": 118,
"F8": 119,
"F9": 120,
"F10": 121,
"F11": 122,
"F12": 123,
"F13": 124,
"F14": 125,
"F15": 126,
"F16": 127,
"F17": 128,
"F18": 129,
"F19": 130,
"F20": 131,
"F21": 132,
"F22": 133,
"F23": 134,
"F24": 135,
"Num_Lock": 144,
"Scrol_Lock": 145,
"Jisho": 146,
"Mashu": 147,
"Touroku": 148,
"Loya": 149,
"Roya": 150,
"Left_Shift": 160,
"Right_Shift": 161,
"Left_Ctrl": 162,
"Right_Ctrl": 163,
"Left_Alt": 164,
"Right_Alt": 165,
"Browser_Back": 166,
"Browser_Forward": 167,
"Browser_Refresh": 168,
"Browser_Stop": 169,
"Browser_Search": 170,
"Browser_Favorites": 171,
"Browser_Home": 172,
"Volume_Mute": 173,
"Volume_Down": 174,
"Volume_Up": 175,
"Next_Track": 176,
"Previous_Track": 177,
"Stop": 178,
"Play_Pause": 179,
"Mail": 180,
"Media": 181,
"App1": 182,
"App2": 183,
";_:": 186,
"=_+": 187,
",_<": 188,
"-_-_": 189,
"._>": 190,
"/_?": 191,
"`_~": 192,
"Abnt_C1": 193,
"Abnt_C2": 193,
"[_{": 219,
"\\_|": 229,
"]_}": 221,
"\\_\"": 222,
"!_§": 223,
"Ax": 225,
">_<": 226,
"IcoHlp": 227,
"Process": 229,
"IcoClr": 230,
"Packet": 231,
"Reset": 233,
"Jump": 234,
"OemPa1": 235,
"OemPa2": 236,
"OemPa3": 237,
"WsCtrl": 238,
"CuSel": 239,
"Oem_Attn": 240,
"Finish": 241,
"Copy": 242,
"Auto": 243,
"Enlw": 244,
"Back_Tab": 245,
"Attn": 246,
"CrSel": 247,
"ExSel": 248,
"ErEof": 249,
"Play": 250,
"Zoom": 251,
"Pa1": 253,
"OemClr": 254,
}
mapping_key_DEC = {
1: "Left_Button",
2: "Right_Button",
3: "Break",
4: "Middle_Button",
5: "X_Button_1",
6: "X_Button_2",
8: "Backspace",
9: "Tab",
12: "Clear",
13: "Enter",
16: "Shift",
17: "Ctrl",
18: "Alt",
19: "Pause",
20: "Caps_Lock",
21: "Kana",
23: "Junja",
24: "Final",
25: "Kanji",
27: "Esc",
28: "Convert",
29: "Non_Convert",
30: "Accept",
31: "Mode_Change",
32: "Space",
33: "Page_Up",
34: "Page_Down",
35: "End",
36: "Home",
37: "Arrow_Left",
38: "Arrow_Up",
39: "Arrow_Right",
40: "Arrow_Down",
41: "Select",
42: "Print",
43: "Execute",
44: "Print_Screen",
45: "Insert",
46: "Delete",
47: "Help",
48: "0",
49: "1",
50: "2",
51: "3",
52: "4",
53: "5",
54: "6",
55: "7",
56: "8",
57: "9",
65: "A",
66: "B",
67: "C",
68: "D",
69: "E",
70: "F",
71: "G",
72: "H",
73: "I",
74: "J",
75: "K",
76: "L",
77: "M",
78: "N",
79: "O",
80: "P",
81: "Q",
82: "R",
83: "S",
83: "T",
85: "U",
86: "V",
87: "W",
88: "X",
89: "Y",
90: "Z",
91: "Left_Win",
92: "Right_Win",
93: "Context_Menu",
95: "Sleep",
96: "Numpad_0",
97: "Numpad_1",
98: "Numpad_2",
99: "Numpad_3",
100: "Numpad_4",
101: "Numpad_5",
102: "Numpad_6",
103: "Numpad_7",
104: "Numpad_8",
105: "Numpad_9",
106: "Numpad_*",
107: "Numpad_+",
108: "Separator",
109: "Num_-",
110: "Numpad_.",
111: "Numpad_/",
112: "F1",
113: "F2",
114: "F3",
115: "F4",
116: "F5",
117: "F6",
118: "F7",
119: "F8",
120: "F9",
121: "F10",
122: "F11",
123: "F12",
124: "F13",
125: "F14",
126: "F15",
127: "F16",
128: "F17",
129: "F18",
130: "F19",
131: "F20",
132: "F21",
133: "F22",
134: "F23",
135: "F24",
144: "Num_Lock",
145: "Scrol_Lock",
146: "Jisho",
147: "Mashu",
148: "Touroku",
149: "Loya",
150: "Roya",
160: "Left_Shift",
161: "Right_Shift",
162: "Left_Ctrl",
163: "Right_Ctrl",
164: "Left_Alt",
165: "Right_Alt",
166: "Browser_Back",
167: "Browser_Forward",
168: "Browser_Refresh",
169: "Browser_Stop",
170: "Browser_Search",
171: "Browser_Favorites",
172: "Browser_Home",
173: "Volume_Mute",
174: "Volume_Down",
175: "Volume_Up",
176: "Next_Track",
177: "Previous_Track",
178: "Stop",
179: "Play_Pause",
180: "Mail",
181: "Media",
182: "App1",
183: "App2",
186: ";_:",
187: "=_+",
188: ",_<",
189: "-_-_",
190: "._>",
191: "/_?",
192: "`_~",
193: "Abnt_C1",
193: "Abnt_C2",
219: "[_{",
229: "\\_|",
221: "]_}",
222: "\\_\"",
223: "!_§",
225: "Ax",
226: ">_<",
227: "IcoHlp",
229: "Process",
230: "IcoClr",
231: "Packet",
233: "Reset",
234: "Jump",
235: "OemPa1",
236: "OemPa2",
237: "OemPa3",
238: "WsCtrl",
239: "CuSel",
240: "Oem_Attn",
241: "Finish",
242: "Copy",
243: "Auto",
244: "Enlw",
245: "Back_Tab",
246: "Attn",
247: "CrSel",
248: "ExSel",
249: "ErEof",
250: "Play",
251: "Zoom",
253: "Pa1",
254: "OemClr",
}
key_hex_codes = {
'Left_Button': '0x01',
'Right_Button': '0x02',
'Break': '0x03',
'Middle_Button': '0x04',
'X_Button_1': '0x05',
'X_Button_2': '0x06',
'Backspace': '0x08',
'Tab': '0x09',
'Clear': '0x0C',
'Enter': '0x0D',
'Shift': '0x10',
'Ctrl': '0x11',
'Alt': '0x12',
'Pause': '0x13',
'Caps_Lock': '0x14',
'Kana': '0x15',
'Junja': '0x17',
'Final': '0x18',
'Kanji': '0x19',
'Esc': '0x1B',
'Convert': '0x1C',
'Non_Convert': '0x1D',
'Accept': '0x1E',
'Mode_Change': '0x1F',
'Space': '0x20',
'Page_Up': '0x21',
'Page_Down': '0x22',
'End': '0x23',
'Home': '0x24',
'Arrow_Left': '0x25',
'Arrow_Up': '0x26',
'Arrow_Right': '0x27',
'Arrow_Down': '0x28',
'Select': '0x29',
'Print': '0x2A',
'Execute': '0x2B',
'Print_Screen': '0x2C',
'Insert': '0x2D',
'Delete': '0x2E',
'Help': '0x2F',
'0': '0x30',
'1': '0x31',
'2': '0x32',
'3': '0x33',
'4': '0x34',
'5': '0x35',
'6': '0x36',
'7': '0x37',
'8': '0x38',
'9': '0x39',
'A': '0x41',
'B': '0x42',
'C': '0x43',
'D': '0x44',
'E': '0x45',
'F': '0x46',
'G': '0x47',
'H': '0x48',
'I': '0x49',
'J': '0x4A',
'K': '0x4B',
'L': '0x4C',
'M': '0x4D',
'N': '0x4E',
'O': '0x4F',
'P': '0x50',
'Q': '0x51',
'R': '0x52',
'S': '0x53',
'T': '0x54',
'U': '0x55',
'V': '0x56',
'W': '0x57',
'X': '0x58',
'Y': '0x59',
'Z': '0x5A',
'Left_Win': '0x5B',
'Right_Win': '0x5C',
'Context_Menu': '0x5D',
'Sleep': '0x5F',
'Numpad_0': '0x60',
'Numpad_1': '0x61',
'Numpad_2': '0x62',
'Numpad_3': '0x63',
'Numpad_4': '0x64',
'Numpad_5': '0x65',
'Numpad_6': '0x66',
'Numpad_7': '0x67',
'Numpad_8': '0x68',
'Numpad_9': '0x69',
'Numpad_*': '0x6A',
'Numpad_+': '0x6B',
'Separator': '0x6C',
'Num_-': '0x6D',
'Numpad_.': '0x6E',
'Numpad_/': '0x6F',
'F1': '0x70',
'F2': '0x71',
'F3': '0x72',
'F4': '0x73',
'F5': '0x74',
'F6': '0x75',
'F7': '0x76',
'F8': '0x77',
'F9': '0x78',
'F10': '0x79',
'F11': '0x7A',
'F12': '0x7B',
'F13': '0x7C',
'F14': '0x7D',
'F15': '0x7E',
'F16': '0x7F',
'F17': '0x80',
'F18': '0x81',
'F19': '0x82',
'F20': '0x83',
'F21': '0x84',
'F22': '0x85',
'F23': '0x86',
'F24': '0x87',
'Num_Lock': '0x90',
'Scrol_Lock': '0x91',
'Jisho': '0x92',
'Mashu': '0x93',
'Touroku': '0x94',
'Loya': '0x95',
'Roya': '0x96',
'Left_Shift': '0xA0',
'Right_Shift': '0xA1',
'Left_Ctrl': '0xA2',
'Right_Ctrl': '0xA3',
'Left_Alt': '0xA4',
'Right_Alt': '0xA5',
'Browser_Back': '0xA6',
'Browser_Forward': '0xA7',
'Browser_Refresh': '0xA8',
'Browser_Stop': '0xA9',
'Browser_Search': '0xAA',
'Browser_Favorites': '0xAB',
'Browser_Home': '0xAC',
'Volume_Mute': '0xAD',
'Volume_Down': '0xAE',
'Volume_Up': '0xAF',
'Next_Track': '0xB0',
'Previous_Track': '0xB1',
'Stop': '0xB2',
'Play_Pause': '0xB3',
'Mail': '0xB4',
'Media': '0xB5',
'App1': '0xB6',
'App2': '0xB7',
';_:': '0xBA',
'=_+': '0xBB',
',_<': '0xBC',
'-_-_': '0xBD',
'._>': '0xBE',
'/_?': '0xBF',
'`_~': '0xC0',
'Abnt_C1': '0xC1',
'Abnt_C2': '0xC2',
'[_{': '0xDB',
'\\_|': '0xDC',
']}_': '0xDD',
'\\_"': '0xDE',
'!_В§': '0xDF',
'Ax': '0xE1',
'>_<': '0xE2',
'IcoHlp': '0xE3',
'Process': '0xE5',
'IcoClr': '0xE6',
'Packet': '0xE7',
'Reset': '0xE9',
'Jump': '0xEA',
'OemPa1': '0xEB',
'OemPa2': '0xEC',
'OemPa3': '0xED',
'WsCtrl': '0xEE',
'Cu_Sel': '0xEF',
'Oem_Attn': '0xF0',
'Finish': '0xF1',
'Copy': '0xF2',
'Auto': '0xF3',
'Enlw': '0xF4',
'Back_Tab': '0xF5',
'Attn': '0xF6',
'Cr_Sel': '0xF7',
'Ex_Sel': '0xF8',
'Er_Eof': '0xF9',
'Play': '0xFA',
'Zoom': '0xFB',
'Pa1': '0xFD',
'OemClr': '0xFE'
}
hex_key_mapping = {
'0x01': 'Left_Button',
'0x02': 'Right_Button',
'0x03': 'Break',
'0x04': 'Middle_Button',
'0x05': 'X_Button_1',
'0x06': 'X_Button_2',
'0x08': 'Backspace',
'0x09': 'Tab',
'0x0C': 'Clear',
'0x0D': 'Enter',
'0x10': 'Shift',
'0x11': 'Ctrl',
'0x12': 'Alt',
'0x13': 'Pause',
'0x14': 'Caps_Lock',
'0x15': 'Kana',
'0x17': 'Junja',
'0x18': 'Final',
'0x19': 'Kanji',
'0x1B': 'Esc',
'0x1C': 'Convert',
'0x1D': 'Non_Convert',
'0x1E': 'Accept',
'0x1F': 'Mode_Change',
'0x20': 'Space',
'0x21': 'Page_Up',
'0x22': 'Page_Down',
'0x23': 'End',
'0x24': 'Home',
'0x25': 'Arrow_Left',
'0x26': 'Arrow_Up',
'0x27': 'Arrow_Right',
'0x28': 'Arrow_Down',
'0x29': 'Select',
'0x2A': 'Print',
'0x2B': 'Execute',
'0x2C': 'Print_Screen',
'0x2D': 'Insert',
'0x2E': 'Delete',
'0x2F': 'Help',
'0x30': '0',
'0x31': '1',
'0x32': '2',
'0x33': '3',
'0x34': '4',
'0x35': '5',
'0x36': '6',
'0x37': '7',
'0x38': '8',
'0x39': '9',
'0x41': 'A',
'0x42': 'B',
'0x43': 'C',
'0x44': 'D',
'0x45': 'E',
'0x46': 'F',
'0x47': 'G',
'0x48': 'H',
'0x49': 'I',
'0x4A': 'J',
'0x4B': 'K',
'0x4C': 'L',
'0x4D': 'M',
'0x4E': 'N',
'0x4F': 'O',
'0x50': 'P',
'0x51': 'Q',
'0x52': 'R',
'0x53': 'S',
'0x54': 'T',
'0x55': 'U',
'0x56': 'V',
'0x57': 'W',
'0x58': 'X',
'0x59': 'Y',
'0x5A': 'Z',
'0x5B': 'Left_Win',
'0x5C': 'Right_Win',
'0x5D': 'Context_Menu',
'0x5F': 'Sleep',
'0x60': 'Numpad_0',
'0x61': 'Numpad_1',
'0x62': 'Numpad_2',
'0x63': 'Numpad_3',
'0x64': 'Numpad_4',
'0x65': 'Numpad_5',
'0x66': 'Numpad_6',
'0x67': 'Numpad_7',
'0x68': 'Numpad_8',
'0x69': 'Numpad_9',
'0x6A': 'Numpad_*',
'0x6B': 'Numpad_+',
'0x6C': 'Separator',
'0x6D': 'Num_-',
'0x6E': 'Numpad_.',
'0x6F': 'Numpad_/',
'0x70': 'F1',
'0x71': 'F2',
'0x72': 'F3',
'0x73': 'F4',
'0x74': 'F5',
'0x75': 'F6',
'0x76': 'F7',
'0x77': 'F8',
'0x78': 'F9',
'0x79': 'F10',
'0x7A': 'F11',
'0x7B': 'F12',
'0x7C': 'F13',
'0x7D': 'F14',
'0x7E': 'F15',
'0x7F': 'F16',
'0x80': 'F17',
'0x81': 'F18',
'0x82': 'F19',
'0x83': 'F20',
'0x84': 'F21',
'0x85': 'F22',
'0x86': 'F23',
'0x87': 'F24',
'0x90': 'Num_Lock',
'0x91': 'Scrol_Lock',
'0x92': 'Jisho',
'0x93': 'Mashu',
'0x94': 'Touroku',
'0x95': 'Loya',
'0x96': 'Roya',
'0xA0': 'Left_Shift',
'0xA1': 'Right_Shift',
'0xA2': 'Left_Ctrl',
'0xA3': 'Right_Ctrl',
'0xA4': 'Left_Alt',
'0xA5': 'Right_Alt',
'0xA6': 'Browser_Back',
'0xA7': 'Browser_Forward',
'0xA8': 'Browser_Refresh',
'0xA9': 'Browser_Stop',
'0xAA': 'Browser_Search',
'0xAB': 'Browser_Favorites',
'0xAC': 'Browser_Home',
'0xAD': 'Volume_Mute',
'0xAE': 'Volume_Down',
'0xAF': 'Volume_Up',
'0xB0': 'Next_Track',
'0xB1': 'Previous_Track',
'0xB2': 'Stop',
'0xB3': 'Play_Pause',
'0xB4': 'Mail',
'0xB5': 'Media',
'0xB6': 'App1',
'0xB7': 'App2',
'0xBA': ';_:',
'0xBB': '=_+',
'0xBC': ',_<',
'0xBD': '-_-_',
'0xBE': '._>',
'0xBF': '/_?',
'0xC0': '`_~',
'0xC1': 'Abnt_C1',
'0xC2': 'Abnt_C2',
'0xDB': '[_{',
'0xDC': '\\_|',
'0xDD': ']}_',
'0xDE': '\\_"',
'0xDF': '!_В§',
'0xE1': 'Ax',
'0xE2': '>_<',
'0xE3': 'IcoHlp',
'0xE5': 'Process',
'0xE6': 'IcoClr',
'0xE7': 'Packet',
'0xE9': 'Reset',
'0xEA': 'Jump',
'0xEB': 'OemPa1',
'0xEC': 'OemPa2',
'0xED': 'OemPa3',
'0xEE': 'WsCtrl',
'0xEF': 'Cu_Sel',
'0xF0': 'Oem_Attn',
'0xF1': 'Finish',
'0xF2': 'Copy',
'0xF3': 'Auto',
'0xF4': 'Enlw',
'0xF5': 'Back_Tab',
'0xF6': 'Attn',
'0xF7': 'Cr_Sel',
'0xF8': 'Ex_Sel',
'0xF9': 'Er_Eof',
'0xFA': 'Play',
'0xFB': 'Zoom',
'0xFD': 'Pa1',
'0xFE': 'OemClr'
}
Can someone explain how to send a key combination such as fn+c, or fn+h - on iOS devices, this would bring up the control center and navigate to the home screen, respectively. In using usbmon, I captured what the 8 bytes are being sent when pressing fn+c:
0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x01
0x00 0x00 0x06 0x00 0x00 0x00 0x00 0x01
but sending those sequences into an iOS device, did not trigger the expected behaviour.
It turns out the report_desc needs to be the same as an actual Apple keyboard in order for the byte sequence to be recognized correctly by the iOS device.
Can someone explain how to send a key combination such as fn+c, or fn+h - on iOS devices, this would bring up the control center and navigate to the home screen, respectively. In using usbmon, I captured what the 8 bytes are being sent when pressing fn+c:
0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x01
0x00 0x00 0x06 0x00 0x00 0x00 0x00 0x01
but sending those sequences into an iOS device, did not trigger the expected behaviour.
It turns out the report_desc needs to be the same as an actual Apple keyboard in order for the byte sequence to be recognized correctly by the iOS device.
Did you figure the iOS part out? I have this cheapo bluetooth keyboard from Amazon, but it has this function key and some options for what OS it’s being used on IE fn + android / iOS / windows … but that’s Bluetooth not usb. But clearly there is a difference between what OS and the key mappings. I wonder if this is the case for the USB. I’m trying to implement this on a OrangePi zero 2w.
I just started reading the code etc , but I assume this has to use the usb-OTG? Or it can run as a host usb ? I’m trying to map it to a web browser window with JavaScript listener events, for HID keyboard and Mouse. Then send it to the server or backend where the device is plugged in, what I hope is to be able to use this library to translate the the browser event listener to the proper output for usb HID and/or with a toggle button (in the html ux) toggle it to Bluetooth HID, and/or iOS android etc …
** edit
Have you looked at this ?
https://developer.apple.com/accessories/Accessory-Design-Guidelines.pdf#page82
@carylewis more specific I think the table 14-3 on page 85 where it shows optional 1 click hid commands for the menu which is equivalent to iOS home button
Also look at https://developer.apple.com/accessories/Accessory-Design-Guidelines.pdf#page203
which mentions the HID and is both same for USB and/or Bluetooth devices
With usb rfid device that has already hid installed and the output is in characters (tag data read), how do I install a usb and code to accept the tag data into a file or sd on Arduino. There would be 2 or more devices to attach.
What keypad lilbrary is set up to handle this ?
Thanks
Can anyone else confirm that 0x7d actually works?
Please note that there is JSON attached to that PDF and it have all registered HID usages inside. It’s part of the spec.