| LPCOpen Platform v1.03 LPCOpen Platform for NXP LPC Microcontrollers

- Main Page
- Modules
- Data Structures
- Files
- Related Pages

- File List
- Globals

All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
HIDClassCommon.h
Go to the documentation of this file.
1 /*
2 * @brief Common definitions and declarations for the library USB HID Class driver
3 *
4 * @note
5 * Copyright(C) NXP Semiconductors, 2012
6 * Copyright(C) Dean Camera, 2011, 2012
7 * All rights reserved.
8 *
9 * @par
10 * Software that is described herein is for illustrative purposes only
11 * which provides customers with programming information regarding the
12 * LPC products. This software is supplied "AS IS" without any warranties of
13 * any kind, and NXP Semiconductors and its licensor disclaim any and
14 * all warranties, express or implied, including all implied warranties of
15 * merchantability, fitness for a particular purpose and non-infringement of
16 * intellectual property rights. NXP Semiconductors assumes no responsibility
17 * or liability for the use of the software, conveys no license or rights under any
18 * patent, copyright, mask work right, or any other intellectual property rights in
19 * or to any products. NXP Semiconductors reserves the right to make changes
20 * in the software without notification. NXP Semiconductors also makes no
21 * representation or warranty that such application will be suitable for the
22 * specified use without further testing or modification.
23 *
24 * @par
25 * Permission to use, copy, modify, and distribute this software and its
26 * documentation is hereby granted, under NXP Semiconductors' and its
27 * licensor's relevant copyrights in the software, without fee, provided that it
28 * is used in conjunction with NXP Semiconductors microcontrollers. This
29 * copyright, permission, and disclaimer notice must appear in all copies of
30 * this code.
31 */
32
43 #ifndef _HID_CLASS_COMMON_H_
44 #define _HID_CLASS_COMMON_H_
45
46 /* Includes: */
47 #include "../../Core/StdDescriptors.h"
48 #include "HIDParser.h"
49
50 /* Enable C linkage for C++ Compilers: */
51 #if defined(__cplusplus)
52 extern "C" {
53 #endif
54
55 /* Preprocessor Checks: */
56 #if !defined(__INCLUDE_FROM_HID_DRIVER)
57 #error Do not include this file directly. Include LPCUSBlib/Drivers/USB.h instead.
58 #endif
59
60 /* Macros: */
64 #define HID_KEYBOARD_MODIFER_LEFTCTRL (1 << 0)
65
67 #define HID_KEYBOARD_MODIFER_LEFTSHIFT (1 << 1)
68
70 #define HID_KEYBOARD_MODIFER_LEFTALT (1 << 2)
71
73 #define HID_KEYBOARD_MODIFER_LEFTGUI (1 << 3)
74
76 #define HID_KEYBOARD_MODIFER_RIGHTCTRL (1 << 4)
77
79 #define HID_KEYBOARD_MODIFER_RIGHTSHIFT (1 << 5)
80
82 #define HID_KEYBOARD_MODIFER_RIGHTALT (1 << 6)
83
85 #define HID_KEYBOARD_MODIFER_RIGHTGUI (1 << 7)
86
87
91 #define HID_KEYBOARD_LED_NUMLOCK (1 << 0)
92
94 #define HID_KEYBOARD_LED_CAPSLOCK (1 << 1)
95
97 #define HID_KEYBOARD_LED_SCROLLLOCK (1 << 2)
98
100 #define HID_KEYBOARD_LED_KATANA (1 << 3)
101
102
105 #define HID_KEYBOARD_SC_ERROR_ROLLOVER 0x01
106 #define HID_KEYBOARD_SC_POST_FAIL 0x02
107 #define HID_KEYBOARD_SC_ERROR_UNDEFINED 0x03
108 #define HID_KEYBOARD_SC_A 0x04
109 #define HID_KEYBOARD_SC_B 0x05
110 #define HID_KEYBOARD_SC_C 0x06
111 #define HID_KEYBOARD_SC_D 0x07
112 #define HID_KEYBOARD_SC_E 0x08
113 #define HID_KEYBOARD_SC_F 0x09
114 #define HID_KEYBOARD_SC_G 0x0A
115 #define HID_KEYBOARD_SC_H 0x0B
116 #define HID_KEYBOARD_SC_I 0x0C
117 #define HID_KEYBOARD_SC_J 0x0D
118 #define HID_KEYBOARD_SC_K 0x0E
119 #define HID_KEYBOARD_SC_L 0x0F
120 #define HID_KEYBOARD_SC_M 0x10
121 #define HID_KEYBOARD_SC_N 0x11
122 #define HID_KEYBOARD_SC_O 0x12
123 #define HID_KEYBOARD_SC_P 0x13
124 #define HID_KEYBOARD_SC_Q 0x14
125 #define HID_KEYBOARD_SC_R 0x15
126 #define HID_KEYBOARD_SC_S 0x16
127 #define HID_KEYBOARD_SC_T 0x17
128 #define HID_KEYBOARD_SC_U 0x18
129 #define HID_KEYBOARD_SC_V 0x19
130 #define HID_KEYBOARD_SC_W 0x1A
131 #define HID_KEYBOARD_SC_X 0x1B
132 #define HID_KEYBOARD_SC_Y 0x1C
133 #define HID_KEYBOARD_SC_Z 0x1D
134 #define HID_KEYBOARD_SC_1_AND_EXCLAMATION 0x1E
135 #define HID_KEYBOARD_SC_2_AND_AT 0x1F
136 #define HID_KEYBOARD_SC_3_AND_HASHMARK 0x20
137 #define HID_KEYBOARD_SC_4_AND_DOLLAR 0x21
138 #define HID_KEYBOARD_SC_5_AND_PERCENTAGE 0x22
139 #define HID_KEYBOARD_SC_6_AND_CARET 0x23
140 #define HID_KEYBOARD_SC_7_AND_AND_AMPERSAND 0x24
141 #define HID_KEYBOARD_SC_8_AND_ASTERISK 0x25
142 #define HID_KEYBOARD_SC_9_AND_OPENING_PARENTHESIS 0x26
143 #define HID_KEYBOARD_SC_0_AND_CLOSING_PARENTHESIS 0x27
144 #define HID_KEYBOARD_SC_ENTER 0x28
145 #define HID_KEYBOARD_SC_ESCAPE 0x29
146 #define HID_KEYBOARD_SC_BACKSPACE 0x2A
147 #define HID_KEYBOARD_SC_TAB 0x2B
148 #define HID_KEYBOARD_SC_SPACE 0x2C
149 #define HID_KEYBOARD_SC_MINUS_AND_UNDERSCORE 0x2D
150 #define HID_KEYBOARD_SC_EQUAL_AND_PLUS 0x2E
151 #define HID_KEYBOARD_SC_OPENING_BRACKET_AND_OPENING_BRACE 0x2F
152 #define HID_KEYBOARD_SC_CLOSING_BRACKET_AND_CLOSING_BRACE 0x30
153 #define HID_KEYBOARD_SC_BACKSLASH_AND_PIPE 0x31
154 #define HID_KEYBOARD_SC_NON_US_HASHMARK_AND_TILDE 0x32
155 #define HID_KEYBOARD_SC_SEMICOLON_AND_COLON 0x33
156 #define HID_KEYBOARD_SC_APOSTROPHE_AND_QUOTE 0x34
157 #define HID_KEYBOARD_SC_GRAVE_ACCENT_AND_TILDE 0x35
158 #define HID_KEYBOARD_SC_COMMA_AND_LESS_THAN_SIGN 0x36
159 #define HID_KEYBOARD_SC_DOT_AND_GREATER_THAN_SIGN 0x37
160 #define HID_KEYBOARD_SC_SLASH_AND_QUESTION_MARK 0x38
161 #define HID_KEYBOARD_SC_CAPS_LOCK 0x39
162 #define HID_KEYBOARD_SC_F1 0x3A
163 #define HID_KEYBOARD_SC_F2 0x3B
164 #define HID_KEYBOARD_SC_F3 0x3C
165 #define HID_KEYBOARD_SC_F4 0x3D
166 #define HID_KEYBOARD_SC_F5 0x3E
167 #define HID_KEYBOARD_SC_F6 0x3F
168 #define HID_KEYBOARD_SC_F7 0x40
169 #define HID_KEYBOARD_SC_F8 0x41
170 #define HID_KEYBOARD_SC_F9 0x42
171 #define HID_KEYBOARD_SC_F10 0x43
172 #define HID_KEYBOARD_SC_F11 0x44
173 #define HID_KEYBOARD_SC_F12 0x45
174 #define HID_KEYBOARD_SC_PRINT_SCREEN 0x46
175 #define HID_KEYBOARD_SC_SCROLL_LOCK 0x47
176 #define HID_KEYBOARD_SC_PAUSE 0x48
177 #define HID_KEYBOARD_SC_INSERT 0x49
178 #define HID_KEYBOARD_SC_HOME 0x4A
179 #define HID_KEYBOARD_SC_PAGE_UP 0x4B
180 #define HID_KEYBOARD_SC_DELETE 0x4C
181 #define HID_KEYBOARD_SC_END 0x4D
182 #define HID_KEYBOARD_SC_PAGE_DOWN 0x4E
183 #define HID_KEYBOARD_SC_RIGHT_ARROW 0x4F
184 #define HID_KEYBOARD_SC_LEFT_ARROW 0x50
185 #define HID_KEYBOARD_SC_DOWN_ARROW 0x51
186 #define HID_KEYBOARD_SC_UP_ARROW 0x52
187 #define HID_KEYBOARD_SC_NUM_LOCK 0x53
188 #define HID_KEYBOARD_SC_KEYPAD_SLASH 0x54
189 #define HID_KEYBOARD_SC_KEYPAD_ASTERISK 0x55
190 #define HID_KEYBOARD_SC_KEYPAD_MINUS 0x56
191 #define HID_KEYBOARD_SC_KEYPAD_PLUS 0x57
192 #define HID_KEYBOARD_SC_KEYPAD_ENTER 0x58
193 #define HID_KEYBOARD_SC_KEYPAD_1_AND_END 0x59
194 #define HID_KEYBOARD_SC_KEYPAD_2_AND_DOWN_ARROW 0x5A
195 #define HID_KEYBOARD_SC_KEYPAD_3_AND_PAGE_DOWN 0x5B
196 #define HID_KEYBOARD_SC_KEYPAD_4_AND_LEFT_ARROW 0x5C
197 #define HID_KEYBOARD_SC_KEYPAD_5 0x5D
198 #define HID_KEYBOARD_SC_KEYPAD_6_AND_RIGHT_ARROW 0x5E
199 #define HID_KEYBOARD_SC_KEYPAD_7_AND_HOME 0x5F
200 #define HID_KEYBOARD_SC_KEYPAD_8_AND_UP_ARROW 0x60
201 #define HID_KEYBOARD_SC_KEYPAD_9_AND_PAGE_UP 0x61
202 #define HID_KEYBOARD_SC_KEYPAD_0_AND_INSERT 0x62
203 #define HID_KEYBOARD_SC_KEYPAD_DOT_AND_DELETE 0x63
204 #define HID_KEYBOARD_SC_NON_US_BACKSLASH_AND_PIPE 0x64
205 #define HID_KEYBOARD_SC_POWER 0x66
206 #define HID_KEYBOARD_SC_EQUAL_SIGN 0x67
207 #define HID_KEYBOARD_SC_F13 0x68
208 #define HID_KEYBOARD_SC_F14 0x69
209 #define HID_KEYBOARD_SC_F15 0x6A
210 #define HID_KEYBOARD_SC_F16 0x6B
211 #define HID_KEYBOARD_SC_F17 0x6C
212 #define HID_KEYBOARD_SC_F18 0x6D
213 #define HID_KEYBOARD_SC_F19 0x6E
214 #define HID_KEYBOARD_SC_F20 0x6F
215 #define HID_KEYBOARD_SC_F21 0x70
216 #define HID_KEYBOARD_SC_F22 0x71
217 #define HID_KEYBOARD_SC_F23 0x72
218 #define HID_KEYBOARD_SC_F24 0x73
219 #define HID_KEYBOARD_SC_EXECUTE 0x74
220 #define HID_KEYBOARD_SC_HELP 0x75
221 #define HID_KEYBOARD_SC_MANU 0x76
222 #define HID_KEYBOARD_SC_SELECT 0x77
223 #define HID_KEYBOARD_SC_STOP 0x78
224 #define HID_KEYBOARD_SC_AGAIN 0x79
225 #define HID_KEYBOARD_SC_UNDO 0x7A
226 #define HID_KEYBOARD_SC_CUT 0x7B
227 #define HID_KEYBOARD_SC_COPY 0x7C
228 #define HID_KEYBOARD_SC_PASTE 0x7D
229 #define HID_KEYBOARD_SC_FIND 0x7E
230 #define HID_KEYBOARD_SC_MUTE 0x7F
231 #define HID_KEYBOARD_SC_VOLUME_UP 0x80
232 #define HID_KEYBOARD_SC_VOLUME_DOWN 0x81
233 #define HID_KEYBOARD_SC_LOCKING_CAPS_LOCK 0x82
234 #define HID_KEYBOARD_SC_LOCKING_NUM_LOCK 0x83
235 #define HID_KEYBOARD_SC_LOCKING_SCROLL_LOCK 0x84
236 #define HID_KEYBOARD_SC_KEYPAD_COMMA 0x85
237 #define HID_KEYBOARD_SC_KEYPAD_EQUAL_SIGN 0x86
238 #define HID_KEYBOARD_SC_INTERNATIONAL1 0x87
239 #define HID_KEYBOARD_SC_INTERNATIONAL2 0x88
240 #define HID_KEYBOARD_SC_INTERNATIONAL3 0x89
241 #define HID_KEYBOARD_SC_INTERNATIONAL4 0x8A
242 #define HID_KEYBOARD_SC_INTERNATIONAL5 0x8B
243 #define HID_KEYBOARD_SC_INTERNATIONAL6 0x8C
244 #define HID_KEYBOARD_SC_INTERNATIONAL7 0x8D
245 #define HID_KEYBOARD_SC_INTERNATIONAL8 0x8E
246 #define HID_KEYBOARD_SC_INTERNATIONAL9 0x8F
247 #define HID_KEYBOARD_SC_LANG1 0x90
248 #define HID_KEYBOARD_SC_LANG2 0x91
249 #define HID_KEYBOARD_SC_LANG3 0x92
250 #define HID_KEYBOARD_SC_LANG4 0x93
251 #define HID_KEYBOARD_SC_LANG5 0x94
252 #define HID_KEYBOARD_SC_LANG6 0x95
253 #define HID_KEYBOARD_SC_LANG7 0x96
254 #define HID_KEYBOARD_SC_LANG8 0x97
255 #define HID_KEYBOARD_SC_LANG9 0x98
256 #define HID_KEYBOARD_SC_ALTERNATE_ERASE 0x99
257 #define HID_KEYBOARD_SC_SISREQ 0x9A
258 #define HID_KEYBOARD_SC_CANCEL 0x9B
259 #define HID_KEYBOARD_SC_CLEAR 0x9C
260 #define HID_KEYBOARD_SC_PRIOR 0x9D
261 #define HID_KEYBOARD_SC_RETURN 0x9E
262 #define HID_KEYBOARD_SC_SEPARATOR 0x9F
263 #define HID_KEYBOARD_SC_OUT 0xA0
264 #define HID_KEYBOARD_SC_OPER 0xA1
265 #define HID_KEYBOARD_SC_CLEAR_AND_AGAIN 0xA2
266 #define HID_KEYBOARD_SC_CRSEL_ANDPROPS 0xA3
267 #define HID_KEYBOARD_SC_EXSEL 0xA4
268 #define HID_KEYBOARD_SC_KEYPAD_00 0xB0
269 #define HID_KEYBOARD_SC_KEYPAD_000 0xB1
270 #define HID_KEYBOARD_SC_THOUSANDS_SEPARATOR 0xB2
271 #define HID_KEYBOARD_SC_DECIMAL_SEPARATOR 0xB3
272 #define HID_KEYBOARD_SC_CURRENCY_UNIT 0xB4
273 #define HID_KEYBOARD_SC_CURRENCY_SUB_UNIT 0xB5
274 #define HID_KEYBOARD_SC_KEYPAD_OPENING_PARENTHESIS 0xB6
275 #define HID_KEYBOARD_SC_KEYPAD_CLOSING_PARENTHESIS 0xB7
276 #define HID_KEYBOARD_SC_KEYPAD_OPENING_BRACE 0xB8
277 #define HID_KEYBOARD_SC_KEYPAD_CLOSING_BRACE 0xB9
278 #define HID_KEYBOARD_SC_KEYPAD_TAB 0xBA
279 #define HID_KEYBOARD_SC_KEYPAD_BACKSPACE 0xBB
280 #define HID_KEYBOARD_SC_KEYPAD_A 0xBC
281 #define HID_KEYBOARD_SC_KEYPAD_B 0xBD
282 #define HID_KEYBOARD_SC_KEYPAD_C 0xBE
283 #define HID_KEYBOARD_SC_KEYPAD_D 0xBF
284 #define HID_KEYBOARD_SC_KEYPAD_E 0xC0
285 #define HID_KEYBOARD_SC_KEYPAD_F 0xC1
286 #define HID_KEYBOARD_SC_KEYPAD_XOR 0xC2
287 #define HID_KEYBOARD_SC_KEYPAD_CARET 0xC3
288 #define HID_KEYBOARD_SC_KEYPAD_PERCENTAGE 0xC4
289 #define HID_KEYBOARD_SC_KEYPAD_LESS_THAN_SIGN 0xC5
290 #define HID_KEYBOARD_SC_KEYPAD_GREATER_THAN_SIGN 0xC6
291 #define HID_KEYBOARD_SC_KEYPAD_AMP 0xC7
292 #define HID_KEYBOARD_SC_KEYPAD_AMP_AMP 0xC8
293 #define HID_KEYBOARD_SC_KEYPAD_PIPE 0xC9
294 #define HID_KEYBOARD_SC_KEYPAD_PIPE_PIPE 0xCA
295 #define HID_KEYBOARD_SC_KEYPAD_COLON 0xCB
296 #define HID_KEYBOARD_SC_KEYPAD_HASHMARK 0xCC
297 #define HID_KEYBOARD_SC_KEYPAD_SPACE 0xCD
298 #define HID_KEYBOARD_SC_KEYPAD_AT 0xCE
299 #define HID_KEYBOARD_SC_KEYPAD_EXCLAMATION_SIGN 0xCF
300 #define HID_KEYBOARD_SC_KEYPAD_MEMORY_STORE 0xD0
301 #define HID_KEYBOARD_SC_KEYPAD_MEMORY_RECALL 0xD1
302 #define HID_KEYBOARD_SC_KEYPAD_MEMORY_CLEAR 0xD2
303 #define HID_KEYBOARD_SC_KEYPAD_MEMORY_ADD 0xD3
304 #define HID_KEYBOARD_SC_KEYPAD_MEMORY_SUBTRACT 0xD4
305 #define HID_KEYBOARD_SC_KEYPAD_MEMORY_MULTIPLY 0xD5
306 #define HID_KEYBOARD_SC_KEYPAD_MEMORY_DIVIDE 0xD6
307 #define HID_KEYBOARD_SC_KEYPAD_PLUS_AND_MINUS 0xD7
308 #define HID_KEYBOARD_SC_KEYPAD_CLEAR 0xD8
309 #define HID_KEYBOARD_SC_KEYPAD_CLEAR_ENTRY 0xD9
310 #define HID_KEYBOARD_SC_KEYPAD_BINARY 0xDA
311 #define HID_KEYBOARD_SC_KEYPAD_OCTAL 0xDB
312 #define HID_KEYBOARD_SC_KEYPAD_DECIMAL 0xDC
313 #define HID_KEYBOARD_SC_KEYPAD_HEXADECIMAL 0xDD
314 #define HID_KEYBOARD_SC_LEFT_CONTROL 0xE0
315 #define HID_KEYBOARD_SC_LEFT_SHIFT 0xE1
316 #define HID_KEYBOARD_SC_LEFT_ALT 0xE2
317 #define HID_KEYBOARD_SC_LEFT_GUI 0xE3
318 #define HID_KEYBOARD_SC_RIGHT_CONTROL 0xE4
319 #define HID_KEYBOARD_SC_RIGHT_SHIFT 0xE5
320 #define HID_KEYBOARD_SC_RIGHT_ALT 0xE6
321 #define HID_KEYBOARD_SC_RIGHT_GUI 0xE7
322
323
351 #define HID_DESCRIPTOR_JOYSTICK(NumAxis, MinAxisVal, MaxAxisVal, MinPhysicalVal, MaxPhysicalVal, Buttons) \
352 HID_RI_USAGE_PAGE(8, 0x01), \
353 HID_RI_USAGE(8, 0x04), \
354 HID_RI_COLLECTION(8, 0x01), \
355 HID_RI_USAGE(8, 0x01), \
356 HID_RI_COLLECTION(8, 0x00), \
357 HID_RI_USAGE_MINIMUM(8, 0x30), \
358 HID_RI_USAGE_MAXIMUM(8, (0x30 + (NumAxis - 1))), \
359 HID_RI_LOGICAL_MINIMUM(16, MinAxisVal), \
360 HID_RI_LOGICAL_MAXIMUM(16, MaxAxisVal), \
361 HID_RI_PHYSICAL_MINIMUM(16, MinPhysicalVal), \
362 HID_RI_PHYSICAL_MAXIMUM(16, MaxPhysicalVal), \
363 HID_RI_REPORT_COUNT(8, NumAxis), \
364 HID_RI_REPORT_SIZE(8, ((((MinAxisVal >= -0xFF) && (MaxAxisVal <= 0xFF)) ? 8 : 16))), \
365 HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE), \
366 HID_RI_END_COLLECTION(0), \
367 HID_RI_USAGE_PAGE(8, 0x09), \
368 HID_RI_USAGE_MINIMUM(8, 0x01), \
369 HID_RI_USAGE_MAXIMUM(8, Buttons), \
370 HID_RI_LOGICAL_MINIMUM(8, 0x00), \
371 HID_RI_LOGICAL_MAXIMUM(8, 0x01), \
372 HID_RI_REPORT_SIZE(8, 0x01), \
373 HID_RI_REPORT_COUNT(8, Buttons), \
374 HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE), \
375 HID_RI_REPORT_SIZE(8, (8 - (Buttons % 8))), \
376 HID_RI_REPORT_COUNT(8, 0x01), \
377 HID_RI_INPUT(8, HID_IOF_CONSTANT), \
378 HID_RI_END_COLLECTION(0)
379
396 #define HID_DESCRIPTOR_KEYBOARD(MaxKeys) \
397 HID_RI_USAGE_PAGE(8, 0x01), \
398 HID_RI_USAGE(8, 0x06), \
399 HID_RI_COLLECTION(8, 0x01), \
400 HID_RI_USAGE_PAGE(8, 0x07), \
401 HID_RI_USAGE_MINIMUM(8, 0xE0), \
402 HID_RI_USAGE_MAXIMUM(8, 0xE7), \
403 HID_RI_LOGICAL_MINIMUM(8, 0x00), \
404 HID_RI_LOGICAL_MAXIMUM(8, 0x01), \
405 HID_RI_REPORT_SIZE(8, 0x01), \
406 HID_RI_REPORT_COUNT(8, 0x08), \
407 HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE), \
408 HID_RI_REPORT_COUNT(8, 0x01), \
409 HID_RI_REPORT_SIZE(8, 0x08), \
410 HID_RI_INPUT(8, HID_IOF_CONSTANT), \
411 HID_RI_USAGE_PAGE(8, 0x08), \
412 HID_RI_USAGE_MINIMUM(8, 0x01), \
413 HID_RI_USAGE_MAXIMUM(8, 0x05), \
414 HID_RI_REPORT_COUNT(8, 0x05), \
415 HID_RI_REPORT_SIZE(8, 0x01), \
416 HID_RI_OUTPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE | HID_IOF_NON_VOLATILE), \
417 HID_RI_REPORT_COUNT(8, 0x01), \
418 HID_RI_REPORT_SIZE(8, 0x03), \
419 HID_RI_OUTPUT(8, HID_IOF_CONSTANT), \
420 HID_RI_LOGICAL_MINIMUM(8, 0x00), \
421 HID_RI_LOGICAL_MAXIMUM(8, 0x65), \
422 HID_RI_USAGE_PAGE(8, 0x07), \
423 HID_RI_USAGE_MINIMUM(8, 0x00), \
424 HID_RI_USAGE_MAXIMUM(8, 0x65), \
425 HID_RI_REPORT_COUNT(8, MaxKeys), \
426 HID_RI_REPORT_SIZE(8, 0x08), \
427 HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_ARRAY | HID_IOF_ABSOLUTE), \
428 HID_RI_END_COLLECTION(0)
429
454 #define HID_DESCRIPTOR_MOUSE(MinAxisVal, MaxAxisVal, MinPhysicalVal, MaxPhysicalVal, Buttons, AbsoluteCoords) \
455 HID_RI_USAGE_PAGE(8, 0x01), \
456 HID_RI_USAGE(8, 0x02), \
457 HID_RI_COLLECTION(8, 0x01), \
458 HID_RI_USAGE(8, 0x01), \
459 HID_RI_COLLECTION(8, 0x00), \
460 HID_RI_USAGE_PAGE(8, 0x09), \
461 HID_RI_USAGE_MINIMUM(8, 0x01), \
462 HID_RI_USAGE_MAXIMUM(8, Buttons), \
463 HID_RI_LOGICAL_MINIMUM(8, 0x00), \
464 HID_RI_LOGICAL_MAXIMUM(8, 0x01), \
465 HID_RI_REPORT_COUNT(8, Buttons), \
466 HID_RI_REPORT_SIZE(8, 0x01), \
467 HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE), \
468 HID_RI_REPORT_COUNT(8, 0x01), \
469 HID_RI_REPORT_SIZE(8, (8 - (Buttons % 8))), \
470 HID_RI_INPUT(8, HID_IOF_CONSTANT), \
471 HID_RI_USAGE_PAGE(8, 0x01), \
472 HID_RI_USAGE(8, 0x30), \
473 HID_RI_USAGE(8, 0x31), \
474 HID_RI_LOGICAL_MINIMUM(16, MinAxisVal), \
475 HID_RI_LOGICAL_MAXIMUM(16, MaxAxisVal), \
476 HID_RI_PHYSICAL_MINIMUM(16, MinPhysicalVal), \
477 HID_RI_PHYSICAL_MAXIMUM(16, MaxPhysicalVal), \
478 HID_RI_REPORT_COUNT(8, 0x02), \
479 HID_RI_REPORT_SIZE(8, ((((MinAxisVal >= -0xFF) && (MaxAxisVal <= 0xFF)) ? 8 : 16))), \
480 HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | (AbsoluteCoords ? HID_IOF_ABSOLUTE : HID_IOF_RELATIVE)), \
481 HID_RI_END_COLLECTION(0), \
482 HID_RI_END_COLLECTION(0)
483
495 #define HID_DESCRIPTOR_VENDOR(VendorPageNum, CollectionUsage, DataINUsage, DataOUTUsage, NumBytes) \
496 HID_RI_USAGE_PAGE(16, (0xFF00 | VendorPageNum)), \
497 HID_RI_USAGE(8, CollectionUsage), \
498 HID_RI_COLLECTION(8, 0x01), \
499 HID_RI_USAGE(8, DataINUsage), \
500 HID_RI_LOGICAL_MINIMUM(8, 0x00), \
501 HID_RI_LOGICAL_MAXIMUM(8, 0xFF), \
502 HID_RI_REPORT_SIZE(8, 0x08), \
503 HID_RI_REPORT_COUNT(8, NumBytes), \
504 HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE), \
505 HID_RI_USAGE(8, DataOUTUsage), \
506 HID_RI_LOGICAL_MINIMUM(8, 0x00), \
507 HID_RI_LOGICAL_MAXIMUM(8, 0xFF), \
508 HID_RI_REPORT_SIZE(8, 0x08), \
509 HID_RI_REPORT_COUNT(8, NumBytes), \
510 HID_RI_OUTPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE | HID_IOF_NON_VOLATILE), \
511 HID_RI_END_COLLECTION(0)
512
513
514 /* Type Defines: */
518 enum HID_Descriptor_ClassSubclassProtocol_t
519 {
520 HID_CSCP_HIDClass = 0x03,
523 HID_CSCP_NonBootSubclass = 0x00,
526 HID_CSCP_BootSubclass = 0x01,
529 HID_CSCP_NonBootProtocol = 0x00,
532 HID_CSCP_KeyboardBootProtocol = 0x01,
535 HID_CSCP_MouseBootProtocol = 0x02,
538 };
539
541 enum HID_ClassRequests_t
542 {
543 HID_REQ_GetReport = 0x01,
544 HID_REQ_GetIdle = 0x02,
545 HID_REQ_GetProtocol = 0x03,
546 HID_REQ_SetReport = 0x09,
547 HID_REQ_SetIdle = 0x0A,
548 HID_REQ_SetProtocol = 0x0B,
549 };
550
552 enum HID_DescriptorTypes_t
553 {
554 HID_DTYPE_HID = 0x21,
555 HID_DTYPE_Report = 0x22,
556 };
557
559 enum HID_ReportItemTypes_t
560 {
561 HID_REPORT_ITEM_In = 0,
562 HID_REPORT_ITEM_Out = 1,
563 HID_REPORT_ITEM_Feature = 2,
564 };
565
575 typedef ATTR_IAR_PACKED struct
576 {
577 USB_Descriptor_Header_t Header;
579 uint16_t HIDSpec;
580 uint8_t CountryCode;
582 uint8_t TotalReportDescriptors;
584 uint8_t HIDReportType;
585 uint16_t HIDReportLength;
586 } ATTR_PACKED USB_HID_Descriptor_HID_t;
587
598 typedef ATTR_IAR_PACKED struct
599 {
600 uint8_t bLength;
601 uint8_t bDescriptorType;
605 uint16_t bcdHID;
606 uint8_t bCountryCode;
608 uint8_t bNumDescriptors;
610 uint8_t bDescriptorType2;
611 uint16_t wDescriptorLength;
612 } ATTR_PACKED USB_HID_StdDescriptor_HID_t;
613
618 typedef ATTR_IAR_PACKED struct
619 {
620 uint8_t Button;
621 int8_t X;
622 int8_t Y;
623 } ATTR_PACKED USB_MouseReport_Data_t;
624
629 typedef ATTR_IAR_PACKED struct
630 {
631 uint8_t Modifier;
634 uint8_t Reserved;
635 uint8_t KeyCode[6];
636 } ATTR_PACKED USB_KeyboardReport_Data_t;
637
639 typedef uint8_t USB_Descriptor_HIDReport_Datatype_t;
640
641 /* Disable C linkage for C++ Compilers: */
642 #if defined(__cplusplus)
643 }
644 #endif
645
646 #endif
647