[How-to] Xbox 360 Controller OSMC

This was tested with a fresh install using a Pi2

Start by SSH or Terminal into your Raspberry Pi.

  1. Install xboxdrv

sudo apt-get install xboxdrv

  1. Find the correct device-name for your specific controller.

sudo xboxdrv

You should get a output similar to this

Quote:pi@raspbmc:~$ sudo xboxdrv
xboxdrv 0.8.4 - http://pingus.seul.org/~grumbel/xboxdrv/
Copyright  2008-2011 Ingo Ruhnke <grumbel@gmx.de>
Licensed under GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This program comes with ABSOLUTELY NO WARRANTY.
This is free software, and you are welcome to redistribute it under certain
conditions; see the file COPYING for details.

Controller: Microsoft Xbox 360 Wireless Controller
Vendor/Product: 045e:0291
USB Path: 001:004
Wireless Port: 0
Controller Type: Xbox360 (wireless)

As you can see my device is called…

“Microsoft Xbox 360 Wireless Controller”

We need to remember this, but for now simply Ctrl-X out so you can type in the terminal again.

IF you get a error similar to…

> -- [ ERROR ] ------------------------------------------------------
>  Error couldn't claim the USB interface: LIBUSB_ERROR_BUSY
> Try to run 'rmmod xpad' and then xboxdrv again or start xboxdrv with the option --detach-kernel-driver.

Just run

sudo rmmod xpad
sudo xboxdrv

Now we need to tell xboxdrv what the different buttons should do inside of XBMC.
We do this by creating a file called xbmc.ini.

`sudo nano /home/osmc/xbmc.ini`

Then simply copy and paste the code bellow and save your way out of there (Ctrl-x)

Note very important here to edit the line device-name = “” to match your controller name.
(Remember to put the name between the quotation marks!)

Code:

# XBMC Configuration
# ==================

#X1: 0 Y1: 0 X2: 0 Y2: 0 du:0 dd:0 dl:0 dr:0 start:0 back:0 TL:0 TR:0 A: 0 B: 0 X: 0 Y: 0 black: 0 white: 0 LT: 0 RT: 0

[xboxdrv]
#ui-clear = true
extra-devices = false
extra-events = false
deadzone = 6000
device-name = "Microsoft Xbox 360 Wireless Controller"

[ui-buttonmap]
# Face buttons
A = KEY_ENTER
B = KEY_BACKSPACE
X = KEY_X
Y = KEY_ESC

# D-Pad
du = KEY_UP
dd = KEY_DOWN
dl = KEY_LEFT
dr = KEY_RIGHT

# Start / Back buttons
start = KEY_SPACE
back = KEY_L

# Bumper Left / Right
white = KEY_C
black = KEY_I

# Stick buttons
TL = BTN_RIGHT # Left stick buttons
TR = BTN_LEFT # Right stick buttons

# Triggers Right / Left
RT = KEY_EQUAL # Right trigger
LT = KEY_MINUS # Left trigger

[ui-axismap]
#x2=REL_RX:10
#y2=REL_RY:-10

x1=REL_X:10
y1=REL_Y:10


# The resp filter moves the neutral position to zero to work around a
# bug in XBMC, that causes bogus events when neutral position is
# elsewhere. It loses a bit of precision in the trigger as result, but
# that isn't noticeable.
LT^resp:127:255=ABS_Z
RT^resp:127:255=ABS_RZ

# EOF #

Next we need to make an .sh script that starts xboxdrv.

sudo nano /home/osmc/start.sh

Then insert…

#!/bin/bash
    rmmod xpad
    modprobe uinput
    modprobe joydev
    
    /usr/bin/xboxdrv --config /home/osmc/xbmc.ini --silent --autofire RT=25 --autofire LT=25 --autofire du=200 --autofire dd=200 --autofire dl=500 --autofire dr=500 &

