Gentoo Wiki




This HOWTO explains how to get the Xbox 360 controller working on Linux via the kernel xpad driver. Please note that Wireless controller support is still experimental.

An alternative to this is the Xbox userspace driver available at:

Which provides support for Xbox1 gamepads, Xbox360 USB gamepads and Xbox360 wireless gamepads.

Compiling xpad module

We have to compile the xpad module and install it. For that, we are going to prepare a new kernel and compile it.

Getting kernel sources

It's time to get lastest kernel sources (skip this step if you don't want to get lastest sources). So, we emerge gentoo-sources.

# emerge gentoo-sources

Preparing kernel

Now we're going to add support for Xbox 360 controllers to kernel xpad driver. You can either replace driver completely with very experimental one which supports Wireless controllers or download a patch which is more stable but adds support for only Wired controllers.

Driver for both Wired and Wireless controllers

Download the kernel patch and apply it (it should work with another kernel versions)

# cd /usr/src/linux
# wget ""
# cat xpad-360-support-2.6.22.patch | patch -p1

or download the new driver and copy it to the kernel source directory (Note: at least on 2.6.23, the directory to copy into is /usr/src/linux/drivers/input/joystick)

# wget "*checkout*/xbox-linux/kernel-2.6/drivers/usb/input/xpad.c"
# wget "*checkout*/xbox-linux/kernel-2.6/drivers/usb/input/xpad.h"
# cp xpad.c xpad.h /usr/src/linux/drivers/usb/input
Code: Kernel 2.6.24-gentoo-r4
as for this kernel version, xpad.c and xpad.h goes in /usr/src/linux/drivers/input/joystick/

Compiling kernel

It's time to compile kernel but at first we have to change configuration.

To get the controller working we have to compile as module (or compile into the kernel) the options from below:

Code: Kernel options
Device Drivers -> Input device support -> Joystick interface
Device Drivers -> USB support -> USB Human Interface Device (full HID) support
Device Drivers -> USB support -> USB Human Interface Device (full HID) support -> HID input layer support (this cannot be compiled as a module)
Device Drivers -> USB support -> X-Box gamepad support

On newer kernels it may be:

Code: Kernel options
Device Drivers -> Input device support -> Joysticks/Gamepads -> X-Box gamepad support

Save config and compile kernel!

# make && make modules_install

Loading modules

We're going to load needed modules. We have to load this modules: joydev, usbhid, xpad

# modprobe joydev usbhid xpad

Connect the controller. If all is working correctly dmesg will say something like:

Code: dmesg
input: Microsoft Xbox 360 Controller as /class/input/input6

Testing the controller

Well, now it's time to test the controller. Run:

# cat /dev/input/js0

and press any button. If appear some kind of symbols means that the controller is working. Congratulations!

or install the joystick ebuild

# emerge joystick

that comes with the jstest program.

# jstest /dev/input/js0

this shows all the buttons and axis recogniced by the driver.

Further information

This method has been tested on a x86 machine, with 2.6.14-gentoo-r5 kernel. Controller has been tested with TuxRacer and works perfectly. Controller has also been tested with an X86_64 machine and works perfectly.

Troubles and Troubleshooting

There are a number of issues supporting more than one Xbox 360 controller at a time, as well as the driver creating a ridiculous number of axis/buttons (10+ for each). As per a recent patch to the CVS driver the "blinking" Big-X on the controller has stopped, and the driver now only creates one usb entry.

Still, there are some hiccups that might annoy a person. ZSNES will have some very strange errors due to the sheer number of axis/buttons. It is my suggestion to remove the entries for treating the D-Pad as four buttons and restrict it to working as two axis, as well as removing the legacy analog a/b/x/y/white/black support to remove 6 more axis. To do so requires you to remove the entries within the top-level arrays and the code that reports the information below it. I've prepared a modified xpad.c in order to solve a lot of these problems. It implements the following changes: Makes the digital pad into two axes rather than four buttons (frees buttons), rebinds the digital pad to be the primary axis (fixes programs that don't let you choose the axis ala dgen and fakeNES), expands the digital pad's axes to work for larger values (left is now -32767 instead of -1), removes support for analog buttons (makes a couple less buttons) and (probably) severely kills original xbox controller support.

