# HOWTO: Xbox 360 controller on Linux

## Waninkoko

Introduction

This HOWTO explains how to get working the Xbox 360 controller on Linux. Wireless controller doesn't work on PC at the moment.

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 apply a small patch to our kernel tree to modify the current xpad driver.

Download the patch from

```
http://kamikaze.waninkoko.info/misc/xpad-360-support-2.6.21.patch
```

And apply it

```
# cd /usr/src/linux

# cat xpad-360-support-2.6.21.patch | patch -p1
```

That's all! 

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:

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
```

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:

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!

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.Last edited by Waninkoko on Thu May 03, 2007 9:19 pm; edited 2 times in total

----------

## thoffmeyer

This is pretty nifty...

----------

## mitch

Thank You so Much

Really Good How to  :Smile: 

----------

## flazz

thanks, from as a sucker who made a usb/xpad-s an found out it didn't work for shit.

also a must have especially for xpad owners: qjoypad. it lets you map joystick axi and buttons to keyboard and mouse events.

this howto should go in the wiki  :Exclamation: 

----------

## simmete

Hi, can I use also a NON 360 joypad?

I have a "normal" xbox, can I use it?

Have you any suggestion about the hardware adapter?

Thanks in advance

----------

## dob

http://gentoo-wiki.com/HOWTO_Xbox_360_controller_on_Linux

As 2.6.19 broke the driver, I was wondering why it had not been integrated into the mainline kernel sources

After all:

a) this is GPL code

b) it works!

So, why not?

----------

## dogshu

OK, I guess 2.6.20 *really* broke the driver, I have it compiled (replacing "SLAB_ATOMIC" with "GFP_KERNEL") and installed, but it doesn't recognize the controllers.  Anybody have this working with 2.6.20?

----------

## darklegion

 *dogshu wrote:*   

> OK, I guess 2.6.20 *really* broke the driver, I have it compiled (replacing "SLAB_ATOMIC" with "GFP_KERNEL") and installed, but it doesn't recognize the controllers.  Anybody have this working with 2.6.20?

 

I don't use the X360 version but the 2.6.20 version of the regular xpad driver uses GFP_ATOMIC instead of GFP_KERNEL, so changing SLAB_ATOMIC to GFP_ATOMIC should fix it for you.

----------

## ll4e

 *Quote:*   

> 
> 
> Hi, can I use also a NON 360 joypad?
> 
> I have a "normal" xbox, can I use it?
> ...

 

Yes, you can. After all, there's a Gentoo port for the Xbox (GentooX). The controller is USB-compatible (you need a converter-cable).. http://gentoo-wiki.com/HOWTO_Gentoo_for_Xbox#Getting_Xbox_Hardware_to_Work -> have a look at the kernel configuration, think you'll find it there  :Smile: 

----------

## weaksauce

Good call darklegion, thanks for that.  That fixed the compile error for both this driver and for my remote's driver in lirc.  Now if only ivtv worked with 2.6.20....

----------

## nex_tym

Did anyone get it to work in 2.6.20.1? I did get it to work in 2.6.17.13 by following those directions. One thing I did have to do is add my controllers product id, and vendor info in the xpad.c file. Works perfect in 2.6.17.13. In 2.6.20.1 I did the following steps.

#include <linux/usb_input.h> >>>>> #include <linux/usb/input.h>

#include <linux/config.h> >>>>> /* #include <linux/config.h> */

input_regs(dev, regs); >>>>  /* input_regs(dev, regs); */

SLAB_ATOMIC >>>> GFP_ATOMIC

Also had to add my controller info to the xpad.c file. It does compile, but I get this 

```
drivers/usb/input/xpad.c: In function 'xpad_probe':

drivers/usb/input/xpad.c:452: warning: passing argument 6 of 'usb_fill_int_urb' from incompatible pointer type
```

I am guessing this is the problem since its not loading the controller up. Same problem as dogshu.

Any help would be appreciated. Thanks

----------

## brian33x51

Answer here is:

struct pt_regs *regs

pretty much wherever you see this in an argument list or see "regs" getting passed around needs to be commented out.

the USB interface changed some.

Start looking and commenting starting at function "xpad_irq_in"

I may test this later on tonight.

----------

## soonland

for those who dont know, there is a wireless usb receiver for xbox 360 controller you can plug on you pc

----------

## Waninkoko

Howto updated!! Driver working with kernel 2.6.21

----------

## nullkey

I added a very experimental support for XBox 360 Wireless controller, please see Gentoo-Wiki: HOWTO Xbox 360 controller on Linux. Could someone please test the new driver and report back whether it works?

I'm not planning to maintain wireless controller support since I don't own one (I just borrowed one to add basic support). There are lots of information about xbox 360 controllers and even an open-source OS X driver for both wireless and wired, so someone with more experience about driver development can easily develop the linux driver further.

----------

## apanloco

Can someone who has access to a Xbox 360 Wireless Gaming Adapter for PC and a controller please give me the dmesg output. I need to know whether it is USB1.1 or USB2.0 before I go and buy this. (For anyone who wonders, I have extended USB inside my wall 15 meters, and it does not work for USB 2.0... but most gamepads are 1.1. However, this thing seems to support high-speed devices like cameras but I need to know for sure)

Would really appreciate it!

Apan

----------

