Skip to content

Using XBMC for Linux with an XBOX 360 Wireless Controller and the Userspace USB Driver xboxdrv

If you are running XBMC for Linux, you can use your Xbox1 (wired), Xbox360 (wired) and Xbox 360 (wireless) controller as a remote just like your original xbox controller with your original Xbox. If you want to use a wireless Xbox 360 controller with Linux, you will need to purchase an Xbox 360™ Wireless Gaming Receiver for Windows®. Despite the Wireless Gaming Receiver being branded as “For Windows”, it is fairly easy to get working quite well under Linux.

The Linux kernel has built in support for Xbox gamepads via a kernel module. The latest SVN XBMC has a default Keymap.xml with some support for this module, but a nice alternative is the Userspace Xbox/Xbox360 USB Gamepad Driver for Linux. I found it to be more stable and easier to get up and running. The only downside is that you will have to write your own Keymap.xml, but you can use my Keymap.xml which mimics the original Xbox controller binding as closely as possible.

UPDATE:
Here are some more up to date sources for getting xboxdrv working with XBMC.
xboxdrv & XMBC live forum thread
Ubuntu 9.04 xboxdrv XMBC How-to

See the README in the source of the Gamepad Driver for instructions on how to get it running, or if you run Ubuntu Linux there is a How-to on the Ubuntu forums at http://ubuntuforums.org/showthread.php?t=825464

I start the Userspace Xbox/Xbox360 USB Gamepad Driver with following options:

xboxdrv --wid 0 -s -l 2 --dpad-as-button --deadzone 12000

‘-s’ puts the driver in silent mode so it won’t spam the screen with messages.
‘-l 2′ tells led light 1 on the controller to blink twice and then stay lit.
‘–dpad-as-button’ turns the dpad into button events instead of an axis. This is important so you can scroll in the XBMC menus.
‘–deadzone 12000′ sets a deadzone for the thumbsticks. 12000 works well with XBMC for things like analog seeking but you might want to play around with that value.

In order for XBMC for linux to use this driver you have to create your own Keymap.xml file with the correct joystick name, which is “Xbox Gamepad (userspace driver)”. If you want to save some time, you can use my Keymap.xml. Place it in your ~/.xbmc/userdata/ folder, and make sure it’s named Keymap.xml(With a capital K) and not keymap.xml.

Download Keymap.xml

Update: jstultz pointed out that it is very important that the filename be Keymap.xml, not keymap.xml.
Checkout this discussion on the xbmc forums:
http://xbmc.org/forum/showthread.php?p=219809#post219809

After placing the Keymap.xml file in your userdata folder and running the xboxdrv command, you can start xbmc. You should then be able to use your controller with XBMC.

If the controller doesn’t work, the problem is most likely with permissions. Make sure the user you run xboxdrv and xbmc as has all the correct permissions to access usb devices and joysticks. This usually means both read and write permission for the file ‘/dev/input/uinput’.

The wireless Xbox 360 controller turns off automatically after a certain amount of inactivity. As a result, the battery lasts longer then other controllers I’ve tried. If you use the rechargeable battery, the controller becomes a pretty nice solution for an XBMC media center remote. Pressing the Xbox button on the controller will power the controller back on and it will start functioning again, so don’t be worried about the controller not working after it powers off.

