xref: /freebsd/sys/dev/usb/usbhid.h (revision 760bc48e7ee4471fe04fa5fee89d00bf7d698ddb)
102ac6454SAndrew Thompson /* $FreeBSD$ */
202ac6454SAndrew Thompson /*-
302ac6454SAndrew Thompson  * Copyright (c) 2008 Hans Petter Selasky. All rights reserved.
402ac6454SAndrew Thompson  * Copyright (c) 1998 The NetBSD Foundation, Inc. All rights reserved.
502ac6454SAndrew Thompson  * Copyright (c) 1998 Lennart Augustsson. All rights reserved.
602ac6454SAndrew Thompson  *
702ac6454SAndrew Thompson  * Redistribution and use in source and binary forms, with or without
802ac6454SAndrew Thompson  * modification, are permitted provided that the following conditions
902ac6454SAndrew Thompson  * are met:
1002ac6454SAndrew Thompson  * 1. Redistributions of source code must retain the above copyright
1102ac6454SAndrew Thompson  *    notice, this list of conditions and the following disclaimer.
1202ac6454SAndrew Thompson  * 2. Redistributions in binary form must reproduce the above copyright
1302ac6454SAndrew Thompson  *    notice, this list of conditions and the following disclaimer in the
1402ac6454SAndrew Thompson  *    documentation and/or other materials provided with the distribution.
1502ac6454SAndrew Thompson  *
1602ac6454SAndrew Thompson  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
1702ac6454SAndrew Thompson  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1802ac6454SAndrew Thompson  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1902ac6454SAndrew Thompson  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
2002ac6454SAndrew Thompson  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2102ac6454SAndrew Thompson  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2202ac6454SAndrew Thompson  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2302ac6454SAndrew Thompson  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2402ac6454SAndrew Thompson  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2502ac6454SAndrew Thompson  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2602ac6454SAndrew Thompson  * SUCH DAMAGE.
2702ac6454SAndrew Thompson  */
2802ac6454SAndrew Thompson 
2902ac6454SAndrew Thompson #ifndef _USB2_HID_H_
3002ac6454SAndrew Thompson #define	_USB2_HID_H_
3102ac6454SAndrew Thompson 
3202ac6454SAndrew Thompson #include <dev/usb/usb_endian.h>
3302ac6454SAndrew Thompson 
3402ac6454SAndrew Thompson #define	UR_GET_HID_DESCRIPTOR	0x06
3502ac6454SAndrew Thompson #define	UDESC_HID		0x21
3602ac6454SAndrew Thompson #define	UDESC_REPORT		0x22
3702ac6454SAndrew Thompson #define	UDESC_PHYSICAL		0x23
3802ac6454SAndrew Thompson #define	UR_SET_HID_DESCRIPTOR	0x07
3902ac6454SAndrew Thompson #define	UR_GET_REPORT		0x01
4002ac6454SAndrew Thompson #define	UR_SET_REPORT		0x09
4102ac6454SAndrew Thompson #define	UR_GET_IDLE		0x02
4202ac6454SAndrew Thompson #define	UR_SET_IDLE		0x0a
4302ac6454SAndrew Thompson #define	UR_GET_PROTOCOL		0x03
4402ac6454SAndrew Thompson #define	UR_SET_PROTOCOL		0x0b
4502ac6454SAndrew Thompson 
46760bc48eSAndrew Thompson struct usb_hid_descriptor {
4702ac6454SAndrew Thompson 	uByte	bLength;
4802ac6454SAndrew Thompson 	uByte	bDescriptorType;
4902ac6454SAndrew Thompson 	uWord	bcdHID;
5002ac6454SAndrew Thompson 	uByte	bCountryCode;
5102ac6454SAndrew Thompson 	uByte	bNumDescriptors;
5202ac6454SAndrew Thompson 	struct {
5302ac6454SAndrew Thompson 		uByte	bDescriptorType;
5402ac6454SAndrew Thompson 		uWord	wDescriptorLength;
5502ac6454SAndrew Thompson 	}	descrs[1];
5602ac6454SAndrew Thompson } __packed;
5702ac6454SAndrew Thompson 
5802ac6454SAndrew Thompson #define	USB_HID_DESCRIPTOR_SIZE(n) (9+((n)*3))
5902ac6454SAndrew Thompson 
6002ac6454SAndrew Thompson /* Usage pages */
6102ac6454SAndrew Thompson #define	HUP_UNDEFINED		0x0000
6202ac6454SAndrew Thompson #define	HUP_GENERIC_DESKTOP	0x0001
6302ac6454SAndrew Thompson #define	HUP_SIMULATION		0x0002
6402ac6454SAndrew Thompson #define	HUP_VR_CONTROLS		0x0003
6502ac6454SAndrew Thompson #define	HUP_SPORTS_CONTROLS	0x0004
6602ac6454SAndrew Thompson #define	HUP_GAMING_CONTROLS	0x0005
6702ac6454SAndrew Thompson #define	HUP_KEYBOARD		0x0007
6802ac6454SAndrew Thompson #define	HUP_LEDS		0x0008
6902ac6454SAndrew Thompson #define	HUP_BUTTON		0x0009
7002ac6454SAndrew Thompson #define	HUP_ORDINALS		0x000a
7102ac6454SAndrew Thompson #define	HUP_TELEPHONY		0x000b
7202ac6454SAndrew Thompson #define	HUP_CONSUMER		0x000c
7302ac6454SAndrew Thompson #define	HUP_DIGITIZERS		0x000d
7402ac6454SAndrew Thompson #define	HUP_PHYSICAL_IFACE	0x000e
7502ac6454SAndrew Thompson #define	HUP_UNICODE		0x0010
7602ac6454SAndrew Thompson #define	HUP_ALPHANUM_DISPLAY	0x0014
7702ac6454SAndrew Thompson #define	HUP_MONITOR		0x0080
7802ac6454SAndrew Thompson #define	HUP_MONITOR_ENUM_VAL	0x0081
7902ac6454SAndrew Thompson #define	HUP_VESA_VC		0x0082
8002ac6454SAndrew Thompson #define	HUP_VESA_CMD		0x0083
8102ac6454SAndrew Thompson #define	HUP_POWER		0x0084
8202ac6454SAndrew Thompson #define	HUP_BATTERY_SYSTEM	0x0085
8302ac6454SAndrew Thompson #define	HUP_BARCODE_SCANNER	0x008b
8402ac6454SAndrew Thompson #define	HUP_SCALE		0x008c
8502ac6454SAndrew Thompson #define	HUP_CAMERA_CONTROL	0x0090
8602ac6454SAndrew Thompson #define	HUP_ARCADE		0x0091
8702ac6454SAndrew Thompson #define	HUP_MICROSOFT		0xff00
8802ac6454SAndrew Thompson 
8902ac6454SAndrew Thompson /* Usages, generic desktop */
9002ac6454SAndrew Thompson #define	HUG_POINTER		0x0001
9102ac6454SAndrew Thompson #define	HUG_MOUSE		0x0002
9202ac6454SAndrew Thompson #define	HUG_JOYSTICK		0x0004
9302ac6454SAndrew Thompson #define	HUG_GAME_PAD		0x0005
9402ac6454SAndrew Thompson #define	HUG_KEYBOARD		0x0006
9502ac6454SAndrew Thompson #define	HUG_KEYPAD		0x0007
9602ac6454SAndrew Thompson #define	HUG_X			0x0030
9702ac6454SAndrew Thompson #define	HUG_Y			0x0031
9802ac6454SAndrew Thompson #define	HUG_Z			0x0032
9902ac6454SAndrew Thompson #define	HUG_RX			0x0033
10002ac6454SAndrew Thompson #define	HUG_RY			0x0034
10102ac6454SAndrew Thompson #define	HUG_RZ			0x0035
10202ac6454SAndrew Thompson #define	HUG_SLIDER		0x0036
10302ac6454SAndrew Thompson #define	HUG_DIAL		0x0037
10402ac6454SAndrew Thompson #define	HUG_WHEEL		0x0038
10502ac6454SAndrew Thompson #define	HUG_HAT_SWITCH		0x0039
10602ac6454SAndrew Thompson #define	HUG_COUNTED_BUFFER	0x003a
10702ac6454SAndrew Thompson #define	HUG_BYTE_COUNT		0x003b
10802ac6454SAndrew Thompson #define	HUG_MOTION_WAKEUP	0x003c
10902ac6454SAndrew Thompson #define	HUG_VX			0x0040
11002ac6454SAndrew Thompson #define	HUG_VY			0x0041
11102ac6454SAndrew Thompson #define	HUG_VZ			0x0042
11202ac6454SAndrew Thompson #define	HUG_VBRX		0x0043
11302ac6454SAndrew Thompson #define	HUG_VBRY		0x0044
11402ac6454SAndrew Thompson #define	HUG_VBRZ		0x0045
11502ac6454SAndrew Thompson #define	HUG_VNO			0x0046
11602ac6454SAndrew Thompson #define	HUG_TWHEEL		0x0048	/* M$ Wireless Intellimouse Wheel */
11702ac6454SAndrew Thompson #define	HUG_SYSTEM_CONTROL	0x0080
11802ac6454SAndrew Thompson #define	HUG_SYSTEM_POWER_DOWN	0x0081
11902ac6454SAndrew Thompson #define	HUG_SYSTEM_SLEEP	0x0082
12002ac6454SAndrew Thompson #define	HUG_SYSTEM_WAKEUP	0x0083
12102ac6454SAndrew Thompson #define	HUG_SYSTEM_CONTEXT_MENU	0x0084
12202ac6454SAndrew Thompson #define	HUG_SYSTEM_MAIN_MENU	0x0085
12302ac6454SAndrew Thompson #define	HUG_SYSTEM_APP_MENU	0x0086
12402ac6454SAndrew Thompson #define	HUG_SYSTEM_MENU_HELP	0x0087
12502ac6454SAndrew Thompson #define	HUG_SYSTEM_MENU_EXIT	0x0088
12602ac6454SAndrew Thompson #define	HUG_SYSTEM_MENU_SELECT	0x0089
12702ac6454SAndrew Thompson #define	HUG_SYSTEM_MENU_RIGHT	0x008a
12802ac6454SAndrew Thompson #define	HUG_SYSTEM_MENU_LEFT	0x008b
12902ac6454SAndrew Thompson #define	HUG_SYSTEM_MENU_UP	0x008c
13002ac6454SAndrew Thompson #define	HUG_SYSTEM_MENU_DOWN	0x008d
131fa64b944SAndrew Thompson #define	HUG_APPLE_EJECT		0x00b8
13202ac6454SAndrew Thompson 
13302ac6454SAndrew Thompson /* Usages Digitizers */
13402ac6454SAndrew Thompson #define	HUD_UNDEFINED		0x0000
13502ac6454SAndrew Thompson #define	HUD_TIP_PRESSURE	0x0030
13602ac6454SAndrew Thompson #define	HUD_BARREL_PRESSURE	0x0031
13702ac6454SAndrew Thompson #define	HUD_IN_RANGE		0x0032
13802ac6454SAndrew Thompson #define	HUD_TOUCH		0x0033
13902ac6454SAndrew Thompson #define	HUD_UNTOUCH		0x0034
14002ac6454SAndrew Thompson #define	HUD_TAP			0x0035
14102ac6454SAndrew Thompson #define	HUD_QUALITY		0x0036
14202ac6454SAndrew Thompson #define	HUD_DATA_VALID		0x0037
14302ac6454SAndrew Thompson #define	HUD_TRANSDUCER_INDEX	0x0038
14402ac6454SAndrew Thompson #define	HUD_TABLET_FKEYS	0x0039
14502ac6454SAndrew Thompson #define	HUD_PROGRAM_CHANGE_KEYS	0x003a
14602ac6454SAndrew Thompson #define	HUD_BATTERY_STRENGTH	0x003b
14702ac6454SAndrew Thompson #define	HUD_INVERT		0x003c
14802ac6454SAndrew Thompson #define	HUD_X_TILT		0x003d
14902ac6454SAndrew Thompson #define	HUD_Y_TILT		0x003e
15002ac6454SAndrew Thompson #define	HUD_AZIMUTH		0x003f
15102ac6454SAndrew Thompson #define	HUD_ALTITUDE		0x0040
15202ac6454SAndrew Thompson #define	HUD_TWIST		0x0041
15302ac6454SAndrew Thompson #define	HUD_TIP_SWITCH		0x0042
15402ac6454SAndrew Thompson #define	HUD_SEC_TIP_SWITCH	0x0043
15502ac6454SAndrew Thompson #define	HUD_BARREL_SWITCH	0x0044
15602ac6454SAndrew Thompson #define	HUD_ERASER		0x0045
15702ac6454SAndrew Thompson #define	HUD_TABLET_PICK		0x0046
15802ac6454SAndrew Thompson 
15902ac6454SAndrew Thompson #define	HID_USAGE2(p,u) (((p) << 16) | (u))
16002ac6454SAndrew Thompson 
16102ac6454SAndrew Thompson #define	UHID_INPUT_REPORT 0x01
16202ac6454SAndrew Thompson #define	UHID_OUTPUT_REPORT 0x02
16302ac6454SAndrew Thompson #define	UHID_FEATURE_REPORT 0x03
16402ac6454SAndrew Thompson 
16502ac6454SAndrew Thompson /* Bits in the input/output/feature items */
16602ac6454SAndrew Thompson #define	HIO_CONST	0x001
16702ac6454SAndrew Thompson #define	HIO_VARIABLE	0x002
16802ac6454SAndrew Thompson #define	HIO_RELATIVE	0x004
16902ac6454SAndrew Thompson #define	HIO_WRAP	0x008
17002ac6454SAndrew Thompson #define	HIO_NONLINEAR	0x010
17102ac6454SAndrew Thompson #define	HIO_NOPREF	0x020
17202ac6454SAndrew Thompson #define	HIO_NULLSTATE	0x040
17302ac6454SAndrew Thompson #define	HIO_VOLATILE	0x080
17402ac6454SAndrew Thompson #define	HIO_BUFBYTES	0x100
17502ac6454SAndrew Thompson 
17602ac6454SAndrew Thompson #endif					/* _USB2_HID_H_ */
177