From ea39bca214ca70ce731f26dc1bdb1ae4ddc5bdc7 Mon Sep 17 00:00:00 2001 From: Jeremy Evans Date: Fri, 25 Oct 2013 03:10:00 +0000 Subject: Add support for Microsoft XBox 360 controller as a uhid. It doesn't use the standard interface class and doesn't have a report descriptor, so use a manually created one. The controller shows up as multiple devices with different interface numbers, so only match the first one as a uhid. The controller shows up as both a uhid and a ugen. Rename ugraphire_rdesc.h to uhid_rdesc.h and add the manually created Xbox 360 report descriptor to the file. Add ifndef SMALL_KERNEL around the related blocks for the XBox 360 controller and Wacom Graphire, so this should actually shrink the ramdisks. Manual report descriptor taken from a 2005 FreeBSD commit. Much help from mpi@ for getting this suitable for commit to OpenBSD. OK mpi@ --- sys/dev/usb/ugraphire_rdesc.h | 177 --------------------------- sys/dev/usb/uhid_rdesc.h | 275 ++++++++++++++++++++++++++++++++++++++++++ sys/dev/usb/uhidev.c | 25 +++- 3 files changed, 296 insertions(+), 181 deletions(-) delete mode 100644 sys/dev/usb/ugraphire_rdesc.h create mode 100644 sys/dev/usb/uhid_rdesc.h (limited to 'sys') diff --git a/sys/dev/usb/ugraphire_rdesc.h b/sys/dev/usb/ugraphire_rdesc.h deleted file mode 100644 index 0daa50c4380..00000000000 --- a/sys/dev/usb/ugraphire_rdesc.h +++ /dev/null @@ -1,177 +0,0 @@ -/* $OpenBSD: ugraphire_rdesc.h,v 1.3 2006/01/06 03:36:32 brad Exp $ */ -/* $NetBSD: ugraphire_rdesc.h,v 1.1 2000/12/29 01:47:49 augustss Exp $ */ -/* - * Copyright (c) 2000 Nick Hibma - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -static uByte uhid_graphire_report_descr[] = { - 0x05, 0x0d, /* USAGE_PAGE (Digitizers) */ - 0x09, 0x01, /* USAGE (Digitizer) */ - 0xa1, 0x01, /* COLLECTION (Application) */ - 0x85, 0x02, /* REPORT_ID (2) */ - 0x05, 0x0d, /* USAGE_PAGE (Digitizers) */ - 0x09, 0x01, /* USAGE (Digitizer) */ - 0xa1, 0x00, /* COLLECTION (Physical) */ - 0x15, 0x00, /* LOGICAL_MINIMUM (0) */ - 0x25, 0x01, /* LOGICAL_MAXIMUM (1) */ - 0x09, 0x33, /* USAGE (Touch) */ - 0x95, 0x01, /* REPORT_COUNT (1) */ - 0x75, 0x01, /* REPORT_SIZE (1) */ - 0x81, 0x02, /* INPUT (Data,Var,Abs) */ - 0x09, 0x44, /* USAGE (Barrel Switch) */ - 0x95, 0x02, /* REPORT_COUNT (2) */ - 0x75, 0x01, /* REPORT_SIZE (1) */ - 0x81, 0x02, /* INPUT (Data,Var,Abs) */ - 0x09, 0x00, /* USAGE (Undefined) */ - 0x95, 0x02, /* REPORT_COUNT (2) */ - 0x75, 0x01, /* REPORT_SIZE (1) */ - 0x81, 0x03, /* INPUT (Cnst,Var,Abs) */ - 0x09, 0x3c, /* USAGE (Invert) */ - 0x95, 0x01, /* REPORT_COUNT (1) */ - 0x75, 0x01, /* REPORT_SIZE (1) */ - 0x81, 0x02, /* INPUT (Data,Var,Abs) */ - 0x09, 0x38, /* USAGE (Transducer Index) */ - 0x95, 0x01, /* REPORT_COUNT (1) */ - 0x75, 0x01, /* REPORT_SIZE (1) */ - 0x81, 0x02, /* INPUT (Data,Var,Abs) */ - 0x09, 0x32, /* USAGE (In Range) */ - 0x95, 0x01, /* REPORT_COUNT (1) */ - 0x75, 0x01, /* REPORT_SIZE (1) */ - 0x81, 0x02, /* INPUT (Data,Var,Abs) */ - 0x05, 0x01, /* USAGE_PAGE (Generic Desktop) */ - 0x09, 0x30, /* USAGE (X) */ - 0x15, 0x00, /* LOGICAL_MINIMUM (0) */ - 0x26, 0xde, 0x27, /* LOGICAL_MAXIMUM (10206) */ - 0x95, 0x01, /* REPORT_COUNT (1) */ - 0x75, 0x10, /* REPORT_SIZE (16) */ - 0x81, 0x02, /* INPUT (Data,Var,Abs) */ - 0x09, 0x31, /* USAGE (Y) */ - 0x26, 0xfe, 0x1c, /* LOGICAL_MAXIMUM (7422) */ - 0x95, 0x01, /* REPORT_COUNT (1) */ - 0x75, 0x10, /* REPORT_SIZE (16) */ - 0x81, 0x02, /* INPUT (Data,Var,Abs) */ - 0x05, 0x0d, /* USAGE_PAGE (Digitizers) */ - 0x09, 0x30, /* USAGE (Tip Pressure) */ - 0x26, 0xff, 0x01, /* LOGICAL_MAXIMUM (511) */ - 0x95, 0x01, /* REPORT_COUNT (1) */ - 0x75, 0x10, /* REPORT_SIZE (16) */ - 0x81, 0x02, /* INPUT (Data,Var,Abs) */ - 0xc0, /* END_COLLECTION */ - 0x05, 0x0d, /* USAGE_PAGE (Digitizers) */ - 0x09, 0x00, /* USAGE (Undefined) */ - 0x85, 0x02, /* REPORT_ID (2) */ - 0x95, 0x01, /* REPORT_COUNT (1) */ - 0xb1, 0x02, /* FEATURE (Data,Var,Abs) */ - 0x09, 0x00, /* USAGE (Undefined) */ - 0x85, 0x03, /* REPORT_ID (3) */ - 0x95, 0x01, /* REPORT_COUNT (1) */ - 0xb1, 0x02, /* FEATURE (Data,Var,Abs) */ - 0xc0, /* END_COLLECTION */ -}; - -static uByte uhid_graphire3_4x5_report_descr[] = { - 0x05, 0x01, /* USAGE_PAGE (Generic Desktop) */ - 0x09, 0x02, /* USAGE (Mouse) */ - 0xa1, 0x01, /* COLLECTION (Application) */ - 0x85, 0x01, /* REPORT_ID (1) */ - 0x09, 0x01, /* USAGE (Pointer) */ - 0xa1, 0x00, /* COLLECTION (Physical) */ - 0x05, 0x09, /* USAGE_PAGE (Button) */ - 0x19, 0x01, /* USAGE_MINIMUM (Button 1) */ - 0x29, 0x03, /* USAGE_MAXIMUM (Button 3) */ - 0x15, 0x00, /* LOGICAL_MINIMUM (0) */ - 0x25, 0x01, /* LOGICAL_MAXIMUM (1) */ - 0x95, 0x03, /* REPORT_COUNT (3) */ - 0x75, 0x01, /* REPORT_SIZE (1) */ - 0x81, 0x02, /* INPUT (Data,Var,Abs) */ - 0x95, 0x01, /* REPORT_COUNT (1) */ - 0x75, 0x05, /* REPORT_SIZE (5) */ - 0x81, 0x01, /* INPUT (Cnst,Ary,Abs) */ - 0x05, 0x01, /* USAGE_PAGE (Generic Desktop) */ - 0x09, 0x30, /* USAGE (X) */ - 0x09, 0x31, /* USAGE (Y) */ - 0x09, 0x38, /* USAGE (Wheel) */ - 0x15, 0x81, /* LOGICAL_MINIMUM (-127) */ - 0x25, 0x7f, /* LOGICAL_MAXIMUM (127) */ - 0x75, 0x08, /* REPORT_SIZE (8) */ - 0x95, 0x03, /* REPORT_COUNT (3) */ - 0x81, 0x06, /* INPUT (Data,Var,Rel) */ - 0xc0, /* END_COLLECTION */ - 0xc0, /* END_COLLECTION */ - 0x05, 0x0d, /* USAGE_PAGE (Digitizers) */ - 0x09, 0x01, /* USAGE (Pointer) */ - 0xa1, 0x01, /* COLLECTION (Application) */ - 0x85, 0x02, /* REPORT_ID (2) */ - 0x05, 0x0d, /* USAGE_PAGE (Digitizers) */ - 0x09, 0x01, /* USAGE (Digitizer) */ - 0xa1, 0x00, /* COLLECTION (Physical) */ - 0x09, 0x33, /* USAGE (Touch) */ - 0x09, 0x44, /* USAGE (Barrel Switch) */ - 0x09, 0x44, /* USAGE (Barrel Switch) */ - 0x15, 0x00, /* LOGICAL_MINIMUM (0) */ - 0x25, 0x01, /* LOGICAL_MAXIMUM (1) */ - 0x75, 0x01, /* REPORT_SIZE (1) */ - 0x95, 0x03, /* REPORT_COUNT (3) */ - 0x81, 0x02, /* INPUT (Data,Var,Abs) */ - 0x75, 0x01, /* REPORT_SIZE (1) */ - 0x95, 0x02, /* REPORT_COUNT (2) */ - 0x81, 0x01, /* INPUT (Cnst,Ary,Abs) */ - 0x09, 0x3c, /* USAGE (Invert) */ - 0x09, 0x38, /* USAGE (Transducer Index) */ - 0x09, 0x32, /* USAGE (In Range) */ - 0x75, 0x01, /* REPORT_SIZE (1) */ - 0x95, 0x03, /* REPORT_COUNT (3) */ - 0x81, 0x02, /* INPUT (Data,Var,Abs) */ - 0x05, 0x01, /* USAGE_PAGE (Generic Desktop) */ - 0x09, 0x30, /* USAGE (X) */ - 0x15, 0x00, /* LOGICAL_MINIMUM (0) */ - 0x26, 0xde, 0x27, /* LOGICAL_MAXIMUM (10206) */ - 0x75, 0x10, /* REPORT_SIZE (16) */ - 0x95, 0x01, /* REPORT_COUNT (1) */ - 0x81, 0x02, /* INPUT (Data,Var,Abs) */ - 0x09, 0x31, /* USAGE (Y) */ - 0x26, 0xfe, 0x1c, /* LOGICAL_MAXIMUM (7422) */ - 0x75, 0x10, /* REPORT_SIZE (16) */ - 0x95, 0x01, /* REPORT_COUNT (1) */ - 0x81, 0x02, /* INPUT (Data,Var,Abs) */ - 0x05, 0x0d, /* USAGE_PAGE (Digitizers) */ - 0x09, 0x30, /* USAGE (Tip Pressure) */ - 0x26, 0xff, 0x01, /* LOGICAL_MAXIMUM (511) */ - 0x75, 0x10, /* REPORT_SIZE (16) */ - 0x95, 0x01, /* REPORT_COUNT (1) */ - 0x81, 0x02, /* INPUT (Data,Var,Abs) */ - 0xc0, /* END_COLLECTION */ - 0x05, 0x0d, /* USAGE_PAGE (Digitizers) */ - 0x09, 0x00, /* USAGE (Undefined) */ - 0x85, 0x02, /* REPORT_ID (2) */ - 0x95, 0x01, /* REPORT_COUNT (1) */ - 0xb1, 0x02, /* FEATURE (Data,Var,Abs) */ - 0x09, 0x00, /* USAGE (Undefined) */ - 0x85, 0x03, /* REPORT_ID (3) */ - 0x95, 0x01, /* REPORT_COUNT (1) */ - 0xb1, 0x02, /* FEATURE (Data,Var,Abs) */ - 0xc0 /* END_COLLECTION */ -}; - diff --git a/sys/dev/usb/uhid_rdesc.h b/sys/dev/usb/uhid_rdesc.h new file mode 100644 index 00000000000..ecf24a6238f --- /dev/null +++ b/sys/dev/usb/uhid_rdesc.h @@ -0,0 +1,275 @@ +/* $OpenBSD: uhid_rdesc.h,v 1.1 2013/10/25 03:09:59 jeremy Exp $ */ +/* $NetBSD: ugraphire_rdesc.h,v 1.1 2000/12/29 01:47:49 augustss Exp $ */ +/* $FreeBSD: uxb360gp_rdesc.h,v 1.3 2008/05/24 18:35:55 ed Exp $ */ +/* + * Copyright (c) 2000 Nick Hibma + * Copyright (c) 2005 Ed Schouten + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +static uByte uhid_graphire_report_descr[] = { + 0x05, 0x0d, /* USAGE_PAGE (Digitizers) */ + 0x09, 0x01, /* USAGE (Digitizer) */ + 0xa1, 0x01, /* COLLECTION (Application) */ + 0x85, 0x02, /* REPORT_ID (2) */ + 0x05, 0x0d, /* USAGE_PAGE (Digitizers) */ + 0x09, 0x01, /* USAGE (Digitizer) */ + 0xa1, 0x00, /* COLLECTION (Physical) */ + 0x15, 0x00, /* LOGICAL_MINIMUM (0) */ + 0x25, 0x01, /* LOGICAL_MAXIMUM (1) */ + 0x09, 0x33, /* USAGE (Touch) */ + 0x95, 0x01, /* REPORT_COUNT (1) */ + 0x75, 0x01, /* REPORT_SIZE (1) */ + 0x81, 0x02, /* INPUT (Data,Var,Abs) */ + 0x09, 0x44, /* USAGE (Barrel Switch) */ + 0x95, 0x02, /* REPORT_COUNT (2) */ + 0x75, 0x01, /* REPORT_SIZE (1) */ + 0x81, 0x02, /* INPUT (Data,Var,Abs) */ + 0x09, 0x00, /* USAGE (Undefined) */ + 0x95, 0x02, /* REPORT_COUNT (2) */ + 0x75, 0x01, /* REPORT_SIZE (1) */ + 0x81, 0x03, /* INPUT (Cnst,Var,Abs) */ + 0x09, 0x3c, /* USAGE (Invert) */ + 0x95, 0x01, /* REPORT_COUNT (1) */ + 0x75, 0x01, /* REPORT_SIZE (1) */ + 0x81, 0x02, /* INPUT (Data,Var,Abs) */ + 0x09, 0x38, /* USAGE (Transducer Index) */ + 0x95, 0x01, /* REPORT_COUNT (1) */ + 0x75, 0x01, /* REPORT_SIZE (1) */ + 0x81, 0x02, /* INPUT (Data,Var,Abs) */ + 0x09, 0x32, /* USAGE (In Range) */ + 0x95, 0x01, /* REPORT_COUNT (1) */ + 0x75, 0x01, /* REPORT_SIZE (1) */ + 0x81, 0x02, /* INPUT (Data,Var,Abs) */ + 0x05, 0x01, /* USAGE_PAGE (Generic Desktop) */ + 0x09, 0x30, /* USAGE (X) */ + 0x15, 0x00, /* LOGICAL_MINIMUM (0) */ + 0x26, 0xde, 0x27, /* LOGICAL_MAXIMUM (10206) */ + 0x95, 0x01, /* REPORT_COUNT (1) */ + 0x75, 0x10, /* REPORT_SIZE (16) */ + 0x81, 0x02, /* INPUT (Data,Var,Abs) */ + 0x09, 0x31, /* USAGE (Y) */ + 0x26, 0xfe, 0x1c, /* LOGICAL_MAXIMUM (7422) */ + 0x95, 0x01, /* REPORT_COUNT (1) */ + 0x75, 0x10, /* REPORT_SIZE (16) */ + 0x81, 0x02, /* INPUT (Data,Var,Abs) */ + 0x05, 0x0d, /* USAGE_PAGE (Digitizers) */ + 0x09, 0x30, /* USAGE (Tip Pressure) */ + 0x26, 0xff, 0x01, /* LOGICAL_MAXIMUM (511) */ + 0x95, 0x01, /* REPORT_COUNT (1) */ + 0x75, 0x10, /* REPORT_SIZE (16) */ + 0x81, 0x02, /* INPUT (Data,Var,Abs) */ + 0xc0, /* END_COLLECTION */ + 0x05, 0x0d, /* USAGE_PAGE (Digitizers) */ + 0x09, 0x00, /* USAGE (Undefined) */ + 0x85, 0x02, /* REPORT_ID (2) */ + 0x95, 0x01, /* REPORT_COUNT (1) */ + 0xb1, 0x02, /* FEATURE (Data,Var,Abs) */ + 0x09, 0x00, /* USAGE (Undefined) */ + 0x85, 0x03, /* REPORT_ID (3) */ + 0x95, 0x01, /* REPORT_COUNT (1) */ + 0xb1, 0x02, /* FEATURE (Data,Var,Abs) */ + 0xc0, /* END_COLLECTION */ +}; + +static uByte uhid_graphire3_4x5_report_descr[] = { + 0x05, 0x01, /* USAGE_PAGE (Generic Desktop) */ + 0x09, 0x02, /* USAGE (Mouse) */ + 0xa1, 0x01, /* COLLECTION (Application) */ + 0x85, 0x01, /* REPORT_ID (1) */ + 0x09, 0x01, /* USAGE (Pointer) */ + 0xa1, 0x00, /* COLLECTION (Physical) */ + 0x05, 0x09, /* USAGE_PAGE (Button) */ + 0x19, 0x01, /* USAGE_MINIMUM (Button 1) */ + 0x29, 0x03, /* USAGE_MAXIMUM (Button 3) */ + 0x15, 0x00, /* LOGICAL_MINIMUM (0) */ + 0x25, 0x01, /* LOGICAL_MAXIMUM (1) */ + 0x95, 0x03, /* REPORT_COUNT (3) */ + 0x75, 0x01, /* REPORT_SIZE (1) */ + 0x81, 0x02, /* INPUT (Data,Var,Abs) */ + 0x95, 0x01, /* REPORT_COUNT (1) */ + 0x75, 0x05, /* REPORT_SIZE (5) */ + 0x81, 0x01, /* INPUT (Cnst,Ary,Abs) */ + 0x05, 0x01, /* USAGE_PAGE (Generic Desktop) */ + 0x09, 0x30, /* USAGE (X) */ + 0x09, 0x31, /* USAGE (Y) */ + 0x09, 0x38, /* USAGE (Wheel) */ + 0x15, 0x81, /* LOGICAL_MINIMUM (-127) */ + 0x25, 0x7f, /* LOGICAL_MAXIMUM (127) */ + 0x75, 0x08, /* REPORT_SIZE (8) */ + 0x95, 0x03, /* REPORT_COUNT (3) */ + 0x81, 0x06, /* INPUT (Data,Var,Rel) */ + 0xc0, /* END_COLLECTION */ + 0xc0, /* END_COLLECTION */ + 0x05, 0x0d, /* USAGE_PAGE (Digitizers) */ + 0x09, 0x01, /* USAGE (Pointer) */ + 0xa1, 0x01, /* COLLECTION (Application) */ + 0x85, 0x02, /* REPORT_ID (2) */ + 0x05, 0x0d, /* USAGE_PAGE (Digitizers) */ + 0x09, 0x01, /* USAGE (Digitizer) */ + 0xa1, 0x00, /* COLLECTION (Physical) */ + 0x09, 0x33, /* USAGE (Touch) */ + 0x09, 0x44, /* USAGE (Barrel Switch) */ + 0x09, 0x44, /* USAGE (Barrel Switch) */ + 0x15, 0x00, /* LOGICAL_MINIMUM (0) */ + 0x25, 0x01, /* LOGICAL_MAXIMUM (1) */ + 0x75, 0x01, /* REPORT_SIZE (1) */ + 0x95, 0x03, /* REPORT_COUNT (3) */ + 0x81, 0x02, /* INPUT (Data,Var,Abs) */ + 0x75, 0x01, /* REPORT_SIZE (1) */ + 0x95, 0x02, /* REPORT_COUNT (2) */ + 0x81, 0x01, /* INPUT (Cnst,Ary,Abs) */ + 0x09, 0x3c, /* USAGE (Invert) */ + 0x09, 0x38, /* USAGE (Transducer Index) */ + 0x09, 0x32, /* USAGE (In Range) */ + 0x75, 0x01, /* REPORT_SIZE (1) */ + 0x95, 0x03, /* REPORT_COUNT (3) */ + 0x81, 0x02, /* INPUT (Data,Var,Abs) */ + 0x05, 0x01, /* USAGE_PAGE (Generic Desktop) */ + 0x09, 0x30, /* USAGE (X) */ + 0x15, 0x00, /* LOGICAL_MINIMUM (0) */ + 0x26, 0xde, 0x27, /* LOGICAL_MAXIMUM (10206) */ + 0x75, 0x10, /* REPORT_SIZE (16) */ + 0x95, 0x01, /* REPORT_COUNT (1) */ + 0x81, 0x02, /* INPUT (Data,Var,Abs) */ + 0x09, 0x31, /* USAGE (Y) */ + 0x26, 0xfe, 0x1c, /* LOGICAL_MAXIMUM (7422) */ + 0x75, 0x10, /* REPORT_SIZE (16) */ + 0x95, 0x01, /* REPORT_COUNT (1) */ + 0x81, 0x02, /* INPUT (Data,Var,Abs) */ + 0x05, 0x0d, /* USAGE_PAGE (Digitizers) */ + 0x09, 0x30, /* USAGE (Tip Pressure) */ + 0x26, 0xff, 0x01, /* LOGICAL_MAXIMUM (511) */ + 0x75, 0x10, /* REPORT_SIZE (16) */ + 0x95, 0x01, /* REPORT_COUNT (1) */ + 0x81, 0x02, /* INPUT (Data,Var,Abs) */ + 0xc0, /* END_COLLECTION */ + 0x05, 0x0d, /* USAGE_PAGE (Digitizers) */ + 0x09, 0x00, /* USAGE (Undefined) */ + 0x85, 0x02, /* REPORT_ID (2) */ + 0x95, 0x01, /* REPORT_COUNT (1) */ + 0xb1, 0x02, /* FEATURE (Data,Var,Abs) */ + 0x09, 0x00, /* USAGE (Undefined) */ + 0x85, 0x03, /* REPORT_ID (3) */ + 0x95, 0x01, /* REPORT_COUNT (1) */ + 0xb1, 0x02, /* FEATURE (Data,Var,Abs) */ + 0xc0 /* END_COLLECTION */ +}; + +/* + * The descriptor has no output report format, thus preventing you from + * controlling the LEDs and the built-in rumblers. + */ +static const uByte uhid_xb360gp_report_descr[] = { + 0x05, 0x01, /* USAGE PAGE (Generic Desktop) */ + 0x09, 0x05, /* USAGE (Gamepad) */ + 0xa1, 0x01, /* COLLECTION (Application) */ + /* Unused */ + 0x75, 0x08, /* REPORT SIZE (8) */ + 0x95, 0x01, /* REPORT COUNT (1) */ + 0x81, 0x01, /* INPUT (Constant) */ + /* Byte count */ + 0x75, 0x08, /* REPORT SIZE (8) */ + 0x95, 0x01, /* REPORT COUNT (1) */ + 0x05, 0x01, /* USAGE PAGE (Generic Desktop) */ + 0x09, 0x3b, /* USAGE (Byte Count) */ + 0x81, 0x01, /* INPUT (Constant) */ + /* D-Pad */ + 0x05, 0x01, /* USAGE PAGE (Generic Desktop) */ + 0x09, 0x01, /* USAGE (Pointer) */ + 0xa1, 0x00, /* COLLECTION (Physical) */ + 0x75, 0x01, /* REPORT SIZE (1) */ + 0x15, 0x00, /* LOGICAL MINIMUM (0) */ + 0x25, 0x01, /* LOGICAL MAXIMUM (1) */ + 0x35, 0x00, /* PHYSICAL MINIMUM (0) */ + 0x45, 0x01, /* PHYSICAL MAXIMUM (1) */ + 0x95, 0x04, /* REPORT COUNT (4) */ + 0x05, 0x01, /* USAGE PAGE (Generic Desktop) */ + 0x09, 0x90, /* USAGE (D-Pad Up) */ + 0x09, 0x91, /* USAGE (D-Pad Down) */ + 0x09, 0x93, /* USAGE (D-Pad Left) */ + 0x09, 0x92, /* USAGE (D-Pad Right) */ + 0x81, 0x02, /* INPUT (Data, Variable, Absolute) */ + 0xc0, /* END COLLECTION */ + /* Buttons 5-11 */ + 0x75, 0x01, /* REPORT SIZE (1) */ + 0x15, 0x00, /* LOGICAL MINIMUM (0) */ + 0x25, 0x01, /* LOGICAL MAXIMUM (1) */ + 0x35, 0x00, /* PHYSICAL MINIMUM (0) */ + 0x45, 0x01, /* PHYSICAL MAXIMUM (1) */ + 0x95, 0x07, /* REPORT COUNT (7) */ + 0x05, 0x09, /* USAGE PAGE (Button) */ + 0x09, 0x08, /* USAGE (Button 8) */ + 0x09, 0x07, /* USAGE (Button 7) */ + 0x09, 0x09, /* USAGE (Button 9) */ + 0x09, 0x0a, /* USAGE (Button 10) */ + 0x09, 0x05, /* USAGE (Button 5) */ + 0x09, 0x06, /* USAGE (Button 6) */ + 0x09, 0x0b, /* USAGE (Button 11) */ + 0x81, 0x02, /* INPUT (Data, Variable, Absolute) */ + /* Unused */ + 0x75, 0x01, /* REPORT SIZE (1) */ + 0x95, 0x01, /* REPORT COUNT (1) */ + 0x81, 0x01, /* INPUT (Constant) */ + /* Buttons 1-4 */ + 0x75, 0x01, /* REPORT SIZE (1) */ + 0x15, 0x00, /* LOGICAL MINIMUM (0) */ + 0x25, 0x01, /* LOGICAL MAXIMUM (1) */ + 0x35, 0x00, /* PHYSICAL MINIMUM (0) */ + 0x45, 0x01, /* PHYSICAL MAXIMUM (1) */ + 0x95, 0x04, /* REPORT COUNT (4) */ + 0x05, 0x09, /* USAGE PAGE (Button) */ + 0x19, 0x01, /* USAGE MINIMUM (Button 1) */ + 0x29, 0x04, /* USAGE MAXIMUM (Button 4) */ + 0x81, 0x02, /* INPUT (Data, Variable, Absolute) */ + /* Triggers */ + 0x75, 0x08, /* REPORT SIZE (8) */ + 0x15, 0x00, /* LOGICAL MINIMUM (0) */ + 0x26, 0xff, 0x00, /* LOGICAL MAXIMUM (255) */ + 0x35, 0x00, /* PHYSICAL MINIMUM (0) */ + 0x46, 0xff, 0x00, /* PHYSICAL MAXIMUM (255) */ + 0x95, 0x02, /* REPORT SIZE (2) */ + 0x05, 0x01, /* USAGE PAGE (Generic Desktop) */ + 0x09, 0x32, /* USAGE (Z) */ + 0x09, 0x35, /* USAGE (Rz) */ + 0x81, 0x02, /* INPUT (Data, Variable, Absolute) */ + /* Sticks */ + 0x75, 0x10, /* REPORT SIZE (16) */ + 0x16, 0x00, 0x80, /* LOGICAL MINIMUM (-32768) */ + 0x26, 0xff, 0x7f, /* LOGICAL MAXIMUM (32767) */ + 0x36, 0x00, 0x80, /* PHYSICAL MINIMUM (-32768) */ + 0x46, 0xff, 0x7f, /* PHYSICAL MAXIMUM (32767) */ + 0x95, 0x04, /* REPORT COUNT (4) */ + 0x05, 0x01, /* USAGE PAGE (Generic Desktop) */ + 0x09, 0x30, /* USAGE (X) */ + 0x09, 0x31, /* USAGE (Y) */ + 0x09, 0x33, /* USAGE (Rx) */ + 0x09, 0x34, /* USAGE (Ry) */ + 0x81, 0x02, /* INPUT (Data, Variable, Absolute) */ + /* Unused */ + 0x75, 0x30, /* REPORT SIZE (48) */ + 0x95, 0x01, /* REPORT COUNT (1) */ + 0x81, 0x01, /* INPUT (Constant) */ + 0xc0, /* END COLLECTION */ +}; diff --git a/sys/dev/usb/uhidev.c b/sys/dev/usb/uhidev.c index cd3f797773a..341d08e2aca 100644 --- a/sys/dev/usb/uhidev.c +++ b/sys/dev/usb/uhidev.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uhidev.c,v 1.46 2013/09/20 15:34:50 mpi Exp $ */ +/* $OpenBSD: uhidev.c,v 1.47 2013/10/25 03:09:59 jeremy Exp $ */ /* $NetBSD: uhidev.c,v 1.14 2003/03/11 16:44:00 augustss Exp $ */ /* @@ -55,8 +55,10 @@ #include -/* Report descriptor for broken Wacom Graphire */ -#include +#ifndef SMALL_KERNEL +/* Replacement report descriptors for devices shipped with broken ones */ +#include +#endif /* !SMALL_KERNEL */ #ifdef UHIDEV_DEBUG #define DPRINTF(x) do { if (uhidevdebug) printf x; } while (0) @@ -99,7 +101,15 @@ uhidev_match(struct device *parent, void *match, void *aux) if (uaa->iface == NULL) return (UMATCH_NONE); id = usbd_get_interface_descriptor(uaa->iface); - if (id == NULL || id->bInterfaceClass != UICLASS_HID) + if (id == NULL) + return (UMATCH_NONE); +#ifndef SMALL_KERNEL + if (uaa->vendor == USB_VENDOR_MICROSOFT && + uaa->product == USB_PRODUCT_MICROSOFT_XBOX360_CONTROLLER && + id->bInterfaceNumber == 0) + return (UMATCH_VENDOR_PRODUCT); +#endif /* !SMALL_KERNEL */ + if (id->bInterfaceClass != UICLASS_HID) return (UMATCH_NONE); if (usbd_get_quirks(uaa->device)->uq_flags & UQ_BAD_HID) return (UMATCH_NONE); @@ -180,6 +190,7 @@ uhidev_attach(struct device *parent, struct device *self, void *aux) /* XXX need to extend this */ descptr = NULL; +#ifndef SMALL_KERNEL if (uaa->vendor == USB_VENDOR_WACOM) { static uByte reportbuf[] = {2, 2, 2}; @@ -200,7 +211,13 @@ uhidev_attach(struct device *parent, struct device *self, void *aux) /* Keep descriptor */ break; } + } else if (uaa->vendor == USB_VENDOR_MICROSOFT && + uaa->product == USB_PRODUCT_MICROSOFT_XBOX360_CONTROLLER) { + /* The Xbox 360 gamepad has no report descriptor. */ + size = sizeof uhid_xb360gp_report_descr; + descptr = uhid_xb360gp_report_descr; } +#endif /* !SMALL_KERNEL */ if (descptr) { desc = malloc(size, M_USBDEV, M_NOWAIT); -- cgit v1.2.3