xref: /netbsd-src/sys/dev/usb/xinput_rdesc.h (revision 4e8e66439e246961c4367c78584be80e23f52897)
1*4e8e6643Sskrll /* $NetBSD: xinput_rdesc.h,v 1.2 2016/04/23 10:15:32 skrll Exp $ */
20ccce831Sjmcneill 
30ccce831Sjmcneill /*-
40ccce831Sjmcneill  * Copyright (c) 2011 Jared D. McNeill <jmcneill@invisible.ca>
50ccce831Sjmcneill  * All rights reserved.
60ccce831Sjmcneill  *
70ccce831Sjmcneill  * Redistribution and use in source and binary forms, with or without
80ccce831Sjmcneill  * modification, are permitted provided that the following conditions
90ccce831Sjmcneill  * are met:
100ccce831Sjmcneill  * 1. Redistributions of source code must retain the above copyright
110ccce831Sjmcneill  *    notice, this list of conditions and the following disclaimer.
120ccce831Sjmcneill  * 2. Redistributions in binary form must reproduce the above copyright
130ccce831Sjmcneill  *    notice, this list of conditions and the following disclaimer in the
140ccce831Sjmcneill  *    documentation and/or other materials provided with the distribution.
150ccce831Sjmcneill  *
160ccce831Sjmcneill  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS''
170ccce831Sjmcneill  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
180ccce831Sjmcneill  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
190ccce831Sjmcneill  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
200ccce831Sjmcneill  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
210ccce831Sjmcneill  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
220ccce831Sjmcneill  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
230ccce831Sjmcneill  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
240ccce831Sjmcneill  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
250ccce831Sjmcneill  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
260ccce831Sjmcneill  * POSSIBILITY OF SUCH DAMAGE.
270ccce831Sjmcneill  */
280ccce831Sjmcneill 
290ccce831Sjmcneill /*
300ccce831Sjmcneill  * Descriptor from http://euc.jp/periphs/xbox-pad-report-desc.txt
310ccce831Sjmcneill  */
320ccce831Sjmcneill 
33*4e8e6643Sskrll #define	USBIF_IS_XINPUT(uiaa)				\
34*4e8e6643Sskrll 	((uiaa)->uiaa_class == UICLASS_VENDOR && 	\
35*4e8e6643Sskrll 	 (uiaa)->uiaa_subclass == 0x5d &&		\
36*4e8e6643Sskrll 	 (uiaa)->uiaa_proto == 0x01)
370ccce831Sjmcneill 
380ccce831Sjmcneill static const uByte uhid_xinput_report_descr[] = {
390ccce831Sjmcneill     0x05, 0x01,		/* Usage Page (Generic Desktop) */
400ccce831Sjmcneill     0x09, 0x05,		/* Usage (Game Pad) */
410ccce831Sjmcneill     0xa1, 0x01,		/* Collection (Application) */
420ccce831Sjmcneill     0x05, 0x01,		/* Usage Page (Generic Desktop) */
430ccce831Sjmcneill     0x09, 0x3a,		/* Usage (Counted Buffer) */
440ccce831Sjmcneill     0xa1, 0x02,		/* Collection (Logical) */
450ccce831Sjmcneill     0x75, 0x08,		/* Report Size (8) */
460ccce831Sjmcneill     0x95, 0x01,		/* Report Count (1) */
470ccce831Sjmcneill     0x81, 0x01,		/* Input (Constant) */
480ccce831Sjmcneill     0x75, 0x08,		/* Report Size (8) */
490ccce831Sjmcneill     0x95, 0x01,		/* Report Count (1) */
500ccce831Sjmcneill     0x05, 0x01,		/* Usage Page (Generic Desktop) */
510ccce831Sjmcneill     0x09, 0x3b,		/* Usage (Byte Count) */
520ccce831Sjmcneill     0x81, 0x01,		/* Input (Constant) */
530ccce831Sjmcneill     0x05, 0x01,		/* Usage Page (Generic Desktop) */
540ccce831Sjmcneill     0x09, 0x01,		/* Usage (Pointer) */
550ccce831Sjmcneill     0xa1, 0x00,		/* Collection (Physical) */
560ccce831Sjmcneill     0x75, 0x01,		/* Report Size (1) */
570ccce831Sjmcneill     0x15, 0x00,		/* Logical Minimum (0) */
580ccce831Sjmcneill     0x25, 0x01,		/* Logical Maximum (1) */
590ccce831Sjmcneill     0x35, 0x00,		/* Physical Minimum (0) */
600ccce831Sjmcneill     0x45, 0x01,		/* Physical Maximum (1) */
610ccce831Sjmcneill     0x95, 0x04,		/* Report Count (4) */
620ccce831Sjmcneill     0x05, 0x01,		/* Usage Page (Generic Desktop) */
630ccce831Sjmcneill     0x09, 0x90,		/* Usage (D-pad Up) */
640ccce831Sjmcneill     0x09, 0x91,		/* Usage (D-pad Down) */
650ccce831Sjmcneill     0x09, 0x93,		/* Usage (D-pad Left) */
660ccce831Sjmcneill     0x09, 0x92,		/* Usage (D-pad Right) */
670ccce831Sjmcneill     0x81, 0x02,		/* Input (Data,Variable,Absolute) */
680ccce831Sjmcneill     0xc0,		/* End Collection */
690ccce831Sjmcneill     0x75, 0x01,		/* Report Size (1) */
700ccce831Sjmcneill     0x15, 0x00,		/* Logical Minimum (0) */
710ccce831Sjmcneill     0x25, 0x01,		/* Logical Maximum (1) */
720ccce831Sjmcneill     0x35, 0x00,		/* Physical Minimum (0) */
730ccce831Sjmcneill     0x45, 0x01,		/* Physical Maximum (1) */
740ccce831Sjmcneill     0x95, 0x04,		/* Report Count (4) */
750ccce831Sjmcneill     0x05, 0x09,		/* Usage Page (Button) */
760ccce831Sjmcneill     0x19, 0x07,		/* Usage Minimum (Button 7) */
770ccce831Sjmcneill     0x29, 0x0a,		/* Usage Maximum (Button 10) */
780ccce831Sjmcneill     0x81, 0x02,		/* Input (Data,Variable,Absolute) */
790ccce831Sjmcneill     0x75, 0x01,		/* Report Size (1) */
800ccce831Sjmcneill     0x95, 0x08,		/* Report Count (8) */
810ccce831Sjmcneill     0x81, 0x01,		/* Input (Constant) */
820ccce831Sjmcneill     0x75, 0x08,		/* Report Size (8) */
830ccce831Sjmcneill     0x15, 0x00,		/* Logical Minimum (0) */
840ccce831Sjmcneill     0x26, 0xff, 0x00,	/* Logical Maximum (255) */
850ccce831Sjmcneill     0x35, 0x00,		/* Physical Minimum (0) */
860ccce831Sjmcneill     0x46, 0xff, 0x00,	/* Physical Maximum (255) */
870ccce831Sjmcneill     0x95, 0x06,		/* Report Count (6) */
880ccce831Sjmcneill     0x05, 0x09,		/* Usage Page (Button) */
890ccce831Sjmcneill     0x19, 0x01,		/* Usage Minimum (Button 1) */
900ccce831Sjmcneill     0x29, 0x06,		/* Usage Minimum (Button 6) */
910ccce831Sjmcneill     0x81, 0x02,		/* Input (Data,Variable,Absolute) */
920ccce831Sjmcneill     0x75, 0x08,		/* Report Size (8) */
930ccce831Sjmcneill     0x15, 0x00,		/* Logical Minimum (0) */
940ccce831Sjmcneill     0x26, 0xff, 0x00,	/* Logical Maximum (255) */
950ccce831Sjmcneill     0x35, 0x00,		/* Physical Minimum (0) */
960ccce831Sjmcneill     0x46, 0xff, 0x00,	/* Physical Maximum (255) */
970ccce831Sjmcneill     0x95, 0x02,		/* Report Count (2) */
980ccce831Sjmcneill     0x05, 0x01,		/* Usage Page (Generic Desktop) */
990ccce831Sjmcneill     0x09, 0x32,		/* Usage (Z) */
1000ccce831Sjmcneill     0x09, 0x35,		/* Usage (Rz) */
1010ccce831Sjmcneill     0x81, 0x02,		/* Input (Data,Variable,Absolute) */
1020ccce831Sjmcneill     0x75, 0x10,		/* Report Size (16) */
1030ccce831Sjmcneill     0x16, 0x00, 0x80,	/* Logical Minimum (-32768) */
1040ccce831Sjmcneill     0x26, 0xff, 0x7f,	/* Logical Maximum (32767) */
1050ccce831Sjmcneill     0x36, 0x00, 0x80,	/* Physical Minimum (-32768) */
1060ccce831Sjmcneill     0x46, 0xff, 0x7f,	/* Physical Maximum (32767) */
1070ccce831Sjmcneill     0x05, 0x01,		/* Usage Page (Generic Desktop) */
1080ccce831Sjmcneill     0x09, 0x01,		/* Usage (Pointer) */
1090ccce831Sjmcneill     0xa1, 0x00,		/* Collection (Physical) */
1100ccce831Sjmcneill     0x95, 0x02,		/* Report Count (2) */
1110ccce831Sjmcneill     0x05, 0x01,		/* Usage Page (Generic Desktop) */
1120ccce831Sjmcneill     0x09, 0x30,		/* Usage (X) */
1130ccce831Sjmcneill     0x09, 0x31,		/* Usage (Y) */
1140ccce831Sjmcneill     0x81, 0x02,		/* Input (Data,Variable,Absolute) */
1150ccce831Sjmcneill     0xc0,		/* End Collection */
1160ccce831Sjmcneill     0x05, 0x01,		/* Usage Page (Generic Desktop) */
1170ccce831Sjmcneill     0x09, 0x01,		/* Usage (Pointer) */
1180ccce831Sjmcneill     0xa1, 0x00,		/* Collection (Physical) */
1190ccce831Sjmcneill     0x95, 0x02,		/* Report Count (2) */
1200ccce831Sjmcneill     0x05, 0x01,		/* Usage Page (Generic Desktop) */
1210ccce831Sjmcneill     0x09, 0x33,		/* Usage (Rx) */
1220ccce831Sjmcneill     0x09, 0x34,		/* Usage (Ry) */
1230ccce831Sjmcneill     0x81, 0x02,		/* Input (Data,Variable,Absolute) */
1240ccce831Sjmcneill     0xc0,		/* End Collection */
1250ccce831Sjmcneill     0xc0,		/* End Collection */
1260ccce831Sjmcneill     0x05, 0x01,		/* Usage Page (Generic Desktop) */
1270ccce831Sjmcneill     0x09, 0x3a,		/* Usage (Counted Buffer) */
1280ccce831Sjmcneill     0xa1, 0x02,		/* Collection (Logical) */
1290ccce831Sjmcneill     0x75, 0x08,		/* Report Size (8) */
1300ccce831Sjmcneill     0x95, 0x01,		/* Report Count (1) */
1310ccce831Sjmcneill     0x91, 0x01,		/* Output (Constant) */
1320ccce831Sjmcneill     0x75, 0x08,		/* Report Size (8) */
1330ccce831Sjmcneill     0x95, 0x01,		/* Report Count (1) */
1340ccce831Sjmcneill     0x05, 0x01,		/* Usage Page (Generic Desktop) */
1350ccce831Sjmcneill     0x09, 0x3b,		/* Usage (Byte Count) */
1360ccce831Sjmcneill     0x91, 0x01,		/* Output (Constant) */
1370ccce831Sjmcneill     0x75, 0x08,		/* Report Size (8) */
1380ccce831Sjmcneill     0x95, 0x01,		/* Report Count (1) */
1390ccce831Sjmcneill     0x91, 0x01,		/* Output (Constant) */
1400ccce831Sjmcneill     0x75, 0x08,		/* Report Size (8) */
1410ccce831Sjmcneill     0x15, 0x00,		/* Logical Minimum (0) */
1420ccce831Sjmcneill     0x26, 0xff, 0x00,	/* Logical Maximum (255) */
1430ccce831Sjmcneill     0x35, 0x00,		/* Physical Minimum (0) */
1440ccce831Sjmcneill     0x46, 0xff, 0x00,	/* Physical Maximum (255) */
1450ccce831Sjmcneill     0x95, 0x01,		/* Report Count (1) */
1460ccce831Sjmcneill     0x06, 0x00, 0xff,	/* Usage Page (vendor-defined) */
1470ccce831Sjmcneill     0x09, 0x01,		/* Usage (1) */
1480ccce831Sjmcneill     0x91, 0x02,		/* Output (Data,Variable,Absolute) */
1490ccce831Sjmcneill     0x75, 0x08,		/* Report Size (8) */
1500ccce831Sjmcneill     0x95, 0x01,		/* Report Count (1) */
1510ccce831Sjmcneill     0x91, 0x01,		/* Output (Constant) */
1520ccce831Sjmcneill     0x75, 0x08,		/* Report Size (8) */
1530ccce831Sjmcneill     0x15, 0x00,		/* Logical Minimum (0) */
1540ccce831Sjmcneill     0x26, 0xff, 0x00,	/* Logical Maximum (255) */
1550ccce831Sjmcneill     0x35, 0x00,		/* Physical Minimum (0) */
1560ccce831Sjmcneill     0x46, 0xff, 0x00,	/* Physical Maximum (255) */
1570ccce831Sjmcneill     0x95, 0x01,		/* Report Count (1) */
1580ccce831Sjmcneill     0x06, 0x00, 0xff,	/* Usage Page (vendor-defined) */
1590ccce831Sjmcneill     0x09, 0x02,		/* Usage (2) */
1600ccce831Sjmcneill     0x91, 0x02,		/* Output (Data,Variable,Absolute) */
1610ccce831Sjmcneill     0xc0,		/* End Collection */
1620ccce831Sjmcneill     0xc0,		/* End Collection */
1630ccce831Sjmcneill };
164