xref: /haiku/headers/os/drivers/usb/USB_hid.h (revision 24159a0c7d6d6dcba9f2a0c1a7c08d2c8167f21b)
1 #ifndef USB_HID_H
2 #define USB_HID_H
3 
4 // (Partial) USB Class Definitions for HID Devices, version 1.11
5 // Reference: http://www.usb.org/developers/devclass_docs/hid1_11.pdf
6 
7 #define USB_HID_DEVICE_CLASS 			0x03
8 #define USB_HID_CLASS_VERSION			0x0100
9 
10 enum { // HID Interface Subclasses
11 	USB_HID_INTERFACE_NO_SUBCLASS = 0x00,	//  No Subclass
12 	USB_HID_INTERFACE_BOOT_SUBCLASS			//	Boot Interface Subclass
13 };
14 
15 enum { // HID Class-Specific descriptor subtypes
16 	USB_HID_DESCRIPTOR_HID						= 0x21,
17 	USB_HID_DESCRIPTOR_REPORT,
18 	USB_HID_DESCRIPTOR_PHYSICAL
19 };
20 
21 enum { // HID Class-specific requests
22 	USB_REQUEST_HID_GET_REPORT		= 0x01,
23 	USB_REQUEST_HID_GET_IDLE,
24 	USB_REQUEST_HID_GET_PROTOCOL,
25 
26 	USB_REQUEST_HID_SET_REPORT = 0x09,
27 	USB_REQUEST_HID_SET_IDLE,
28 	USB_REQUEST_HID_SET_PROTOCOL
29 };
30 
31 typedef struct
32 {
33 	uint8	length;
34 	uint8	descriptor_type;
35 	uint16	hid_version;
36 	uint8	country_code;
37 	uint8	num_descriptors;
38 	struct
39 	{
40 		uint8	descriptor_type;
41 		uint16	descriptor_length;
42 	} _PACKED descriptor_info [1];
43 } _PACKED usb_hid_descriptor;
44 
45 
46 /*
47 	Usage Pages/IDs
48 */
49 
50 enum
51 {
52 	USAGE_PAGE_GENERIC_DESKTOP = 0x1,
53 	USAGE_PAGE_SIMULATION,
54 	USAGE_PAGE_VR,
55 	USAGE_PAGE_SPORT,
56 	USAGE_PAGE_GAME,
57 	USAGE_PAGE_GENERIC,
58 	USAGE_PAGE_KEYBOARD,
59 	USAGE_PAGE_LED,
60 	USAGE_PAGE_BUTTON,
61 	USAGE_PAGE_ORDINAL,
62 	USAGE_PAGE_TELEPHONY,
63 	USAGE_PAGE_CONSUMER,
64 	USAGE_PAGE_DIGITIZER,
65 	USAGE_PAGE_PID = 0xf,
66 	USAGE_PAGE_UNICODE,
67 	USAGE_PAGE_ALPHANUM_DISPLAY = 0x14,
68 	USAGE_PAGE_MEDICAL = 0x40
69 };
70 
71 /* Page 1: Generic Desktop */
72 
73 enum
74 {
75 	USAGE_ID_POINTER = 0x1,
76 	USAGE_ID_MOUSE,
77 	USAGE_ID_JOYSTICK = 0x4,
78 	USAGE_ID_GAMEPAD,
79 	USAGE_ID_KEYBOARD,
80 	USAGE_ID_KEYPAD,
81 	USAGE_ID_MULTIAXIS = 0x8,
82 
83 	USAGE_ID_X = 0x30,
84 	USAGE_ID_Y,
85 	USAGE_ID_Z,
86 	USAGE_ID_RX,
87 	USAGE_ID_RY,
88 	USAGE_ID_RZ,
89 	USAGE_ID_SLIDER,
90 	USAGE_ID_DIAL,
91 	USAGE_ID_WHEEL,
92 	USAGE_ID_HAT_SWITCH,
93 	USAGE_ID_COUNTED_BUFFER,
94 	USAGE_ID_BYTE_COUNT,
95 	USAGE_ID_MOTION_WAKEUP,
96 	USAGE_ID_START,
97 	USAGE_ID_SELECT,
98 	USAGE_ID_VX = 0x40,
99 	USAGE_ID_VY,
100 	USAGE_ID_VZ,
101 	USAGE_ID_VBRX,
102 	USAGE_ID_VBRY,
103 	USAGE_ID_VBRZ,
104 	USAGE_ID_VNO,
105 	USAGE_ID_FEATURE_NOTIFICATION
106 };
107 
108 /* Page 2: Simulation */
109 
110 enum
111 {
112 	USAGE_ID_RUDDER = 0xBA,
113 	USAGE_ID_THROTTLE = 0xBB,
114 };
115 
116 #endif	// USB_HID_H
117