Controlling Kodi with Gamepad

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 [url]http://kodi.wiki/view/Keymap[/url] 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:

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

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)

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(R)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.

I have asked the same question in Kodi forum, and someone said that Kodi needs to be compiled with --enable-joystick --enable-sdl in order to support gamepad, and from his research on OSMC git, Kodi is explicitly compiled with --disable-sdl --disable-joystick.

Can someone confirm this and why it is this way (too buggy? performance issue on RPI?)

Is there some plan to support gamepad in final version? If not, is there some idea of workaround to get gamepad working (for example could it be handled with an add-on)?

I have open an issue: [Enable joystick support][1]. I can confirm SDL and joystick support are disabled in the Kodi compilation for OSMC: [osmc/package/mediacenter-next-osmc/build.sh][2], but I don’t know why.
[1]: Enable joystick support · Issue #162 · osmc/osmc · GitHub
[2]: osmc/build.sh at 01ba60ddefcd4feeb009c0d6f628232b17b329be · osmc/osmc · GitHub