If "modprobe xpad" seems to fail, run dmesg. This error:

Code: dmesg
 Please convert to input_allocate_device() or contact

Indicates your kernel is incompatible. Notably, this dies in 2.6.15 kernels (with the exception of a particular Fedora kernel that is a 2.6.16 kernel in disguise). It works in 2.6.16, so upgrade your kernel!

Wireless 360 controller

(xpad-driver v 0.0.8) The wireless controller ring of light doesn't show the correct controller number but instead keeps blinking as if it can't connect, it does however still send the correct button presses and axis and it does not turn itself off (as it does to save batteries when it's being left without connection after you yank the power cord from the 360). Also there is no way to turn the controller off other than pulling the batteries.

Problems with Left Trigger being 3rd axis

Some games may have issues with the 3rd axis being set as the left trigger, and the 6th axis being the right stick Y axis. To fix this:

Edit the /usr/src/linux/drivers/input/joystick/xpad.c and replace every instance of "ABS_RY" with "ABS_Z" and replace all "ABS_Z" with "ABS_RY".

This places the left trigger as the 6th axis and the right Y axis as the 3rd axis.

DDR Pads

Most Pads, Adding unknown pads

NEW! The linux kernel driver has been updated for 2.6.19 to handle DDR pads correctly. If you use this kernel version, your ORIGINAL XBOX (maybe not 360) ddr pads should work out of the box. If they don't, please email binary1230-at-yahoo-D0t-com with your USB product/vendor ID's for your pad (cat /proc/bus/usb/devices).

It should be trivial to do the same modification for the 360 driver.

DPAD troubles

Some DDR Pads may come-up with their DPADs as axes instead of buttons. This is bad for for some applications(stepmania).

two solutions: (kernel >2.6.19) 1. modprobe the xpad module with the dpad_to_buttons option

#modprobe -r xpad
#modprobe xpad dpad_to_buttons=1

2. recompile module

In some older or newer versions there may already be an option called USB_XPAD_DPAD_MAPPING or something similar, check this first and set it to N' for DDRpad(dpad to buttons) default behavior. If this doesn't work/exist, you may also need to follow the procedure below:

Check the output of /proc/bus/usb/devices for your xpad's vendor/productID:

T:  Bus=02 Lev=01 Prnt=01 Port=00 Cnt=01 Dev#=  4 Spd=12  MxCh= 0
D:  Ver= 1.10 Cls=00(>ifc ) Sub=00 Prot=00 MxPS=64 #Cfgs=  1
P:  Vendor=045e ProdID=0202 Rev= 1.02
C:* #Ifs= 1 Cfg#= 1 Atr=80 MxPwr=100mA
I:* If#= 0 Alt= 0 #EPs= 1 Cls=58(unk. ) Sub=42 Prot=00 Driver=xpad
E:  Ad=81(I) Atr=03(Int.) MxPS=  32 Ivl=4ms

Now if you examine the xpad.c in cd /usr/src/linux/drivers/input/joystick/xpad.c you'll see a bunch of lines corresponding to vendor and product IDs and DPAD behavior. Add your device if its not present(and submit it to the the kernel-hacker above for future inclusion).

Unfortunately my pad replicates the normal Xbox padv1's Vendor and Product IDs, and thus you must change the default xpad behavior:

 } xpad_device[] = {
       { 0x045e, 0x0202, "Microsoft X-Box pad v1 (US)", MAP_DPAD_TO_AXES },
       { 0x045e, 0x0289, "Microsoft X-Box pad v2 (US)", MAP_DPAD_TO_AXES },

which begs for changing to this:

 } xpad_device[] = {
       { 0x045e, 0x0202, "Microsoft X-Box pad v1 (US)", MAP_DPAD_TO_BUTTONS },
       { 0x045e, 0x0289, "Microsoft X-Box pad v2 (US)", MAP_DPAD_TO_AXES },

Recompile, and test in jscalibrator. Your arrows (on a ddrpad) should now function as buttons.

Retrieved from ""

Last modified: Thu, 04 Sep 2008 22:21:00 +0000 Hits: 33,132