1 /* Copyright (C) 2011-2014 by Jacob Alexander
3 * Permission is hereby granted, free of charge, to any person obtaining a copy
4 * of this software and associated documentation files (the "Software"), to deal
5 * in the Software without restriction, including without limitation the rights
6 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 * copies of the Software, and to permit persons to whom the Software is
8 * furnished to do so, subject to the following conditions:
10 * The above copyright notice and this permission notice shall be included in
11 * all copies or substantial portions of the Software.
13 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25 // ----- Defines -----
27 // The USB codes are all taken from the USB HID Spec
28 // http://www.usb.org/developers/devclass_docs/Hut1_11.pdf
30 // List of Keycodes - USB HID 1.11 pg 53
31 #define KEY_NOEVENT 0x00 // Event, not a physical key
32 #define KEY_ERRORROLLOVER 0x01 // Event, not a physical key
33 #define KEY_POSTFAIL 0x02 // Event, not a physical key
34 #define KEY_ERRORUNDEFINED 0x03 // Event, not a physical key
71 #define KEY_ENTER 0x28
73 #define KEY_BACKSPACE 0x2A
75 #define KEY_SPACE 0x2C
76 #define KEY_MINUS 0x2D
77 #define KEY_EQUAL 0x2E
78 #define KEY_LEFT_BRACE 0x2F
79 #define KEY_RIGHT_BRACE 0x30
80 #define KEY_BACKSLASH 0x31
81 #define KEY_NUMBER 0x32
82 #define KEY_SEMICOLON 0x33
83 #define KEY_QUOTE 0x34
84 #define KEY_TILDE 0x35 // TODO Removeme (old definition)
85 #define KEY_BACKTICK 0x35
86 #define KEY_COMMA 0x36
87 #define KEY_PERIOD 0x37
88 #define KEY_SLASH 0x38
89 #define KEY_CAPS_LOCK 0x39
102 #define KEY_PRINTSCREEN 0x46
103 #define KEY_SCROLL_LOCK 0x47
104 #define KEY_PAUSE 0x48
105 #define KEY_INSERT 0x49
106 #define KEY_HOME 0x4A
107 #define KEY_PAGE_UP 0x4B
108 #define KEY_DELETE 0x4C
110 #define KEY_PAGE_DOWN 0x4E
111 #define KEY_RIGHT 0x4F
112 #define KEY_LEFT 0x50
113 #define KEY_DOWN 0x51
115 #define KEY_NUM_LOCK 0x53
116 #define KEYPAD_SLASH 0x54
117 #define KEYPAD_ASTERIX 0x55
118 #define KEYPAD_MINUS 0x56
119 #define KEYPAD_PLUS 0x57
120 #define KEYPAD_ENTER 0x58
121 #define KEYPAD_1 0x59
122 #define KEYPAD_2 0x5A
123 #define KEYPAD_3 0x5B
124 #define KEYPAD_4 0x5C
125 #define KEYPAD_5 0x5D
126 #define KEYPAD_6 0x5E
127 #define KEYPAD_7 0x5F
128 #define KEYPAD_8 0x60
129 #define KEYPAD_9 0x61
130 #define KEYPAD_0 0x62
131 #define KEYPAD_PERIOD 0x63
132 #define KEY_ISO_BACKSLASH 0x64 // TODO Removeme (old definition)
133 #define KEY_ISO_SLASH 0x64
135 #define KEYBOARD_STATUS 0x66 // Used for indicating status or errors, not a key
136 #define KEYPAD_EQUAL 0x67
149 #define KEY_EXEC 0x74
150 #define KEY_HELP 0x75
151 #define KEY_MENU 0x76
152 #define KEY_SELECT 0x77
153 #define KEY_STOP 0x78
154 #define KEY_AGAIN 0x79
155 #define KEY_UNDO 0x7A
157 #define KEY_COPY 0x7C
158 #define KEY_PASTE 0x7D
159 #define KEY_FIND 0x7E
160 #define KEY_MUTE 0x7F
161 #define KEY_VOL_UP 0x80
162 #define KEY_VOL_DOWN 0x81
163 #define KEY_CAPS_TLOCK 0x82 // Toggle "Locking" Scroll Lock (Old keyboards with Locking Caps Lock)
164 #define KEY_NUM_TLOCK 0x83
165 #define KEY_SCROLL_TLOCK 0x84
166 #define KEYPAD_COMMA 0x85 // Brazillian (See spec)
167 #define KEYPAD_EQUAL_AS 0x86 // AS/400 Keyboard (See spec)
168 #define KEY_INTER1 0x87 // KANJI1 - Brazillian and Japanese "Ru" and "-"
169 #define KEY_INTER2 0x88 // KANJI2 - Japanese Katakana/Hiragana
170 #define KEY_INTER3 0x89 // KANJI3 - Japanese Yen
171 #define KEY_INTER4 0x8A // KANJI4 - Japanese Henkan
172 #define KEY_INTER5 0x8B // KANJI5 - Japanese Muhenkan
173 #define KEY_INTER6 0x8C // KANJI6 - PC0x62 Comma (Ka-m-ma)
174 #define KEY_INTER7 0x8D // KANJI7 - Double-Byte/Single-Byte Toggle
175 #define KEY_INTER8 0x8E // KANJI8 - Undefined
176 #define KEY_INTER9 0x8F // KANJI9 - Undefined
177 #define KEY_LANG1 0x90 // Korean Hangul/English Toggle
178 #define KEY_LANG2 0x91 // Korean Hanja Conversion - Japanese Eisu
179 #define KEY_LANG3 0x92 // Japanese Katakana Key (USB)
180 #define KEY_LANG4 0x93 // Japanese Hiragana Key (USB)
181 #define KEY_LANG5 0x94 // Japanese Zenkaku/Hankaku Key (USB)
182 #define KEY_LANG6 0x95 // Reserved (Application Specific)
183 #define KEY_LANG7 0x96 // Reserved (Application Specific)
184 #define KEY_LANG8 0x97 // Reserved (Application Specific)
185 #define KEY_LANG9 0x98 // Reserved (Application Specific)
186 #define KEY_ALT_ERASE 0x99 // Special Erase (See Spec)
187 #define KEY_SYSREQ_ATT 0x9A // Modifier Type
188 #define KEY_CANCEL 0x9B
189 #define KEY_CLEAR 0x9C
190 #define KEY_PRIOR 0x9D
191 #define KEY_RETURN 0x9E
192 #define KEY_SEPARATOR 0x9F
194 #define KEY_OPER 0xA1
195 #define KEY_CLEAR_AGAIN 0xA2
196 #define KEY_CRSEL_PROPS 0xA3
197 #define KEY_EXSEL 0xA4
198 // 0xA5 - 0xAF Reserved
199 #define KEYPAD_00 0xB0
200 #define KEYPAD_000 0xB1
201 #define KEY_1000_SEP 0xB2
202 #define KEY_DECIMAL_SEP 0xB3
203 #define KEY_CURRENCY_MAIN 0xB4
204 #define KEY_CURRENCY_SUB 0xB5
205 #define KEYPAD_LPAREN 0xB6
206 #define KEYPAD_RPAREN 0xB7
207 #define KEYPAD_LBRACE 0xB8
208 #define KEYPAD_RBRACE 0xB9
209 #define KEYPAD_TAB 0xBA
210 #define KEYPAD_BACKSPACE 0xBB
211 #define KEYPAD_A 0xBC
212 #define KEYPAD_B 0xBD
213 #define KEYPAD_C 0xBE
214 #define KEYPAD_D 0xBF
215 #define KEYPAD_E 0xC0
216 #define KEYPAD_F 0xC1
217 #define KEYPAD_XOR 0xC2
218 #define KEYPAD_CHEVRON 0xC3
219 #define KEYPAD_PERCENT 0xC4
220 #define KEYPAD_LTHAN 0xC5
221 #define KEYPAD_GTHAN 0xC6
222 #define KEYPAD_BITAND 0xC7
223 #define KEYPAD_AND 0xC8
224 #define KEYPAD_BITOR 0xC9
225 #define KEYPAD_OR 0xCA
226 #define KEYPAD_COLON 0xCB
227 #define KEYPAD_POUND 0xCC
228 #define KEYPAD_SPACE 0xCD
229 #define KEYPAD_AT 0xCE
230 #define KEYPAD_EXCLAIM 0xCF
231 #define KEYPAD_MEM_STORE 0xD0
232 #define KEYPAD_MEM_RECALL 0xD1
233 #define KEYPAD_MEM_CLEAR 0xD2
234 #define KEYPAD_MEM_ADD 0xD3
235 #define KEYPAD_MEM_SUB 0xD4
236 #define KEYPAD_MEM_MULT 0xD5
237 #define KEYPAD_MEM_DIV 0xD6
238 #define KEYPAD_PLUS_MINUS 0xD7
239 #define KEYPAD_CLEAR 0xD8
240 #define KEYPAD_CLEAR_ENTRY 0xD9
241 #define KEYPAD_BINARY 0xDA
242 #define KEYPAD_OCTAL 0xDB
243 #define KEYPAD_DECIMAL 0xDC
244 #define KEYPAD_HEX 0xDD
245 // 0xDE - 0xDF Reserved
246 #define KEY_CTRL 0xE0 // Convenience
247 #define KEY_LCTRL 0xE0
248 #define KEY_SHIFT 0xE1 // Convenience
249 #define KEY_LSHIFT 0xE1
250 #define KEY_ALT 0xE2 // Convenience
251 #define KEY_LALT 0xE2
252 #define KEY_GUI 0xE3 // Convenience
253 #define KEY_LGUI 0xE3
254 #define KEY_RCTRL 0xE4
255 #define KEY_RSHIFT 0xE5
256 #define KEY_RALT 0xE6
257 #define KEY_RGUI 0xE7
258 // 0xE8 - 0xFFFF Reserved
259 // Except for 0xE0-0xE7 which are DV (Dynamic Flags), all Keycodes are Sel (Selectors).
262 // List of LED codes - USB HID 1.11 pg 61
263 // LED/Indicators are defined as:
264 // OOC - On/Off Control
265 // US - Usage Indicator: 1 - In Use, 0 - Not In Use
266 // UM - Usage Multi Mode Indicator Collection of 1 or more indicators: On, Flash, Slow Blink, Fast Blink, Off
269 #define LED_UNDEFINED 0x00
270 #define LED_NUM_LOCK 0x01 // OOC
271 #define LED_CAPS_LOCK 0x02 // OOC
272 #define LED_SCROLL_LOCK 0x03 // OOC
273 #define LED_COMPOSE 0x04 // OOC
274 #define LED_KANA 0x05 // OOC
275 #define LED_POWER 0x06 // OOC
276 #define LED_SHIFT 0x07 // OOC
277 #define LED_DO_NOT_DISTURB 0x08 // OOC
278 #define LED_MUTE 0x09 // OOC
279 #define LED_TONE_ENABLE 0x0A // OOC
280 #define LED_HIGHCUT_FILTER 0x0B // OOC
281 #define LED_LOWCUT_FILTER 0x0C // OOC
282 #define LED_EQL_ENABLE 0x0D // OOC
283 #define LED_SND_FLD_ON 0x0E // OOC
284 #define LED_SURROUND_ON 0x0F // OOC
285 #define LED_REPEAT 0x10 // OOC
286 #define LED_STEREO 0x11 // OOC
287 #define LED_SAMPLE_RT_DET 0x12 // OOC
288 #define LED_SPINNING 0x13 // OOC
289 #define LED_CAV 0x14 // OOC
290 #define LED_CLV 0x15 // OOC
291 #define LED_REC_FMT_DET 0x16 // OOC
292 #define LED_OFF_HOOK 0x17 // OOC
293 #define LED_RING 0x18 // OOC
294 #define LED_MSG_WAITING 0x19 // OOC
295 #define LED_DATA_MODE 0x1A // OOC
296 #define LED_BAT_OPERATION 0x1B // OOC
297 #define LED_BAT_OK 0x1C // OOC
298 #define LED_BAT_LOW 0x1D // OOC
299 #define LED_SPEAKER 0x1E // OOC
300 #define LED_HEAD_SET 0x1F // OOC
301 #define LED_HOLD 0x20 // OOC
302 #define LED_MICROPHONE 0x21 // OOC
303 #define LED_COVERAGE 0x22 // OOC
304 #define LED_NIGHT_MODE 0x23 // OOC
305 #define LED_SEND_CALLS 0x24 // OOC
306 #define LED_CALL_PICKUP 0x25 // OOC
307 #define LED_CONFERENCE 0x26 // OOC
308 #define LED_STAND_BY 0x27 // OOC
309 #define LED_CAMERA_ON 0x28 // OOC
310 #define LED_CAMERA_OFF 0x29 // OOC
311 #define LED_ON_LINE 0x2A // OOC
312 #define LED_OFF_LINE 0x2B // OOC
313 #define LED_BUSY 0x2C // OOC
314 #define LED_READY 0x2D // OOC
315 #define LED_PAPER_OUT 0x2E // OOC
316 #define LED_PAPER_JAM 0x2F // OOC
317 #define LED_REMOTE 0x30 // OOC
318 #define LED_FORWARD 0x31 // OOC
319 #define LED_REVERSE 0x32 // OOC
320 #define LED_STOP 0x33 // OOC
321 #define LED_REWIND 0x34 // OOC
322 #define LED_FAST_FORWARD 0x35 // OOC
323 #define LED_PLAY 0x36 // OOC
324 #define LED_PAUSE 0x37 // OOC
325 #define LED_RECORD 0x38 // OOC
326 #define LED_ERROR 0x39 // OOC
327 #define LED_USI 0x3A // US
328 #define LED_UIUI 0x3B // US
329 #define LED_UMMI 0x3C // UM
330 #define LED_IND_ON 0x3D // Sel
331 #define LED_IND_FLASH 0x3E // Sel
332 #define LED_IND_SLOW_BLNK 0x3F // Sel
333 #define LED_IND_FAST_BLNK 0x40 // Sel
334 #define LED_IND_OFF 0x41 // Sel
335 #define LED_FLASH_ON_TIME 0x42 // DV
336 #define LED_SLW_B_ON_TIME 0x43 // DV
337 #define LED_SLW_B_OFF_TIME 0x44 // DV
338 #define LED_FST_B_ON_TIME 0x45 // DV
339 #define LED_FST_B_OFF_TIME 0x46 // DV
340 #define LED_UIC 0x47 // UM
341 #define LED_IND_RED 0x48 // Sel
342 #define LED_IND_GREEN 0x49 // Sel
343 #define LED_IND_AMBER 0x4A // Sel
344 #define LED_GENERIC_IND 0x4B // OOC
345 #define LED_SYS_SUSPEND 0x4C // OOC
346 #define LED_EXT_PWR_CONN 0x4D // OOC
347 // 0x4E - 0xFFFF Reserved
350 // List of Mouse Buttons - USB HID 1.11 pg 67
351 #define MOUSE_NOPRESS 0x00
352 #define MOUSE_PRIMARY 0x01 // Button 1
353 #define MOUSE_SECONDARY 0x02 // Button 2
354 #define MOUSE_TERTIARY 0x03 // Button 3
355 #define MOUSE_BUTTON(x) x
356 // Continues to 0xFFFF, the higher the Mouse code, the selector significance descreases
357 // Buttons can be defined as:
359 // OOC - On/Off Control
360 // MC - Momentary Control
361 // OSC - One-Shot Control
362 // depending on context.
366 // List of Consumer Codes - USB HID 1.11
367 // Only listing used ones, let me know if you need more -HaaTa
368 #define CONSUMER_SCAN_NEXT_TRACK 0x0B5
369 #define CONSUMER_SCAN_PREVIOUS_TRACK 0x0B6
370 #define CONSUMER_STOP 0x0B7
371 #define CONSUMER_EJECT 0x0B8
373 #define CONSUMER_PAUSE_PLAY 0x0CD
375 #define CONSUMER_MUTE 0x0E2
377 #define CONSUMER_BASS_BOOST 0x0E5
379 #define CONSUMER_LOUDNESS 0x0E7
381 #define CONSUMER_VOLUME_UP 0x0E9
382 #define CONSUMER_VOLUME_DOWN 0x0EA
384 #define CONSUMER_BASS_INCR 0x152
385 #define CONSUMER_BASS_DECR 0x153
386 #define CONSUMER_TREBLE_INCR 0x154
387 #define CONSUMER_TREBLE_DECR 0x155
389 #define CONSUMER_AL_LAUNCH_BUTTON_CONFIG_TOOL 0x181
390 #define CONSUMER_AL_PROGRAMMABLE_BUTTON_CONFIG 0x182
391 #define CONSUMER_AL_CONSUMER_CONTROL_CONFIG 0x183
392 #define CONSUMER_AL_WORD_PROCESSOR 0x184
393 #define CONSUMER_AL_TEXT_EDITOR 0x185
394 #define CONSUMER_AL_SPREADSHEET 0x186
395 #define CONSUMER_AL_GRAPHICS_EDITOR 0x187
396 #define CONSUMER_AL_PRESENTATION_APP 0x188
397 #define CONSUMER_AL_DATABASE_APP 0x189
398 #define CONSUMER_AL_EMAIL_READER 0x18A
399 #define CONSUMER_AL_NEWSREADER 0x18B
400 #define CONSUMER_AL_VOICEMAIL 0x18C
401 #define CONSUMER_AL_CONTACTS_ADDRESS_BOOK 0x18D
402 #define CONSUMER_AL_CALENDAR_SCHEDULE 0x18E
403 #define CONSUMER_AL_TASK_PROJECT_MANAGER 0x18F
404 #define CONSUMER_AL_LOG_JOURNAL_TIMECARD 0x190
405 #define CONSUMER_AL_CHECKBOOK_FINANCE 0x191
406 #define CONSUMER_AL_CALCULATOR 0x192
407 #define CONSUMER_AL_A_V_CAPTURE_PLAYBACK 0x193
408 #define CONSUMER_AL_LOCAL_MACHINE_BROWSER 0x194
409 #define CONSUMER_AL_LAN_WAN_BROWSER 0x195
410 #define CONSUMER_AL_INTERNET_BROWSER 0x196
411 #define CONSUMER_AL_REMOTE_NETWORKING_ISP_CONNECT 0x197
412 #define CONSUMER_AL_NETWORK_CONFERENCE 0x198
413 #define CONSUMER_AL_NETWORK_CHAT 0x199
414 #define CONSUMER_AL_TELEPHONY_DIALER 0x19A
415 #define CONSUMER_AL_LOGON 0x19B
416 #define CONSUMER_AL_LOGOFF 0x19C
417 #define CONSUMER_AL_LOGON_LOGOFF 0x19D
418 #define CONSUMER_AL_TERMINAL_LOCK_SCREENSAVER 0x19E
419 #define CONSUMER_AL_CONTROL_PANEL 0x19F
420 #define CONSUMER_AL_COMMAND_LINE_PROCESSOR_RUN 0x1A0
421 #define CONSUMER_AL_PROCESS_TASK_MANAGER 0x1A1
422 #define CONSUMER_AL_SELECT_TAST_APP 0x1A2
423 #define CONSUMER_AL_NEXT_TASK_APP 0x1A3
424 #define CONSUMER_AL_PREVIOUS_TASK_APP 0x1A4
425 #define CONSUMER_AL_PREEMPTIVE_HALT_TASK_APP 0x1A5
427 #define CONSUMER_AC_NEW 0x201
428 #define CONSUMER_AC_OPEN 0x202
429 #define CONSUMER_AC_CLOSE 0x203
430 #define CONSUMER_AC_EXIT 0x204
431 #define CONSUMER_AC_MAXIMIZE 0x205
432 #define CONSUMER_AC_MINIMIZE 0x206
433 #define CONSUMER_AC_SAVE 0x207
434 #define CONSUMER_AC_PRINT 0x208
435 #define CONSUMER_AC_PROPERTIES 0x209
436 #define CONSUMER_AC_UNDO 0x21A
437 #define CONSUMER_AC_COPY 0x21B
438 #define CONSUMER_AC_CUT 0x21C
439 #define CONSUMER_AC_PASTE 0x21D
440 #define CONSUMER_AC_SELECT_ALL 0x21E
441 #define CONSUMER_AC_FIND 0x21F
442 #define CONSUMER_AC_FIND_AND_REPLACE 0x220
443 #define CONSUMER_AC_SEARCH 0x221
444 #define CONSUMER_AC_GO_TO 0x222
445 #define CONSUMER_AC_HOME 0x223
446 #define CONSUMER_AC_BACK 0x224
447 #define CONSUMER_AC_FORWARD 0x225
448 #define CONSUMER_AC_STOP 0x226
449 #define CONSUMER_AC_REFRESH 0x227
450 #define CONSUMER_AC_PREVIOUS_LINK 0x228
451 #define CONSUMER_AC_NEXT_LINK 0x229
452 #define CONSUMER_AC_BOOKMARKS 0x22A
453 #define CONSUMER_AC_HISTORY 0x22B
454 #define CONSUMER_AC_SUBSCRIPTIONS 0x22C
455 #define CONSUMER_AC_ZOOM_IN 0x22D
456 #define CONSUMER_AC_ZOOM_OUT 0x22E
457 #define CONSUMER_AC_ZOOM 0x22F
458 #define CONSUMER_AC_FULL_SCREEN_VIEW 0x230
459 #define CONSUMER_AC_NORMAL_VIEW 0x231
460 #define CONSUMER_AC_VIEW_TOGGLE 0x232
461 #define CONSUMER_AC_SCROLL_UP 0x233
462 #define CONSUMER_AC_SCROLL_DOWN 0x234
463 #define CONSUMER_AC_SCROLL 0x235
464 #define CONSUMER_AC_PAN_LEFT 0x236
465 #define CONSUMER_AC_PAN_RIGHT 0x237
466 #define CONSUMER_AC_PAN 0x238
467 #define CONSUMER_AC_NEW_WINDOW 0x239
468 #define CONSUMER_AC_TILE_HORIZONTALLY 0x23A
469 #define CONSUMER_AC_TILE_VERTICALLY 0x23B
470 #define CONSUMER_AC_FORMAT 0x23C