How to get half-working gamepad working?

I have a ASUS Gamepad that works ok, the event device that is registered works fine - except some buttons seems to be reported as keyboard buttons leading to confusion in apps that use the gamepad [the keys reported as keyboard buttons are "dead"] and the js0 device lack the buttons.

Would it be easy to make a minimal hid kernel driver that translates the returned key? (Or adds the non-reported keys to the js0 device)

Is there any other solution that could be used?

Posted Apr 27, 2016, 2:11 PM UTC

114
UpSoUs•

What linux are you using?
What are the gamepad's details from the 'lsusb' command?

2
OctetzOP•

I am using a raspberry pi with raspbian [ uname -a: Linux retropie 4.1.19-v7+ #858 SMP Tue Mar 15 15:56:00 GMT 2016 armv7l GNU/Linux ]

The gamepad is a bluetooth device but the output of dmesg | grep -i blue is

[   10.472455] Bluetooth: Core ver 2.20
[   10.472559] Bluetooth: HCI device and connection manager initialized
[   10.472584] Bluetooth: HCI socket layer initialized
[   10.472602] Bluetooth: L2CAP socket layer initialized
[   10.472659] Bluetooth: SCO socket layer initialized
[   10.479943] Bluetooth: HCI UART driver ver 2.3
[   10.479965] Bluetooth: HCI UART protocol H4 registered
[   10.479974] Bluetooth: HCI UART protocol Three-wire (H5) registered
[   10.479983] Bluetooth: HCI UART protocol BCM registered
[   10.673287] Bluetooth: BNEP (Ethernet Emulation) ver 1.3
[   10.673300] Bluetooth: BNEP filters: protocol multicast
[   10.673315] Bluetooth: BNEP socket layer initialized
[  476.100905] Bluetooth: HIDP (Human Interface Emulation) ver 1.2
[  476.100942] Bluetooth: HIDP socket layer initialized
[  476.106068] hid-generic 0005:0B05:4500.0003: input,hidraw2: BLUETOOTH HID v0.40 Gamepad [ASUS Gamepad] on b8:27:eb:c9:34:62
1
UpSoUs•

Raspbian might have qjoypad in its repos. If your gamepad buttons are detected at all, you could use that to remap (or "quickset") them to something useful.

2
OctetzOP•

This would probably have been perfect, except the issue is that I am not using X - but instead running programs that take their input via SDL.

crdlb suggested MoltenGamepad which seems to be like qjoypad but on a lower level. We'll see if I get that working

1
crdlb•

You can perform the translation in userspace with uinput. I've been using https://github.com/jgeumlek/MoltenGamepad with my wiimote and classic controller pro. You should be able to create a generic driver that describes your controller.

As far as fixing the kernel, the hid driver can't be changed to use BTN_DPAD_* as that would break ABI. It might be possible to fix joydev (the driver that makes /dev/input/jsN) in some way, but it's deprecated and apparently no longer developed.

2
OctetzOP•

Thanks! I'll definetly look into the MoltenGamepad!

1
Linuxllc•

I really like my gamepad. Own it during my Windows years. Now I'm a Linux user for the past 12+ years. My gamepad is always recognize as soon I plug it in. Plug-n-play and the way I go.

I rarely even have to calibrated it.

It's my trusted Thrustmaster Firestorm Dual Power Gamepad.

http://www.dansdata.com/images/tmsticks/fsdp480.jpg

http://static.giantbomb.com/uploads/original/7/75483/2352422-firestorm.jpg

Still looks new and still responds great. Best gamepad I ever own.

This don't fix your problem. But, looking into another gamepad can be another option.

2
OctetzOP•

Haha, I would definetly follow your advice if being a bluetooth gamepad wasn't a number one priority.

1
Linuxllc•

bluetooth gamepad wasn't a number one priority.

So that's the problem "bluetooth".

I'm so close to my PC a USB cord is much easier to setup then a bluetooth gamepad.

How far are you from your PC?

1
Linuxllc•

Bluetooth setup for a gamepad

sudo apt install bluez-compat jstest-gtk

hcitool scan

sudo hidd --connect <ADDRESS>

(replace with the address from the scan).

Finally, you can confirm that gamepad input is working by running jstest-gtk

1
OctetzOP•

Thanks llc - but as stated I already have the device working fairly well - only some buttons are not working suggesting it is not a bluetooth issue but a driver issue.

1
Linuxllc•

Have you try out the xboxdrv? I believes it's a modular for the Linux Kernel. And you have to disable xpad Kernel driver. So there won't be any conflict. I'm sure you can Google all the info about how to install the xboxdrv. If you haven't try it out yet.

1