usbhid.h revision 1.5 1 /* $NetBSD: usbhid.h,v 1.5 1999/05/13 23:29:11 augustss Exp $ */
2
3 /*
4 * Copyright (c) 1998 The NetBSD Foundation, Inc.
5 * All rights reserved.
6 *
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Lennart Augustsson (augustss (at) carlstedt.se) at
9 * Carlstedt Research & Technology.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions and the following disclaimer.
16 * 2. Redistributions in binary form must reproduce the above copyright
17 * notice, this list of conditions and the following disclaimer in the
18 * documentation and/or other materials provided with the distribution.
19 * 3. All advertising materials mentioning features or use of this software
20 * must display the following acknowledgement:
21 * This product includes software developed by the NetBSD
22 * Foundation, Inc. and its contributors.
23 * 4. Neither the name of The NetBSD Foundation nor the names of its
24 * contributors may be used to endorse or promote products derived
25 * from this software without specific prior written permission.
26 *
27 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
28 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
29 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
30 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
31 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
32 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
33 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
34 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
35 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
36 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
37 * POSSIBILITY OF SUCH DAMAGE.
38 */
39
40
41 #ifndef _USBHID_H_
42 #define _USBHID_H_
43
44 #define UR_GET_HID_DESCRIPTOR 0x06
45 #define UDESC_HID 0x21
46 #define UDESC_REPORT 0x22
47 #define UDESC_PHYSICAL 0x23
48 #define UR_SET_HID_DESCRIPTOR 0x07
49 #define UR_GET_REPORT 0x01
50 #define UR_SET_REPORT 0x09
51 #define UR_GET_IDLE 0x02
52 #define UR_SET_IDLE 0x0a
53 #define UR_GET_PROTOCOL 0x03
54 #define UR_SET_PROTOCOL 0x0b
55
56 typedef struct usb_hid_descriptor {
57 uByte bLength;
58 uByte bDescriptorType;
59 uWord bcdHID;
60 uByte bCountryCode;
61 uByte bNumDescriptors;
62 struct {
63 uByte bDescriptorType;
64 uWord wDescriptorLength;
65 } descrs[1];
66 } usb_hid_descriptor_t;
67 #define USB_HID_DESCRIPTOR_SIZE(n) (9+(n)*3)
68
69 /* Usage pages */
70 #define HUP_GENERIC_DESKTOP 0x0001
71 #define HUP_SIMULATION 0x0002
72 #define HUP_LEDS 0x0008
73 #define HUP_BUTTON 0x0009
74 #define HUP_DIGITIZERS 0x000d
75
76 /* Usages, generic desktop */
77 #define HUG_POINTER 0x0001
78 #define HUG_MOUSE 0x0002
79 #define HUG_JOYSTICK 0x0004
80 #define HUG_GAME_PAD 0x0005
81 #define HUG_KEYBOARD 0x0006
82 #define HUG_KEYPAD 0x0007
83 #define HUG_X 0x0030
84 #define HUG_Y 0x0031
85 #define HUG_Z 0x0032
86 #define HUG_RX 0x0033
87 #define HUG_RY 0x0034
88 #define HUG_RZ 0x0035
89 #define HUG_SLIDER 0x0036
90 #define HUG_DIAL 0x0037
91 #define HUG_WHEEL 0x0038
92 #define HUG_HAT_SWITCH 0x0039
93 #define HUG_COUNTED_BUFFER 0x003a
94 #define HUG_BYTE_COUNT 0x003b
95 #define HUG_MOTION_WAKEUP 0x003c
96 #define HUG_VX 0x0040
97 #define HUG_VY 0x0041
98 #define HUG_VZ 0x0042
99 #define HUG_VBRX 0x0043
100 #define HUG_VBRY 0x0044
101 #define HUG_VBRZ 0x0045
102 #define HUG_VNO 0x0046
103 #define HUG_SYSTEM_CONTROL 0x0080
104 #define HUG_SYSTEM_POWER_DOWN 0x0081
105 #define HUG_SYSTEM_SLEEP 0x0082
106 #define HUG_SYSTEM_WAKEUP 0x0083
107 #define HUG_SYSTEM_CONTEXT_MENU 0x0084
108 #define HUG_SYSTEM_MAIN_MENU 0x0085
109 #define HUG_SYSTEM_APP_MENU 0x0086
110 #define HUG_SYSTEM_MENU_HELP 0x0087
111 #define HUG_SYSTEM_MENU_EXIT 0x0088
112 #define HUG_SYSTEM_MENU_SELECT 0x0089
113 #define HUG_SYSTEM_MENU_RIGHT 0x008a
114 #define HUG_SYSTEM_MENU_LEFT 0x008b
115 #define HUG_SYSTEM_MENU_UP 0x008c
116 #define HUG_SYSTEM_MENU_DOWN 0x008d
117
118 /* Usages Digitizers */
119 #define HUD_TIP_PRESSURE 0x0030
120 #define HUD_BARREL_PRESSURE 0x0031
121 #define HUD_IN_RANGE 0x0032
122 #define HUD_TOUCH 0x0033
123 #define HUD_UNTOUCH 0x0034
124 #define HUD_TAP 0x0035
125 #define HUD_QUALITY 0x0036
126 #define HUD_INVERT 0x003c
127 #define HUD_X_TILT 0x003d
128 #define HUD_Y_TILT 0x003e
129 #define HUD_AZIMUTH 0x003f
130 #define HUD_ALTITUDE 0x0040
131 #define HUD_TWIST 0x0041
132 #define HUD_TIP_SWITCH 0x0042
133 #define HUD_SEC_TIP_SWITCH 0x0043
134 #define HUD_BARREL_SWITCH 0x0044
135 #define HUD_ERASER 0x0045
136 #define HUD_TABLET_PICK 0x0046
137
138 #define HID_USAGE2(p,u) (((p) << 16) | u)
139
140 #define UHID_INPUT_REPORT 0x01
141 #define UHID_OUTPUT_REPORT 0x02
142 #define UHID_FEATURE_REPORT 0x03
143
144 /* Bits in the input/output/feature items */
145 #define HIO_CONST 0x001
146 #define HIO_VARIABLE 0x002
147 #define HIO_RELATIVE 0x004
148 #define HIO_WRAP 0x008
149 #define HIO_NONLINEAR 0x010
150 #define HIO_NOPREF 0x020
151 #define HIO_NULLSTATE 0x040
152 #define HIO_VOLATILE 0x080
153 #define HIO_BUFBYTES 0x100
154
155 #endif /* _USBHID_H_ */
156