22 Comments

  1. colsen wrote:

    Great article!

    I have a spare beta bright light board lying around, is there anyway I could get it to interact with XBMC on linux? Perhaps by displaying the currently playing video file?

    Saturday, September 13, 2008 at 3:18 pm | Permalink
  2. jstultz wrote:

    It’s important to note that (at least in my experience getting this to work) it must be Keymap.xml, not keymap.xml (as it is capitalized in your link).

    Sunday, October 12, 2008 at 6:56 pm | Permalink
  3. Jon wrote:

    So this seems to work okay, but what is the best way to load this on boot. It seems to require root to run it.; I guess I don’t have the permissions set up right.

    Wednesday, November 12, 2008 at 7:44 pm | Permalink
  4. Jon wrote:

    Okay, what I did might be dirty, but it works.

    sudo cp xboxdrv /usr/local/bin
    sudo visudo

    input this line at the end
    %admin ALL = (ALL) NOPASSWD:/usr/local/bin/xboxdrv

    then I added your line my fluxbox startup script

    Wednesday, November 12, 2008 at 8:46 pm | Permalink
  5. ian wrote:

    Good stuff! Thanks.

    Monday, January 5, 2009 at 7:58 pm | Permalink
  6. ian wrote:

    Tony, I’ve found that if my Xbox controller turns off and I reconnect, the controller LEDs keep flashing annoyingly. The only way to cure that is to restart xboxdrv, but then the controller stops working until I restart XBMC. Has this happened to you?

    Thursday, January 15, 2009 at 1:31 am | Permalink
  7. tonymagro wrote:

    Ian, the problem you mentioned also happens to me. My guess is that the xbox controller sends a signal to indicate it has turned back on but the xboxdrv ignores this signal and doesn’t tell the controller to light up the LEDs based on the parameters. I’ve never looked at the code so it might be more complicated. Since this problem would most likely only happen with the wireless controller I think the developer probably just overlooked it. I recently posted on their google group about it and if the feature is possible I hope it will make it into a future release.

    Thursday, January 15, 2009 at 1:59 am | Permalink
  8. ian wrote:

    Sweet, thanks!

    Thursday, January 15, 2009 at 2:22 am | Permalink
  9. tonymagro wrote:

    Ian, I got a reply back from the xboxdrv developer and he added the feature. You can test it out if you grab the latest development version with

    git clone http://pingus.seul.org/~grumbel/xboxdrv.git

    I was having some issues with the dev version and the dpad buttons “sticking” but I am not sure if the problem was with the new version or my setup. Let me know if you see similar problems.

    Thursday, January 15, 2009 at 11:30 am | Permalink
  10. Christian wrote:

    I just compiled and tested the latest git version and also have the dpad issues. First I thought it didn’t register presses sometimes, but from your comment I do believe they are in fact sticking, thus not registering new ones.

    Friday, February 27, 2009 at 10:50 am | Permalink
  11. Radman wrote:

    wasn’t there a new release for this?

    Sunday, March 1, 2009 at 5:00 pm | Permalink
  12. Fili wrote:

    hi, I am stumped as to what is wrong with my Xbox360 controller, we only used it a few times here and there in the last year since we purchased it, and now one of the controllers, when we turn it on, flashes then just continues flashing and we can’t use it at all, does anyone know how to fix this (of course the last resort is to purchase a whole new one)
    Thanks

    Thursday, April 9, 2009 at 11:29 pm | Permalink
  13. dstruct2k wrote:

    Fili:

    When it’s flashing like that, it means it’s not finding the device it’s paired with. Try this:

    On the USB receiver, hold the button on it until the green LED flashes.
    Once the LED is flashing, hold the button on the top-middle of the controller (beside the charger port) until the lights on the controller change.
    At this point, the receiver should stop flashing and the controller should (at least on Windows) indicate it is controller #1. The Linux xboxdrv may not tell it to light up quadrant #1, but if the receiver stops blinking, it’s a good bet you re-paired them successfully.

    Restart XMBC once the controller is paired again and you should be in business.

    Thursday, April 23, 2009 at 1:26 am | Permalink
  14. Paul wrote:

    Hi all,

    Does the latest version fixes the “reconnect” problem? Meaning you don’t have to restart the driver after reconnecting the controller?

    If it does behave correctly, the only issue left would be related to the dpad? So if you do not use the dpad, it works fine?

    Thanks

    Monday, June 15, 2009 at 1:35 pm | Permalink
  15. jacky wrote:

    Hi,

    Does this and how can I get this to work with XBMC LIVE booting off of a usb flash drive? I do not have a harddrive or cdrom on the media server pc I am building and I do not have Linux installed. Thank you very much!

    Monday, August 3, 2009 at 10:22 am | Permalink
  16. Alblerto wrote:

    I too would love this to work with XBMC Live. How exactly do we get it on? Many thanks in advance

    Friday, August 14, 2009 at 9:02 am | Permalink
  17. Semidark wrote:

    Very Nice Tutorial. Everything worked well

    Sunday, August 16, 2009 at 1:15 pm | Permalink
  18. Darwin wrote:

    For people who may find this page via google, I have updated Tony’s Keymap.xml for the changed behavior of xboxdrv under Ubuntu Jaunty / XBMC Live 9.04. Full credit to Tony for his file, I just modified it slightly for 9.04, and am distributing it with a precompiled copy of xboxdrv and startup scripts which works on Hardy, Intrepid, Jaunty, and XBMC Live 8.10 (Ubuntu 8.04) and XBMC Live 9.04. If you are having weird behavior with the shoulder buttons on your Xbox360 controller with xboxdrv, see this XBMC forum thread :

    http://www.xbmc.org/forum/showthread.php?t=57304

    =darwin

    Wednesday, September 2, 2009 at 10:30 pm | Permalink
  19. Joe Anderson wrote:

    What I find interesting that no one has noticed or said anything about, if you put the Keymap.xml in /userdata dir it will overwrite your original Keymal.xml which has support for keyboard, remote and various other gamepads etc..

    Now why would someone completely loose the keyboard support in xbmc for the joystick?

    Why cant the provided xml file be merged with the other xml file and add the 360 wireless support in addition to the existing input devices configured there?

    Saturday, October 17, 2009 at 6:06 pm | Permalink
  20. tonymagro wrote:

    You might have a slightly different setup but in a more standard installation the default Keymap.xml file is installed globally which allows you to place my custom xboxdrv 360 Keymap.xml in your home directory at ~/.xbmc/userdata/Keymap.xml . As a result, it doesn’t require you to overwrite any files and the custom 360 Keymap.xml is loaded in addition to the default global Keymap.xml so all your keyboard and joystick settings will load too.

    The reason why the provided Keymap.xml contains only the xboxdrv 360 entries is because the default Keymap.xml could change depending on which version of XBMC you have installed. If I pasted the default Keymap.xml bindings into my xboxdrv Keymap.xml then you wouldn’t get the most up to date Keymap.xml settings from your installation of XMBC. This would mean that if XMBC added or changed keyboard or joystick bindings between versions and you used my xboxdrv Keymap.xml which contained old default bindings in addition to the custom xboxdrv 360 bindings then the old default bindings could cause problems with the new version. I would recommend using a setup where you load my xboxdrv 360 Keymap.xml in addition to a global default Keymap.xml but I do realize that not everybody can use standard installation paths and a person might want to load all their settings from one location. If you fall in this category and changing your setup is not possible then I would recommend just appending the contents of my xboxdrv 360 Keymap.xml to the end of your single default Keymap.xml file.

    Saturday, October 17, 2009 at 7:36 pm | Permalink
  21. alecos wrote:

    Hey all,
    I was wondering, could the control be used to replace the mouse?
    Like with the dpad n toggle sticks to control the mouse movement.

    Ofcourse outside the xbmc.

    thanks

    Thursday, October 22, 2009 at 1:35 pm | Permalink
  22. Lars wrote:

    Found another way to autostart xboxdrv, which suited me better.

    I’m running karmic 9.10 and latest xbmc svn, with a minimal install.
    Using /etc/rc.local stalled my system and it didn’t load xbmc.

    So here is the fix i’m using :

    sudo nano /etc/init/tty2.conf

    replace this line :
    exec /sbin/getty -8 38400 tty2

    with :
    exec /home/xbmc/xboxdrv/xboxdrv –silent –dpad-as-button –deadzone 3000

    and it’ll start on tty2 instead :)

    Really really enjoyed this guide, been able to reuse my old logitech wireless xbox1 controller :)

    Thanks !

    Saturday, November 14, 2009 at 3:05 pm | Permalink

One Trackback/Pingback

  1. [...] http://www.stolennotebook.com/anthony/2008/09/13/using-xbmc-for-linux-with-an-xbox-360-wireless-cont…A blog post by Tony to get me started with the driver in XBMC and a Keymap.xml Share/Save Categories: Uncategorized Tags: Comments (0) Trackbacks (0) Leave a comment Trackback [...]

Post a Comment

Your email is never published nor shared. Required fields are marked *
*
*