[HowTo] Scripts for using Xbox Controller in RetrOSMC


Unfortunately it’s the wireless version and I don’t own the cable to turn it into a wired one.

Ah, that’s why! And congratulations on the office! :slight_smile:
Anyway, donating via Paypal/Bitcoin/Flattr is always open and I’ll just use this instead.

Okay, will do so! This will be interesting.

Again, thanks for your help! And keep OSMC as awesome as it its :slight_smile:


Thanks :slight_smile:

Let me know how you get on. You should find the build process relatively hands-off. Make sure you have a few GB free on the SD card (as the kernel is a large package)


osmc@RASPI2:~$ uname -a
Linux RASPI2 4.4.16-1-osmc #1 SMP PREEMPT Thu Aug 18 16:30:00 UTC 2016 armv7l GNU/Linux

It took nearly five hours to build, but at least I built my first (custom) kernel, yay. :smiley: Btw, it worked with an 8 GB µSD card that contained nothing but OSMC.
Before I started building, I edited the /home/osmc/osmc/package/kernel-osmc/patches/rbp2-000-add-kernel-config.patch to contain


During building some y/n/m questions came up for including stuff into the kernel, I answered n to CONFIG_JOYSTICK_XPAD and CONFIG_JOYSTICK_XPAD_FF. Also about six questions about sound broadcom thingie (unfortunately didn’t take screenhots) to which I replied n as well.
sudo dpkg -i rbp2-image-4.4.16-1-osmc.deb, edited /etc/osmc/prefs.d/update_preferences, removed the sudo rmmod xpad line from /home/osmc/start.sh, rebooted, tested controller.

Unfortunately it still doesn’t work reliably. All tests/methods from the last ten posts above showed the same behaviour and error messages.
Now it might be imagination, but with the new kernel it worked in 4/5 cases. What also changed was the LED behaviour; now flashing always means working, and staying lit in position 1 always means not working. This is strange, as this is exactly what the --led=2 in /home/osmc/start.sh tells it to do.

Therefore I still think it can’t be a problem in principle but has to do with the order or way the USB device is initialised. If this can be determined by syslogs or anything, I’m happy to provide them.

[TESTING] Kodi 18 (Leia) builds for Raspberry Pi

I’m also interested in a solution, please fix it :slight_smile:


Retropie 4.0 just released :

NOTE: Some people have been having trouble with the XBox/XBox 360 controller driver xboxdrv on the current Raspbian Kernel. To work around this we now include the latest xpad kernel driver with the image (it is available from the Packages -> Drivers menu for those upgrading). The included xpad has been patched to map the Xbox 360 triggers to buttons, so they work out of the box with Emulation Station, without the need for xboxdrv.

I’ve tried to install xpad but it ended up with could not install package : dkms raspberrypi-kernel-headers


We don’t use DKMS modules. If someone gets in touch with them and finds out where they sourced the updated kernel module from I will update our kernel.

Seems like the RetroPie guys are suggesting the kernel module is problematic. If this is the case I’m not sure why excluding it from the build as @RJ45 did doesn’t fix the problem.


I’ve asked for help on the retropie forum https://retropie.org.uk/forum/topic/3496/osmc-xpad-support.
Wait & see


From a retropie admin :

You may not want our xpad, as it may cause problems with Kodi on OSMC or other issues. We have some support for OSMC but I don’t think I can help get xpad working if they are managing their own kernels that won’t work with dkms.

The code is here

It’s this driver we are building - which contains newer xpad code than is in the currentl Raspbian 4.4 kernel - https://github.com/paroj/xpad.git

However due to problems with ES and the triggers, I have patched it so the triggers are forced to act as buttons (can be switched off via module param).


I need to know if this causes regressions, as this may have an impact on RetroPlayer in v18. I can backport the driver if someone is willing to give it a go.

It looks like there is a small downstream (RetroPie) patch, which is applied to the xpad.git tree which is based on the latest upstream kernel.



I’m willing to try but I’m not at home until wednesday. @RJ45 or @cibban can you try sooner ?


I have compile tested this only, so no guarantee if it will work:

I will now schedule builds on Jenkins and let you know when they are available.



I’m willing to test anything, although I managed to get the standard xpad driver to work reasonably good by simply removing all custom configs. It works ok with the autoconfig. I’m just not sure how to test it. All that git magic is fairly new to me so I’m still trying to wrap my head around it.



We are working our new build system, and it’s being given a small workout tonight which is delaying these builds.

No need to do anything with Git. When the new kernels for Pi 1 and Pi 2 are ready, I will give you clear instructions for how to try them.




I still can’t install xpad because I could not install the dkms raspberrypi-kernel-headers
What’s the trick ?


xpad module are included in the OSMC kernel already; no need for DKMS.


got problem with retroarch joystick input but all seems to work


Hi @Yggdrasil and @RJ45

I have followed all steps from the first post and it working fine in OSMC.
Is there a way to also be able to use the joystick?

When I launch RetroPie (RetrOsmc), I have the “No gamepads detected” screen but holding a button does nothing and I’m litterally stuck.

Any suggestions?

I’m using a wireless xbox controller connected with it wireless USB receiver.



With Emulstation running I tried to execute the following commands manually and it worked fine

sudo kill -9 'ps -ef | grep xboxdrv | grep -v grep | awk ‘{print $2}’'
sudo xboxdrv --wid 0 --led 3 --alt-config /home/osmc/xboxdrv-buttonswap.ini & sleep 2

So for me there is 2 solutions:

  1. the exit instruction in the batch is causing troubles (weird)
  2. it’s not called at the right moment
    currently it’s launched from here:
    ( hashes replaced by // to not mess with the editor


// This scripts starts the emulationstation watchdog deamon and
// emulationstation itself while stopping KODI afterwards.
// Script by mcobit

//clear the virtaul terminal 7 screen

sudo openvt -c 7 -s -f clear

// start the watchdog script

sudo su osmc -c “sh /home/osmc/RetroPie/scripts/retropie_watchdog.sh &” &

//run switch to xpad emulation for xboxdrv

sudo su osmc -c “sh /home/osmc/xboxdrv-switchtoxpad.sh &” &

// check if emulationstation script in chroot is changed and if so, create altered script

sudo chown osmc:osmc /usr/bin/emulationstation

Any ideas?


Sorry to disappoint you, but I couldn’t get to work the wireless 360 controller even with a custom built kernel. It either works in OSMC or in RetroPie, but not in both.

Waiting for Kodi 18 and its integration into OSMC now, it’ll have a built-in RetroPie, so to say, called RetroPlayer.

At the moment there’s a problem with xboxdrv and the kernel, so xpad has to be used.

As far as I can see, your only solution for the time being is to have a dual boot of RetroPie and OSMC.


Thanks for this precision.
For now, you said that

It either works in OSMC or in RetroPie, but not in both.

What should I change to make it work ONLY with RetroPie?


Hey guys,

first of all thanks for the great project, been using it for quite a while now. Since the xboxdrv debacle I am successfully using xpad in Emulationstation and moonlight-embedded…but the flashing LEDs are driving me insane. Has there been any progress on integrating the updated xpad packages?