usb/90141: uhid(4): Add support for Microsoft's Xbox360 gamepad

Ed Schouten ed at fxq.nl
Fri Dec 9 06:40:40 PST 2005


>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 at 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:


More information about the freebsd-usb mailing list