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