initial commit
[armstart-ibdap] / inc / usbd / usbd_hid.h
1 /***********************************************************************\r
2 * $Id: mw_usbd_hid.h.rca 1.2 Tue Nov  1 11:45:07 2011 nlv09221 Experimental $\r
3 *\r
4 * Project: USB device ROM Stack\r
5 *\r
6 * Description:\r
7 *     HID Definitions.\r
8 *\r
9 ***********************************************************************\r
10 *   Copyright(C) 2011, NXP Semiconductor\r
11 *   All rights reserved.\r
12 *\r
13 * Software that is described herein is for illustrative purposes only\r
14 * which provides customers with programming information regarding the\r
15 * products. This software is supplied "AS IS" without any warranties.\r
16 * NXP Semiconductors assumes no responsibility or liability for the\r
17 * use of the software, conveys no license or title under any patent,\r
18 * copyright, or mask work right to the product. NXP Semiconductors\r
19 * reserves the right to make changes in the software without\r
20 * notification. NXP Semiconductors also make no representation or\r
21 * warranty that such application will be suitable for the specified\r
22 * use without further testing or modification.\r
23 **********************************************************************/\r
24 #ifndef __HID_H__\r
25 #define __HID_H__\r
26 \r
27 #include "usbd.h"\r
28 \r
29 /** \file\r
30  *  \brief Common definitions and declarations for the library USB HID Class driver.\r
31  *\r
32  *  Common definitions and declarations for the library USB HID Class driver.\r
33  *  \addtogroup USBD_HID \r
34  *  @{\r
35  */\r
36 \r
37 \r
38 /** HID Subclass Codes  \r
39  * @{ \r
40  */\r
41 /** Descriptor Subclass value indicating that the device or interface does not implement a HID boot protocol. */\r
42 #define HID_SUBCLASS_NONE               0x00\r
43 /** Descriptor Subclass value indicating that the device or interface implements a HID boot protocol. */\r
44 #define HID_SUBCLASS_BOOT               0x01\r
45 /** @} */\r
46 \r
47 /** HID Protocol Codes \r
48  * @{ \r
49  */\r
50 /** Descriptor Protocol value indicating that the device or interface does not belong to a HID boot protocol. */\r
51 #define HID_PROTOCOL_NONE               0x00\r
52 /** Descriptor Protocol value indicating that the device or interface belongs to the Keyboard HID boot protocol. */\r
53 #define HID_PROTOCOL_KEYBOARD           0x01\r
54 /** Descriptor Protocol value indicating that the device or interface belongs to the Mouse HID boot protocol. */\r
55 #define HID_PROTOCOL_MOUSE              0x02\r
56 /** @} */\r
57 \r
58 \r
59 \r
60 /** Descriptor Types  \r
61  * @{ \r
62  */\r
63 /** Descriptor header type value, to indicate a HID class HID descriptor. */\r
64 #define HID_HID_DESCRIPTOR_TYPE         0x21\r
65 /** Descriptor header type value, to indicate a HID class HID report descriptor. */\r
66 #define HID_REPORT_DESCRIPTOR_TYPE      0x22\r
67 /** Descriptor header type value, to indicate a HID class HID Physical descriptor. */\r
68 #define HID_PHYSICAL_DESCRIPTOR_TYPE    0x23\r
69 /** @} */\r
70 \r
71 \r
72 /** \brief HID class-specific HID Descriptor.\r
73  *\r
74  *  Type define for the HID class-specific HID descriptor, to describe the HID device's specifications. Refer to the HID\r
75  *  specification for details on the structure elements.\r
76  *\r
77  */\r
78 PRE_PACK struct POST_PACK _HID_DESCRIPTOR {\r
79   uint8_t  bLength;     /**< Size of the descriptor, in bytes. */\r
80   uint8_t  bDescriptorType;     /**< Type of HID descriptor. */\r
81   uint16_t bcdHID; /**< BCD encoded version that the HID descriptor and device complies to. */\r
82   uint8_t  bCountryCode; /**< Country code of the localized device, or zero if universal. */\r
83   uint8_t  bNumDescriptors; /**< Total number of HID report descriptors for the interface. */\r
84   \r
85   PRE_PACK struct POST_PACK _HID_DESCRIPTOR_LIST {\r
86     uint8_t  bDescriptorType; /**< Type of HID report. */\r
87     uint16_t wDescriptorLength; /**< Length of the associated HID report descriptor, in bytes. */\r
88   } DescriptorList[1]; /**< Array of one or more descriptors */\r
89 } ;\r
90 /** HID class-specific HID Descriptor. */\r
91 typedef struct _HID_DESCRIPTOR HID_DESCRIPTOR;\r
92 \r
93 #define HID_DESC_SIZE   sizeof(HID_DESCRIPTOR)\r
94 \r
95 /** HID Request Codes  \r
96  * @{ \r
97  */\r
98 #define HID_REQUEST_GET_REPORT          0x01\r
99 #define HID_REQUEST_GET_IDLE            0x02\r
100 #define HID_REQUEST_GET_PROTOCOL        0x03\r
101 #define HID_REQUEST_SET_REPORT          0x09\r
102 #define HID_REQUEST_SET_IDLE            0x0A\r
103 #define HID_REQUEST_SET_PROTOCOL        0x0B\r
104 /** @} */\r
105 \r
106 /** HID Report Types  \r
107  * @{ \r
108  */\r
109 #define HID_REPORT_INPUT                0x01\r
110 #define HID_REPORT_OUTPUT               0x02\r
111 #define HID_REPORT_FEATURE              0x03\r
112 /** @} */\r
113 \r
114 \r
115 /** Usage Pages  \r
116  * @{ \r
117  */\r
118 #define HID_USAGE_PAGE_UNDEFINED        0x00\r
119 #define HID_USAGE_PAGE_GENERIC          0x01\r
120 #define HID_USAGE_PAGE_SIMULATION       0x02\r
121 #define HID_USAGE_PAGE_VR               0x03\r
122 #define HID_USAGE_PAGE_SPORT            0x04\r
123 #define HID_USAGE_PAGE_GAME             0x05\r
124 #define HID_USAGE_PAGE_DEV_CONTROLS     0x06\r
125 #define HID_USAGE_PAGE_KEYBOARD         0x07\r
126 #define HID_USAGE_PAGE_LED              0x08\r
127 #define HID_USAGE_PAGE_BUTTON           0x09\r
128 #define HID_USAGE_PAGE_ORDINAL          0x0A\r
129 #define HID_USAGE_PAGE_TELEPHONY        0x0B\r
130 #define HID_USAGE_PAGE_CONSUMER         0x0C\r
131 #define HID_USAGE_PAGE_DIGITIZER        0x0D\r
132 #define HID_USAGE_PAGE_UNICODE          0x10\r
133 #define HID_USAGE_PAGE_ALPHANUMERIC     0x14\r
134 /** @} */\r
135 \r
136 \r
137 /** Generic Desktop Page (0x01)  \r
138  * @{ \r
139  */\r
140 #define HID_USAGE_GENERIC_POINTER               0x01\r
141 #define HID_USAGE_GENERIC_MOUSE                 0x02\r
142 #define HID_USAGE_GENERIC_JOYSTICK              0x04\r
143 #define HID_USAGE_GENERIC_GAMEPAD               0x05\r
144 #define HID_USAGE_GENERIC_KEYBOARD              0x06\r
145 #define HID_USAGE_GENERIC_KEYPAD                0x07\r
146 #define HID_USAGE_GENERIC_X                     0x30\r
147 #define HID_USAGE_GENERIC_Y                     0x31\r
148 #define HID_USAGE_GENERIC_Z                     0x32\r
149 #define HID_USAGE_GENERIC_RX                    0x33\r
150 #define HID_USAGE_GENERIC_RY                    0x34\r
151 #define HID_USAGE_GENERIC_RZ                    0x35\r
152 #define HID_USAGE_GENERIC_SLIDER                0x36\r
153 #define HID_USAGE_GENERIC_DIAL                  0x37\r
154 #define HID_USAGE_GENERIC_WHEEL                 0x38\r
155 #define HID_USAGE_GENERIC_HATSWITCH             0x39\r
156 #define HID_USAGE_GENERIC_COUNTED_BUFFER        0x3A\r
157 #define HID_USAGE_GENERIC_BYTE_COUNT            0x3B\r
158 #define HID_USAGE_GENERIC_MOTION_WAKEUP         0x3C\r
159 #define HID_USAGE_GENERIC_VX                    0x40\r
160 #define HID_USAGE_GENERIC_VY                    0x41\r
161 #define HID_USAGE_GENERIC_VZ                    0x42\r
162 #define HID_USAGE_GENERIC_VBRX                  0x43\r
163 #define HID_USAGE_GENERIC_VBRY                  0x44\r
164 #define HID_USAGE_GENERIC_VBRZ                  0x45\r
165 #define HID_USAGE_GENERIC_VNO                   0x46\r
166 #define HID_USAGE_GENERIC_SYSTEM_CTL            0x80\r
167 #define HID_USAGE_GENERIC_SYSCTL_POWER          0x81\r
168 #define HID_USAGE_GENERIC_SYSCTL_SLEEP          0x82\r
169 #define HID_USAGE_GENERIC_SYSCTL_WAKE           0x83\r
170 #define HID_USAGE_GENERIC_SYSCTL_CONTEXT_MENU   0x84\r
171 #define HID_USAGE_GENERIC_SYSCTL_MAIN_MENU      0x85\r
172 #define HID_USAGE_GENERIC_SYSCTL_APP_MENU       0x86\r
173 #define HID_USAGE_GENERIC_SYSCTL_HELP_MENU      0x87\r
174 #define HID_USAGE_GENERIC_SYSCTL_MENU_EXIT      0x88\r
175 #define HID_USAGE_GENERIC_SYSCTL_MENU_SELECT    0x89\r
176 #define HID_USAGE_GENERIC_SYSCTL_MENU_RIGHT     0x8A\r
177 #define HID_USAGE_GENERIC_SYSCTL_MENU_LEFT      0x8B\r
178 #define HID_USAGE_GENERIC_SYSCTL_MENU_UP        0x8C\r
179 #define HID_USAGE_GENERIC_SYSCTL_MENU_DOWN      0x8D\r
180 /** @} */\r
181 \r
182 /** Simulation Controls Page (0x02)  \r
183  * @{ \r
184  */\r
185 #define HID_USAGE_SIMULATION_RUDDER             0xBA\r
186 #define HID_USAGE_SIMULATION_THROTTLE           0xBB\r
187 /** @} */\r
188 \r
189 /* Virtual Reality Controls Page (0x03) */\r
190 /* ... */\r
191 \r
192 /* Sport Controls Page (0x04) */\r
193 /* ... */\r
194 \r
195 /* Game Controls Page (0x05) */\r
196 /* ... */\r
197 \r
198 /* Generic Device Controls Page (0x06) */\r
199 /* ... */\r
200 \r
201 /** Keyboard/Keypad Page (0x07)  \r
202  * @{ \r
203  */\r
204 /** Error "keys" */\r
205 #define HID_USAGE_KEYBOARD_NOEVENT              0x00\r
206 #define HID_USAGE_KEYBOARD_ROLLOVER             0x01\r
207 #define HID_USAGE_KEYBOARD_POSTFAIL             0x02\r
208 #define HID_USAGE_KEYBOARD_UNDEFINED            0x03\r
209 \r
210 /** Letters */\r
211 #define HID_USAGE_KEYBOARD_aA                   0x04\r
212 #define HID_USAGE_KEYBOARD_zZ                   0x1D\r
213 \r
214 /** Numbers */\r
215 #define HID_USAGE_KEYBOARD_ONE                  0x1E\r
216 #define HID_USAGE_KEYBOARD_ZERO                 0x27\r
217 \r
218 #define HID_USAGE_KEYBOARD_RETURN               0x28\r
219 #define HID_USAGE_KEYBOARD_ESCAPE               0x29\r
220 #define HID_USAGE_KEYBOARD_DELETE               0x2A\r
221 \r
222 /** Funtion keys */\r
223 #define HID_USAGE_KEYBOARD_F1                   0x3A\r
224 #define HID_USAGE_KEYBOARD_F12                  0x45\r
225 \r
226 #define HID_USAGE_KEYBOARD_PRINT_SCREEN         0x46\r
227 \r
228 /** Modifier Keys */\r
229 #define HID_USAGE_KEYBOARD_LCTRL                0xE0\r
230 #define HID_USAGE_KEYBOARD_LSHFT                0xE1\r
231 #define HID_USAGE_KEYBOARD_LALT                 0xE2\r
232 #define HID_USAGE_KEYBOARD_LGUI                 0xE3\r
233 #define HID_USAGE_KEYBOARD_RCTRL                0xE4\r
234 #define HID_USAGE_KEYBOARD_RSHFT                0xE5\r
235 #define HID_USAGE_KEYBOARD_RALT                 0xE6\r
236 #define HID_USAGE_KEYBOARD_RGUI                 0xE7\r
237 #define HID_USAGE_KEYBOARD_SCROLL_LOCK          0x47\r
238 #define HID_USAGE_KEYBOARD_NUM_LOCK             0x53\r
239 #define HID_USAGE_KEYBOARD_CAPS_LOCK            0x39\r
240 /** @} */\r
241 \r
242 /* ... */\r
243 \r
244 /** LED Page (0x08)  \r
245  * @{ \r
246  */\r
247 #define HID_USAGE_LED_NUM_LOCK                  0x01\r
248 #define HID_USAGE_LED_CAPS_LOCK                 0x02\r
249 #define HID_USAGE_LED_SCROLL_LOCK               0x03\r
250 #define HID_USAGE_LED_COMPOSE                   0x04\r
251 #define HID_USAGE_LED_KANA                      0x05\r
252 #define HID_USAGE_LED_POWER                     0x06\r
253 #define HID_USAGE_LED_SHIFT                     0x07\r
254 #define HID_USAGE_LED_DO_NOT_DISTURB            0x08\r
255 #define HID_USAGE_LED_MUTE                      0x09\r
256 #define HID_USAGE_LED_TONE_ENABLE               0x0A\r
257 #define HID_USAGE_LED_HIGH_CUT_FILTER           0x0B\r
258 #define HID_USAGE_LED_LOW_CUT_FILTER            0x0C\r
259 #define HID_USAGE_LED_EQUALIZER_ENABLE          0x0D\r
260 #define HID_USAGE_LED_SOUND_FIELD_ON            0x0E\r
261 #define HID_USAGE_LED_SURROUND_FIELD_ON         0x0F\r
262 #define HID_USAGE_LED_REPEAT                    0x10\r
263 #define HID_USAGE_LED_STEREO                    0x11\r
264 #define HID_USAGE_LED_SAMPLING_RATE_DETECT      0x12\r
265 #define HID_USAGE_LED_SPINNING                  0x13\r
266 #define HID_USAGE_LED_CAV                       0x14\r
267 #define HID_USAGE_LED_CLV                       0x15\r
268 #define HID_USAGE_LED_RECORDING_FORMAT_DET      0x16\r
269 #define HID_USAGE_LED_OFF_HOOK                  0x17\r
270 #define HID_USAGE_LED_RING                      0x18\r
271 #define HID_USAGE_LED_MESSAGE_WAITING           0x19\r
272 #define HID_USAGE_LED_DATA_MODE                 0x1A\r
273 #define HID_USAGE_LED_BATTERY_OPERATION         0x1B\r
274 #define HID_USAGE_LED_BATTERY_OK                0x1C\r
275 #define HID_USAGE_LED_BATTERY_LOW               0x1D\r
276 #define HID_USAGE_LED_SPEAKER                   0x1E\r
277 #define HID_USAGE_LED_HEAD_SET                  0x1F\r
278 #define HID_USAGE_LED_HOLD                      0x20\r
279 #define HID_USAGE_LED_MICROPHONE                0x21\r
280 #define HID_USAGE_LED_COVERAGE                  0x22\r
281 #define HID_USAGE_LED_NIGHT_MODE                0x23\r
282 #define HID_USAGE_LED_SEND_CALLS                0x24\r
283 #define HID_USAGE_LED_CALL_PICKUP               0x25\r
284 #define HID_USAGE_LED_CONFERENCE                0x26\r
285 #define HID_USAGE_LED_STAND_BY                  0x27\r
286 #define HID_USAGE_LED_CAMERA_ON                 0x28\r
287 #define HID_USAGE_LED_CAMERA_OFF                0x29\r
288 #define HID_USAGE_LED_ON_LINE                   0x2A\r
289 #define HID_USAGE_LED_OFF_LINE                  0x2B\r
290 #define HID_USAGE_LED_BUSY                      0x2C\r
291 #define HID_USAGE_LED_READY                     0x2D\r
292 #define HID_USAGE_LED_PAPER_OUT                 0x2E\r
293 #define HID_USAGE_LED_PAPER_JAM                 0x2F\r
294 #define HID_USAGE_LED_REMOTE                    0x30\r
295 #define HID_USAGE_LED_FORWARD                   0x31\r
296 #define HID_USAGE_LED_REVERSE                   0x32\r
297 #define HID_USAGE_LED_STOP                      0x33\r
298 #define HID_USAGE_LED_REWIND                    0x34\r
299 #define HID_USAGE_LED_FAST_FORWARD              0x35\r
300 #define HID_USAGE_LED_PLAY                      0x36\r
301 #define HID_USAGE_LED_PAUSE                     0x37\r
302 #define HID_USAGE_LED_RECORD                    0x38\r
303 #define HID_USAGE_LED_ERROR                     0x39\r
304 #define HID_USAGE_LED_SELECTED_INDICATOR        0x3A\r
305 #define HID_USAGE_LED_IN_USE_INDICATOR          0x3B\r
306 #define HID_USAGE_LED_MULTI_MODE_INDICATOR      0x3C\r
307 #define HID_USAGE_LED_INDICATOR_ON              0x3D\r
308 #define HID_USAGE_LED_INDICATOR_FLASH           0x3E\r
309 #define HID_USAGE_LED_INDICATOR_SLOW_BLINK      0x3F\r
310 #define HID_USAGE_LED_INDICATOR_FAST_BLINK      0x40\r
311 #define HID_USAGE_LED_INDICATOR_OFF             0x41\r
312 #define HID_USAGE_LED_FLASH_ON_TIME             0x42\r
313 #define HID_USAGE_LED_SLOW_BLINK_ON_TIME        0x43\r
314 #define HID_USAGE_LED_SLOW_BLINK_OFF_TIME       0x44\r
315 #define HID_USAGE_LED_FAST_BLINK_ON_TIME        0x45\r
316 #define HID_USAGE_LED_FAST_BLINK_OFF_TIME       0x46\r
317 #define HID_USAGE_LED_INDICATOR_COLOR           0x47\r
318 #define HID_USAGE_LED_RED                       0x48\r
319 #define HID_USAGE_LED_GREEN                     0x49\r
320 #define HID_USAGE_LED_AMBER                     0x4A\r
321 #define HID_USAGE_LED_GENERIC_INDICATOR         0x4B\r
322 /** @} */\r
323 \r
324 /*  Button Page (0x09)  \r
325  */\r
326 /*   There is no need to label these usages. */\r
327 \r
328 /*  Ordinal Page (0x0A)  \r
329  */\r
330 /*   There is no need to label these usages. */\r
331 \r
332 /** Telephony Device Page (0x0B)  \r
333  * @{ \r
334  */\r
335 #define HID_USAGE_TELEPHONY_PHONE               0x01\r
336 #define HID_USAGE_TELEPHONY_ANSWERING_MACHINE   0x02\r
337 #define HID_USAGE_TELEPHONY_MESSAGE_CONTROLS    0x03\r
338 #define HID_USAGE_TELEPHONY_HANDSET             0x04\r
339 #define HID_USAGE_TELEPHONY_HEADSET             0x05\r
340 #define HID_USAGE_TELEPHONY_KEYPAD              0x06\r
341 #define HID_USAGE_TELEPHONY_PROGRAMMABLE_BUTTON 0x07\r
342 /** @} */\r
343 /* ... */\r
344 \r
345 /** Consumer Page (0x0C)  \r
346  * @{ \r
347  */\r
348 #define HID_USAGE_CONSUMER_CONTROL              0x01\r
349 #define HID_USAGE_CONSUMER_FAST_FORWARD       0xB3\r
350 #define HID_USAGE_CONSUMER_REWIND             0xB4\r
351 #define HID_USAGE_CONSUMER_PLAY_PAUSE                       0xCD\r
352 #define HID_USAGE_CONSUMER_VOLUME_INCREMENT             0xE9\r
353 #define HID_USAGE_CONSUMER_VOLUME_DECREMENT             0xEA\r
354 /** @} */\r
355 /* ... */\r
356 \r
357 /* and others ... */\r
358 \r
359 \r
360 /** HID Report Item Macros  \r
361  * @{ \r
362  */\r
363 /** Main Items */\r
364 #define HID_Input(x)           0x81,x\r
365 #define HID_Output(x)          0x91,x\r
366 #define HID_Feature(x)         0xB1,x\r
367 #define HID_Collection(x)      0xA1,x\r
368 #define HID_EndCollection      0xC0\r
369 \r
370 /** Data (Input, Output, Feature) */\r
371 #define HID_Data               0<<0\r
372 #define HID_Constant           1<<0\r
373 #define HID_Array              0<<1\r
374 #define HID_Variable           1<<1\r
375 #define HID_Absolute           0<<2\r
376 #define HID_Relative           1<<2\r
377 #define HID_NoWrap             0<<3\r
378 #define HID_Wrap               1<<3\r
379 #define HID_Linear             0<<4\r
380 #define HID_NonLinear          1<<4\r
381 #define HID_PreferredState     0<<5\r
382 #define HID_NoPreferred        1<<5\r
383 #define HID_NoNullPosition     0<<6\r
384 #define HID_NullState          1<<6\r
385 #define HID_NonVolatile        0<<7\r
386 #define HID_Volatile           1<<7\r
387 \r
388 /** Collection Data */\r
389 #define HID_Physical           0x00\r
390 #define HID_Application        0x01\r
391 #define HID_Logical            0x02\r
392 #define HID_Report             0x03\r
393 #define HID_NamedArray         0x04\r
394 #define HID_UsageSwitch        0x05\r
395 #define HID_UsageModifier      0x06\r
396 \r
397 /** Global Items */\r
398 #define HID_UsagePage(x)       0x05,x\r
399 #define HID_UsagePageVendor(x) 0x06,x,0xFF\r
400 #define HID_LogicalMin(x)      0x15,x\r
401 #define HID_LogicalMinS(x)     0x16,(x&0xFF),((x>>8)&0xFF)\r
402 #define HID_LogicalMinL(x)     0x17,(x&0xFF),((x>>8)&0xFF),((x>>16)&0xFF),((x>>24)&0xFF)\r
403 #define HID_LogicalMax(x)      0x25,x\r
404 #define HID_LogicalMaxS(x)     0x26,(x&0xFF),((x>>8)&0xFF)\r
405 #define HID_LogicalMaxL(x)     0x27,(x&0xFF),((x>>8)&0xFF),((x>>16)&0xFF),((x>>24)&0xFF)\r
406 #define HID_PhysicalMin(x)     0x35,x\r
407 #define HID_PhysicalMinS(x)    0x36,(x&0xFF),((x>>8)&0xFF)\r
408 #define HID_PhysicalMinL(x)    0x37,(x&0xFF),((x>>8)&0xFF),((x>>16)&0xFF),((x>>24)&0xFF)\r
409 #define HID_PhysicalMax(x)     0x45,x\r
410 #define HID_PhysicalMaxS(x)    0x46,(x&0xFF),((x>>8)&0xFF)\r
411 #define HID_PhysicalMaxL(x)    0x47,(x&0xFF),((x>>8)&0xFF),((x>>16)&0xFF),((x>>24)&0xFF)\r
412 #define HID_UnitExponent(x)    0x55,x\r
413 #define HID_Unit(x)            0x65,x\r
414 #define HID_UnitS(x)           0x66,(x&0xFF),((x>>8)&0xFF)\r
415 #define HID_UnitL(x)           0x67,(x&0xFF),((x>>8)&0xFF),((x>>16)&0xFF),((x>>24)&0xFF)\r
416 #define HID_ReportSize(x)      0x75,x\r
417 #define HID_ReportID(x)        0x85,x\r
418 #define HID_ReportCount(x)     0x95,x\r
419 #define HID_Push               0xA0\r
420 #define HID_Pop                0xB0\r
421 \r
422 /** Local Items */\r
423 #define HID_Usage(x)           0x09,x\r
424 #define HID_UsageMin(x)        0x19,x\r
425 #define HID_UsageMax(x)        0x29,x\r
426 /** @} */\r
427 \r
428 /** @} */\r
429 \r
430 #endif  /* __HID_H__ */\r