Save your way out of nano again (Ctrl-O + Ctrl-X

Almost done!
Just need to change some permissions and tell Linux to run the .sh script at boot start-up.

Run

sudo chmod 777 /home/osmc/start.sh
sudo chmod 777 /home/osmc/xbmc.ini

Open rc.local

sudo nano /etc/rc.local

Set start.sh to start at boot.
Add this before the exit 0

/home/osmc/start.sh

Now run

sudo reboot .

Thats it, have fun!

Controller Layout in XBMC

[Image: 289lzy8.png]
Face buttons
A = Select
B = Back
X = Stop
Y = Home screen
Start / Back buttons
start = Pause/Play
back = Next subtitle
Bumper
Right = Info
Left = Contextual menu
Triggers
Right = Volume up
Left = Volume down

Note if you run into issues do something for me and I will try to help, start ssh

run sudo xboxdrv
paste output
then run
sudo ./start.sh
paste output

I hope this helps, mostly all credit goes to Alza! Thanks man you’re epic!

6 Likes

Thanks for this tutorial!
UNfortunatly, like for wanamaa in this post OSMC Forums , I do not manage to use my controller :frowning:
My device name is: “Microsoft Xbox 360 Wireless Controller (PC)”

Please find hereafter the:
sudo xboxdrv OUTPUT

xboxdrv 0.8.5 - xxx
Copyright © 2008-2011 Ingo Ruhnke xxx
Licensed under GNU GPL version 3 or later xxx
This program comes with ABSOLUTELY NO WARRANTY.
This is free software, and you are welcome to redistribute it under certain
conditions; see the file COPYING for details.

Controller: Microsoft Xbox 360 Wireless Controller (PC)
Vendor/Product: 045e:0719
USB Path: 001:005
Wireless Port: 0
Controller Type: Xbox360 (wireless)

Your Xbox/Xbox360 controller should now be available as:
/dev/input/js0
/dev/input/event2

and the sudo ./start.sh ouput:


rmmod: ERROR: Module xpad is not currently loaded
osmc@osmc:~$
– [ ERROR ] ------------------------------------------------------
unknown section: ‘’

Tanks for your help!

I also had this problem and this is what solved it for me:

sudo modprobe xpad
sudo rmmod xpad
sudo xboxdrv

Hi there,

Thanks for sharing this, it worked for me with no trouble :smile:

However i am trying to reverse this process at the moment, could you tell me, is it safe to delete the rc.local file, or does it exist by default? If it is there already, should I delete the bottom two lines? It was a couple of weeks ago that I set this up so can’t remember if rc.local was already there or not.

Cheers!

Remove your lines from rc.local, don’t delete the whole file. The only non-comment line in an original rc.local is exit 0.

Hi
Im looking to set auto-fire for the right analog stick to move (down,up) list etc when trigger is held. This currently works with the d-pad auto-fire configuration below.

Heres my right axis mappings in xbox.ini:
x2=KEY_LEFT:KEY_RIGHT
y2=KEY_UP:KEY_DOWN

I basically want to copy the (du/dd/dl/dr) settings below but have it mapped to x2 and y2. I tried replacing du with x2 and dd with x2 but seems that because x2 & y2 are each mapped to 2 buttons then im wrong in code.

/usr/bin/xboxdrv --config /home/osmc/xbmc.ini --silent --autofire RT=25 --autofire LT=25 --autofire du=200 --autofire dd=200 --autofire dl=500 --autofire dr=500 &

Thanks for any help on this.

Hi,

Not sure what Im doing wrong… but xboxdrv insnt installed on a fresh install!

Also, once ive installed it manually and removed xpad, my rock candy 360 controlled is not found. usb-devices reports that it is there.

Anyone got any ideas. This is super frustrating.

Hi cnschulz,
I hat this problem too,
just use

sudo apt-get install xboxdrv

Vinc0682

How can I do this with a game-pad that is not the XBOX 360 game pad?

I have a speed-link sl-4443

Witch works in emulation station.

This worked like a charm, thanks a lot for sharing it!

When you do

sudo rmmod xpad
sudo xboxdrv

You will get the opout like

Controller: Your Controller name
Vendor/Product: 045e:0291
USB Path: 001:004
Wireless Port: 0
Controller Type: Controller

then in the xboxdrv just change

device-name = “Microsoft Xbox 360 Wireless Controller”

to

device-name = “Your controller name”

When I type sudo rmmod xpad
i get

rmmod: ERROR: Module xpad is not currently loaded
osmc@osmc:~$ sudo xboxdrv
xboxdrv 0.8.5 - http://pingus.seul.org/~grumbel/xboxdrv/
Copyright © 2008-2011 Ingo Ruhnke grumbel@gmx.de
Licensed under GNU GPL version 3 or later http://gnu.org/licenses/gpl.html
This program comes with ABSOLUTELY NO WARRANTY.
This is free software, and you are welcome to redistribute it under certain conditions; see the file COPYING for details.

– [ ERROR ] ------------------------------------------------------
No Xbox or Xbox360 controller found

so, what did i do wrong? I don’t think it sees my controller as a x360 game-pad and that is the problem.

Thank you

This worked very well for me. I was wondering if anyone is having the same problem as me after setup, though. I use a wired controller, and after unplugging it and plugging it back in the Pi doesn’t find it. I have to reboot the system for it to recognize the controller. Is there a line I need to add to a file or a script to write to have it recognize the controller when I plug it in after booting?

To be honest ive never tried pluging it in after. Since I am using a wireless controller and it always detects it. Let me look into it and see what I can find out.

I made my update seconds too late. I’m using Kodi with it, in case that would make any difference.

Im getting this arfter sudo xboxdrv
Controller: Microsoft Xbox 360 Wireless Controller
Vendor/Product: 045e:0291
USB Path: 001:006
Wireless Port: 0
Controller Type: Xbox360 (wireless)

Your Xbox/Xbox360 controller should now be available as:
/dev/input/js0
/dev/input/event0

Press Ctrl-c to quit, use ‘–silent’ to suppress the event output
X1: -3914 Y1: -288 X2: -2643 Y2: 671 du:0 dd:0 dl:1 dr:0 back:0 guide:0 start:0 TL:0 TR:0 A:0 B:0 X:0 Y:0 LB:0 RB:0 LT: 0 RT: 0

and this after sudo ./start.sh
osmc@osmc:~$ sudo ./start.sh
rmmod: ERROR: Module xpad is not currently loaded
osmc@osmc:~$
– [ ERROR ] ------------------------------------------------------
unable to convert ‘false extra-events = false deadzone = 6000 device-name =’ to bool

Any thoughts?

I had to disable xpad to get it to work, might help for other people

from stackexchange Stephen Kitt
To disable xpad permanently you can blacklist it: create a file named say xpad.conf in /etc/modprobe.d containing

blacklist xpad

1 Like

Great tutorial.

For customizing keys how would I add a modifies such as ctrl
ex. guide = KEY_CTRL + KEY_P
would the above be correct?

Were you able to do it?

No
Tried with a few game pads
nothing…