From owner-freebsd-usb@FreeBSD.ORG Fri Dec 9 14:40:40 2005 Return-Path: X-Original-To: freebsd-usb@hub.freebsd.org Delivered-To: freebsd-usb@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 4321916A41F for ; Fri, 9 Dec 2005 14:40:40 +0000 (GMT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 053FF43D53 for ; Fri, 9 Dec 2005 14:40:09 +0000 (GMT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.13.3/8.13.3) with ESMTP id jB9Ee325037992 for ; Fri, 9 Dec 2005 14:40:03 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.13.3/8.13.1/Submit) id jB9Ee2Zl037989; Fri, 9 Dec 2005 14:40:03 GMT (envelope-from gnats) Resent-Date: Fri, 9 Dec 2005 14:40:03 GMT Resent-Message-Id: <200512091440.jB9Ee2Zl037989@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-usb@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Ed Schouten Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 54EBD16A41F for ; Fri, 9 Dec 2005 14:38:03 +0000 (GMT) (envelope-from ed@hoeg.nl) Received: from palm.hoeg.nl (mx0.hoeg.nl [83.98.131.211]) by mx1.FreeBSD.org (Postfix) with ESMTP id 3612843D7E for ; Fri, 9 Dec 2005 14:37:57 +0000 (GMT) (envelope-from ed@hoeg.nl) Received: by palm.hoeg.nl (Postfix, from userid 1000) id 463301702B; Fri, 9 Dec 2005 15:37:54 +0100 (CET) Message-Id: <20051209143754.463301702B@palm.hoeg.nl> Date: Fri, 9 Dec 2005 15:37:54 +0100 (CET) From: Ed Schouten To: FreeBSD-gnats-submit@FreeBSD.org X-Send-Pr-Version: 3.113 Cc: Rink Springer Subject: usb/90141: uhid(4): Add support for Microsoft's Xbox360 gamepad X-BeenThere: freebsd-usb@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Ed Schouten List-Id: FreeBSD support for USB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 09 Dec 2005 14:40:40 -0000 >Number: 90141 >Category: usb >Synopsis: uhid(4): Add support for Microsoft's Xbox360 gamepad >Confidential: no >Severity: non-critical >Priority: medium >Responsible: freebsd-usb >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Fri Dec 09 14:40:02 GMT 2005 >Closed-Date: >Last-Modified: >Originator: Ed Schouten >Release: FreeBSD 5.4-STABLE i386 >Organization: n/a >Environment: System: FreeBSD palm.hoeg.nl 5.4-STABLE FreeBSD 5.4-STABLE #0: Mon Oct 17 00:03:47 CEST 2005 root@palm.hoeg.nl:/usr/obj/usr/src/sys/PALM i386 >Description: The guys at Microsoft have released their new Xbox, the Xbox 360, within the last few weeks. The console comes with controllers which have regular USB connectors but are not entirely HID compliant: - It has no HID report descriptor - It uses a different DeviceClass (UICLASS_VENDOR) FreeBSD attaches the ugen(4) driver which is not really useful. >How-To-Repeat: Plug a (wired) Xbox 360 gamepad in one of the spare USB ports of your system. uhid(4) won't attach to it. >Fix: A patch is available at: - http://g-rave.nl/files/xbox/freebsd-xbox360-gamepad.diff The patch works as follows: The USB_MATCH function has been altered to attach when the device has the same InterfaceClass, InterfaceSubClass and InterfaceProtocol as the Xbox 360 gamepad. It does not look at the USB device and vendor ID because then we should update the driver each time a different vendor releases a compatible gamepad. The USB_ATTACH function has also been altered; I added the 'rdesc' variable containing a pointer to the replacement descriptor making it easier to add more devices that need another report descriptor. The 'uxb360gp_rdesc.h' file contains a hand-crafted report descriptor. It is based on the following documentation: - Xbox 1 gamepad - has a lot in common: http://euc.jp/periphs/xbox-controller.en.html - Xbox 360 gamepad: http://www.free60.org/wiki/Gamepad After applying this patch, FreeBSD detects the gamepad as a regular USB HID device: | $ dmesg | grep '^uhid2:' | uhid2: Microsoft Corporation Controller, rev 2.00/1.10, addr 2, iclass 255/93 I've tested the gamepad with Neverball. I also did a lot of debugging with usbhidctl(1). It works quite good. The patch has some small caveats though: - The descriptor has no output report format, thus preventing you from controlling the LEDs and the built-in rumblers. I do not have any information about its format. - The Y-axis of both the left and the right stick are inverted. I looked through the HID spec, but it seems there is no way to make the {Physical,Logical} Maximum of an object lower than its Minimum. Users should use the checkbox present in most games. Windows also supports these gamepads; it downloads a driver from the internet when plugged in. The folks at xbox-linux.org also made a Linux driver which does not use the HID layer at all for some reason. >Release-Note: >Audit-Trail: >Unformatted: