Kodi Community Forum

Full Version: Controlling Kodi with Gamepad
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
In short, I try to use a gamepad (Logitech Dual Action gamepad or PS3 gamepad) to control Kodi, but I don't manage to have it working. Despite I have been looking several thread and using google, I did not find a solution to my problem. I also tried to follow the Kodi wiki Keymap (wiki) instruction.

For info, I use Kodi 14.1 (March 14), included last OSMC contribution (Release Candidate 0.9.9) on Raspberry PI 2

When running cat /proc/bus/input/devices command, I can see that the gamepad are recognized:
Code:
osmc@osmc:~/.kodi$ cat /proc/bus/input/devices

I: Bus=0003 Vendor=03f0 Product=0024 Version=0110
N: Name="CHICONY HP Basic USB Keyboard"
P: Phys=usb-bcm2708_usb-1.2/input0
S: Sysfs=/devices/platform/bcm2708_usb/usb1/1-1/1-1.2/1-1.2:1.0/0003:03F0:0024.0001/input/input0
U: Uniq=
H: Handlers=sysrq kbd event0
B: PROP=0
B: EV=120013
B: KEY=10000 7 ff9f207a c14057ff febeffdf ffefffff ffffffff fffffffe
B: MSC=10
B: LED=7

I: Bus=0003 Vendor=046d Product=c216 Version=0110
N: Name="Logitech Logitech Dual Action"
P: Phys=usb-bcm2708_usb-1.5/input0
S: Sysfs=/devices/platform/bcm2708_usb/usb1/1-1/1-1.5/1-1.5:1.0/0003:046D:C216.0003/input/input1
U: Uniq=
H: Handlers=event1 js0
B: PROP=0
B: EV=1b
B: KEY=fff 0 0 0 0 0 0 0 0 0
B: ABS=30027
B: MSC=10

I: Bus=0003 Vendor=054c Product=0268 Version=0111
N: Name="Sony PLAYSTATION(R)3 Controller"
P: Phys=usb-bcm2708_usb-1.3/input0
S: Sysfs=/devices/platform/bcm2708_usb/usb1/1-1/1-1.3/1-1.3:1.0/0003:054C:0268.0002/input/input2
U: Uniq=
H: Handlers=event2 js1
B: PROP=0
B: EV=1b
B: KEY=7 0 0 0 0 0 0 0 0 0 0 0 0 ffff 0 0 0 0 0 0 0 0 0
B: ABS=7fffff00 27
B: MSC=10

I have created a keymap file in the right folder
Code:
osmc@osmc:~/.kodi/userdata/keymaps$ ls -al

drwxr-xr-x 2 osmc osmc 4096 Apr  5 22:45 .
drwxr-xr-x 9 osmc osmc 4096 Apr  4 21:35 ..
-rw-r--r-- 1 osmc osmc 3299 Apr  5 22:46 logitech.xml

and the content of the logitech.xml file is (this is not the final version that I want, but have made this one as results of several tries and my understanding of the wiki documentation to get at least some response of the gamepad in Kodi)
Code:
osmc@osmc:~/.kodi/userdata/keymaps$ more logitech.xml
<keymap>
    <global>
        <gamepad>
            <A>ParentDir</A>
            <b>Select</b>
            <dpadleft>Left</dpadleft>
            <dpadright>Right</dpadright>
            <dpadup>Up</dpadup>
            <dpaddown>Down</dpaddown>
            <leftthumbstickleft>Left</leftthumbstickleft>
            <leftthumbstickright>Right</leftthumbstickright>
            <leftthumbstickup>Up</leftthumbstickup>
            <leftthumbstickdown>Down</leftthumbstickdown>
            <rightthumbstickleft>Left</rightthumbstickleft>
            <rightthumbstickright>Right</rightthumbstickright>
            <rightthumbstickup>Up</rightthumbstickup>
            <rightthumbstickdown>Down</rightthumbstickdown>
        </gamepad>
        <joystick name="Logitech Logitech Dual Action">
            <button id="1">ParentDir</button>
            <button id="2">Select</button>
            <button id="3">Pause</button>
            <button id="4">Stop</button>
            <button id="5">skipPrevious</button>
            <button id="6">skipNext</button>
            <button id="7">Rewind</button>
            <button id="8">FastForward</button>
            <button id="9">ContextMenu</button>
            <button id="10">FullScreen</button>
            <hat id="1" position="left">Left</hat>
            <hat id="1" position="right">Right</hat>
            <hat id="1" position="up">Up</hat>
            <hat id="1" position="down">Down</hat>
            <axis limit="+1" id="4">VolumeDown</axis>
            <axis limit="-1" id="4">VolumeUp</axis>
            <axis limit="+1" id="3">AnalogSeekForward</axis>
            <axis limit="-1" id="3">AnalogSeekBack</axis>
            <axis limit="-1" id="2">ScrollUp</axis>
            <axis limit="+1" id="2">ScrollDown</axis>
        </joystick>
        <joystick name="Logitech Dual Action">
            <altname>Logitech Dual Action</altname>
            <button id="1">ParentDir</button>
            <button id="2">Select</button>
            <button id="3">Pause</button>
            <button id="4">Stop</button>
            <button id="5">skipPrevious</button>
            <button id="6">skipNext</button>
            <button id="7">Rewind</button>
            <button id="8">FastForward</button>
            <button id="9">ContextMenu</button>
            <button id="10">FullScreen</button>
            <hat id="1" position="left">Left</hat>
            <hat id="1" position="right">Right</hat>
            <hat id="1" position="up">Up</hat>
            <hat id="1" position="down">Down</hat>
            <axis limit="+1" id="4">VolumeDown</axis>
            <axis limit="-1" id="4">VolumeUp</axis>
            <axis limit="+1" id="3">AnalogSeekForward</axis>
            <axis limit="-1" id="3">AnalogSeekBack</axis>
            <axis limit="-1" id="2">ScrollUp</axis>
            <axis limit="+1" id="2">ScrollDown</axis>
        </joystick>
        <joystick name="Sony PLAYSTATION(R)3 Controller">
            <altname>Logitech Dual Action</altname>
            <button id="1">ParentDir</button>
            <button id="2">Select</button>
            <button id="3">Pause</button>
            <button id="4">Stop</button>
            <button id="5">skipPrevious</button>
            <button id="6">skipNext</button>
            <button id="7">Rewind</button>
            <button id="8">FastForward</button>
            <button id="9">ContextMenu</button>
            <button id="10">FullScreen</button>
            <hat id="1" position="left">Left</hat>
            <hat id="1" position="right">Right</hat>
            <hat id="1" position="up">Up</hat>
            <hat id="1" position="down">Down</hat>
            <axis limit="+1" id="4">VolumeDown</axis>
            <axis limit="-1" id="4">VolumeUp</axis>
            <axis limit="+1" id="3">AnalogSeekForward</axis>
            <axis limit="-1" id="3">AnalogSeekBack</axis>
            <axis limit="-1" id="2">ScrollUp</axis>
            <axis limit="+1" id="2">ScrollDown</axis>
        </joystick>
    </global>
</keymap>

log of the debug is available at http://xbmclogs.com/pmm4em0uq (generated after a reboot, and trying to move & press button on each gamepad)
it looks that device is opened:
Line 935: 22:53:42 T:1957089280 INFO: opened device 'Logitech Logitech Dual Action' (file name /dev/input/event1), m_bSkipNonKeyEvents 0
Line 957: 22:53:42 T:1957089280 INFO: opened device 'Sony PLAYSTATION®3 Controller' (file name /dev/input/event2), m_bSkipNonKeyEvents 0

Later I can see
22:54:20 T:1957089280 DEBUG: Keyboard: scancode: 0x6a, sym: 0x0113, unicode: 0x0000, modifier: 0x0
22:54:20 T:1957089280 DEBUG: OnKey: right (0xf083) pressed, action is Right
but no similar line for gamepad action

Whaterver gamepad I use, nothing happen (either with both gamepad connected, only the Logitech or only the PS3) as I can't move in the menu.

My understanding is that it is possible to use gamepad with Kodi, so what do I do wrong?

Thanks in advance for your help.
AFAIK for joystick support Kodi needs to be compiled with --enable-joystick --enable-sdl.
From what I can see from OSMC git Kodi is explicitly compiled with --disable-sdl --disable-joystick. Confused

Edit: ask in @Milhouse's openelec thread, openelec has sdl/joystick support, not sure if it's enabled in @Milhouse's builds.
OpenELEC master no longer supports SDL.
So if I understand correctly your feedback, Kodi could support gamepad if compiled with the correct options, but neither osmc or OpenElec propose it (will be interesting to know why? some bugs? performance issue on RPI?)

Does someone have ideas of workaround? For example:
- just to replace few files in the Kodi installation folder with other files which will give the gamepad support?
- possibility to install the full Kodi Linux version ( http:// http://kodi.wiki/view/HOW-TO:Ins..._for_Linux) over the osmc / OpenElec OS (or the Kodi installed in these distribution is too different from the Linux version and it will not work anymore?)
- Install some add-on inside Kodi?
...
SDL needs x.org, and OpenELEC on ARM has never supported x.org, so Kodi can't use SDL, therefore gamepads don't work with Kodi in OpenELEC on ARM.

No idea about OSMC, but you might be able to get Kodi, SDL and x.org working by switching to Raspbian or some other distribution which does support x.org.

Rather a major undertaking just to control Kodi with a gamepad. Why not use a regular remote control, or even a smartphone (which can't be any less clunky than a gamepad).
It is just that I have a spare old gamepad, and no IR USB receiver and remote, and I was thinking that it would be easy to use it.

But as it looks nearly impossible to use the gamepad for Kodi on RPI, I will look other option, first to explore if I can use the remote of my pioneer VSX AV receiver in CEC way.
I'm interested in gamepad support for Kodi as well. It would be great while using Advanced Launcher/Retroarch to be able to navigate between different games without having to pick up my remote control and just continue using the gamepad.
(2015-04-16, 15:09)mcowher Wrote: [ -> ]I'm interested in gamepad support for Kodi as well. It would be great while using Advanced Launcher/Retroarch to be able to navigate between different games without having to pick up my remote control and just continue using the gamepad.

me too! :-)
I've been looking into this for several days now, and I finally stumbled into here from a combination of Github, RetroPie, and OSMC issues and forums.

While it's good to know that I can stop wasting time trying to get a controller working with my Pi running OSMC, are there any updates on this?

@Milhouse -- I see Krypton has a nice, new controller mapping plugin. Is that just a GUI or is it planned that more devices that run Kodi will support gamepad input?
ping @garbear
(2016-06-27, 08:24)cricket_007 Wrote: [ -> ]@Milhouse -- I see Krypton has a nice, new controller mapping plugin. Is that just a GUI or is it planned that more devices that run Kodi will support gamepad input?

There is certainly more support in Krypton/nightly builds. I am able to control Kodi with a PS2 controller (through a USB adaptor), using a Milhouse build on Pi.
(2016-06-27, 18:17)popcornmix Wrote: [ -> ]
(2016-06-27, 08:24)cricket_007 Wrote: [ -> ]@Milhouse -- I see Krypton has a nice, new controller mapping plugin. Is that just a GUI or is it planned that more devices that run Kodi will support gamepad input?

There is certainly more support in Krypton/nightly builds. I am able to control Kodi with a PS2 controller (through a USB adaptor), using a Milhouse build on Pi.

That's good to hear. @popcornmix, when you say "Milhouse build", are you referring to OpenELEC? I would prefer to stick with OSMC or Recalbox because I like ability to still use my Pi for linux things (and I need a package manager and R/W filesystem for that).

I was mostly curious about the built-in bluetooth of the Pi 3 with a genuine PS3 Controller. I currently have it setup with the QtSixA driver that I built from source from Recalbox in OSMC, and then I have a keyboard input device mapped to Kodi-related events and a joystick for Moonlight game streaming. While that setup works, the whole keyboard mapping process was tedious and less than ideal, and I was hoping that Krypton add-on would make it much simpler. Additionally, (this can be address by a simple yes/no), does the bluez bluetooth service not have a comparable way to configure a device like QtSixA? I'm talking about enabling/disabling LEDs, specifying timeouts, remapping buttons, etc.

I read through the OSMC source, and I do see the --disable-joystick flag when Kodi is built, so I think the keyboard emulation is the best I can get. I also tried to compare OSMC source to Recalbox source, and Recalbox seems to be able to get away with having joystick keymapping because they are using buildroot and/or uinput? Those are probably discussions to have on their respective threads, though.
(2016-06-27, 23:31)cricket_007 Wrote: [ -> ]That's good to hear. @popcornmix, when you say "Milhouse build", are you referring to OpenELEC? I would prefer to stick with OSMC or Recalbox because I like ability to still use my Pi for linux things (and I need a package manager and R/W filesystem for that).

No, it's a LibreELEC build: http://forum.kodi.tv/showthread.php?tid=269814

This OSMC test build thread might be of interest: http://forum.kodi.tv/showthread.php?tid=265306