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
195 #define KEY_OPER 0xA1
196 #define KEY_CLEAR_AGAIN 0xA2
197 #define KEY_CRSEL_PROPS 0xA3
198 #define KEY_EXSEL 0xA4
199 // 0xA5 - 0xAF Reserved
200 #define KEYPAD_00 0xB0
201 #define KEYPAD_000 0xB1
202 #define KEY_1000_SEP 0xB2
203 #define KEY_DECIMAL_SEP 0xB3
204 #define KEY_CURRENCY_MAIN 0xB4
205 #define KEY_CURRENCY_SUB 0xB5
206 #define KEYPAD_LPAREN 0xB6
207 #define KEYPAD_RPAREN 0xB7
208 #define KEYPAD_LBRACE 0xB8
209 #define KEYPAD_RBRACE 0xB9
210 #define KEYPAD_TAB 0xBA
211 #define KEYPAD_BACKSPACE 0xBB
212 #define KEYPAD_A 0xBC
213 #define KEYPAD_B 0xBD
214 #define KEYPAD_C 0xBE
215 #define KEYPAD_D 0xBF
216 #define KEYPAD_E 0xC0
217 #define KEYPAD_F 0xC1
218 #define KEYPAD_XOR 0xC2
219 #define KEYPAD_CHEVRON 0xC3
220 #define KEYPAD_PERCENT 0xC4
221 #define KEYPAD_LTHAN 0xC5
222 #define KEYPAD_GTHAN 0xC6
223 #define KEYPAD_BITAND 0xC7
224 #define KEYPAD_AND 0xC8
225 #define KEYPAD_BITOR 0xC9
226 #define KEYPAD_OR 0xCA
227 #define KEYPAD_COLON 0xCB
228 #define KEYPAD_POUND 0xCC
229 #define KEYPAD_SPACE 0xCD
230 #define KEYPAD_AT 0xCE
231 #define KEYPAD_EXCLAIM 0xCF
232 #define KEYPAD_MEM_STORE 0xD0
233 #define KEYPAD_MEM_RECALL 0xD1
234 #define KEYPAD_MEM_CLEAR 0xD2
235 #define KEYPAD_MEM_ADD 0xD3
236 #define KEYPAD_MEM_SUB 0xD4
237 #define KEYPAD_MEM_MULT 0xD5
238 #define KEYPAD_MEM_DIV 0xD6
239 #define KEYPAD_PLUS_MINUS 0xD7
240 #define KEYPAD_CLEAR 0xD8
241 #define KEYPAD_CLEAR_ENTRY 0xD9
242 #define KEYPAD_BINARY 0xDA
243 #define KEYPAD_OCTAL 0xDB
244 #define KEYPAD_DECIMAL 0xDC
245 #define KEYPAD_HEX 0xDD
246 // 0xDE - 0xDF Reserved
247 #define KEY_CTRL 0xE0 // Convenience
248 #define KEY_LCTRL 0xE0
249 #define KEY_SHIFT 0xE1 // Convenience
250 #define KEY_LSHIFT 0xE1
251 #define KEY_ALT 0xE2 // Convenience
252 #define KEY_LALT 0xE2
253 #define KEY_GUI 0xE3 // Convenience
254 #define KEY_LGUI 0xE3
255 #define KEY_RCTRL 0xE4
256 #define KEY_RSHIFT 0xE5
257 #define KEY_RALT 0xE6
258 #define KEY_RGUI 0xE7
259 // 0xE8 - 0xFFFF Reserved
260 // Except for 0xE0-0xE7 which are DV (Dynamic Flags), all Keycodes are Sel (Selectors).
263 // List of LED codes - USB HID 1.11 pg 61
264 // LED/Indicators are defined as:
265 // OOC - On/Off Control
266 // US - Usage Indicator: 1 - In Use, 0 - Not In Use
267 // UM - Usage Multi Mode Indicator Collection of 1 or more indicators: On, Flash, Slow Blink, Fast Blink, Off
270 #define LED_UNDEFINED 0x00
271 #define LED_NUM_LOCK 0x01 // OOC
272 #define LED_CAPS_LOCK 0x02 // OOC
273 #define LED_SCROLL_LOCK 0x03 // OOC
274 #define LED_COMPOSE 0x04 // OOC
275 #define LED_KANA 0x05 // OOC
276 #define LED_POWER 0x06 // OOC
277 #define LED_SHIFT 0x07 // OOC
278 #define LED_DO_NOT_DISTURB 0x08 // OOC
279 #define LED_MUTE 0x09 // OOC
280 #define LED_TONE_ENABLE 0x0A // OOC
281 #define LED_HIGHCUT_FILTER 0x0B // OOC
282 #define LED_LOWCUT_FILTER 0x0C // OOC
283 #define LED_EQL_ENABLE 0x0D // OOC
284 #define LED_SND_FLD_ON 0x0E // OOC
285 #define LED_SURROUND_ON 0x0F // OOC
286 #define LED_REPEAT 0x10 // OOC
287 #define LED_STEREO 0x11 // OOC
288 #define LED_SAMPLE_RT_DET 0x12 // OOC
289 #define LED_SPINNING 0x13 // OOC
290 #define LED_CAV 0x14 // OOC
291 #define LED_CLV 0x15 // OOC
292 #define LED_REC_FMT_DET 0x16 // OOC
293 #define LED_OFF_HOOK 0x17 // OOC
294 #define LED_RING 0x18 // OOC
295 #define LED_MSG_WAITING 0x19 // OOC
296 #define LED_DATA_MODE 0x1A // OOC
297 #define LED_BAT_OPERATION 0x1B // OOC
298 #define LED_BAT_OK 0x1C // OOC
299 #define LED_BAT_LOW 0x1D // OOC
300 #define LED_SPEAKER 0x1E // OOC
301 #define LED_HEAD_SET 0x1F // OOC
302 #define LED_HOLD 0x20 // OOC
303 #define LED_MICROPHONE 0x21 // OOC
304 #define LED_COVERAGE 0x22 // OOC
305 #define LED_NIGHT_MODE 0x23 // OOC
306 #define LED_SEND_CALLS 0x24 // OOC
307 #define LED_CALL_PICKUP 0x25 // OOC
308 #define LED_CONFERENCE 0x26 // OOC
309 #define LED_STAND_BY 0x27 // OOC
310 #define LED_CAMERA_ON 0x28 // OOC
311 #define LED_CAMERA_OFF 0x29 // OOC
312 #define LED_ON_LINE 0x2A // OOC
313 #define LED_OFF_LINE 0x2B // OOC
314 #define LED_BUSY 0x2C // OOC
315 #define LED_READY 0x2D // OOC
316 #define LED_PAPER_OUT 0x2E // OOC
317 #define LED_PAPER_JAM 0x2F // OOC
318 #define LED_REMOTE 0x30 // OOC
319 #define LED_FORWARD 0x31 // OOC
320 #define LED_REVERSE 0x32 // OOC
321 #define LED_STOP 0x33 // OOC
322 #define LED_REWIND 0x34 // OOC
323 #define LED_FAST_FORWARD 0x35 // OOC
324 #define LED_PLAY 0x36 // OOC
325 #define LED_PAUSE 0x37 // OOC
326 #define LED_RECORD 0x38 // OOC
327 #define LED_ERROR 0x39 // OOC
328 #define LED_USI 0x3A // US
329 #define LED_UIUI 0x3B // US
330 #define LED_UMMI 0x3C // UM
331 #define LED_IND_ON 0x3D // Sel
332 #define LED_IND_FLASH 0x3E // Sel
333 #define LED_IND_SLOW_BLNK 0x3F // Sel
334 #define LED_IND_FAST_BLNK 0x40 // Sel
335 #define LED_IND_OFF 0x41 // Sel
336 #define LED_FLASH_ON_TIME 0x42 // DV
337 #define LED_SLW_B_ON_TIME 0x43 // DV
338 #define LED_SLW_B_OFF_TIME 0x44 // DV
339 #define LED_FST_B_ON_TIME 0x45 // DV
340 #define LED_FST_B_OFF_TIME 0x46 // DV
341 #define LED_UIC 0x47 // UM
342 #define LED_IND_RED 0x48 // Sel
343 #define LED_IND_GREEN 0x49 // Sel
344 #define LED_IND_AMBER 0x4A // Sel
345 #define LED_GENERIC_IND 0x4B // OOC
346 #define LED_SYS_SUSPEND 0x4C // OOC
347 #define LED_EXT_PWR_CONN 0x4D // OOC
348 // 0x4E - 0xFFFF Reserved
351 // List of Mouse Buttons - USB HID 1.11 pg 67
352 #define MOUSE_NOPRESS 0x00
353 #define MOUSE_PRIMARY 0x01 // Button 1
354 #define MOUSE_SECONDARY 0x02 // Button 2
355 #define MOUSE_TERTIARY 0x03 // Button 3
356 #define MOUSE_BUTTON(x) x
357 // Continues to 0xFFFF, the higher the Mouse code, the selector significance descreases
358 // Buttons can be defined as:
360 // OOC - On/Off Control
361 // MC - Momentary Control
362 // OSC - One-Shot Control
363 // depending on context.