Search code examples
linuxsdlsdl-2gamepadgamecontroller

Why won't SDL detect my iBuffalo game controller on Linux (PocketCHIP)?


I recently obtained an ARM-based Linux computer called a PocketCHIP. It's a great little computer! I'm working on writing a program which uses SDL 2.0.4 and my iBuffalo USB gamepad. However, SDL does not seem to recognize the controller on the PocketCHIP. I think this is a popular controller, so it would surprise me if SDL did not already support it, which makes me think that there's something wrong with my setup/installation. The controller does work in other programs though (mednafen).

On my Mac, when I run the testgamecontroller.c, testjoystick.c, and controllermap.c scripts that are included in the SDL test directory, they all recognize the controller correctly:

INFO: Joystick 0: USB,2-axis 8-button gamepad   (guid 83050000000000006020000000000000)
INFO: There are 0 game controller(s) attached (1 joystick(s))

However, when I run the same scripts on the PocketCHIP, it does not detect the controller.

INFO: There are 0 game controller(s) attached (0 joystick(s))

Linux does seem to recognize the device as connected though:

$ cat /proc/bus/input/devices
...

I: Bus=0003 Vendor=0583 Product=2060 Version=0110
N: Name="USB,2-axis 8-button gamepad  "
P: Phys=usb-1c14400.usb-1/input0
S: Sysfs=/devices/platform/soc@01c00000/1c14400.usb/usb2/2-1/2-1:1.0/0003:0583:2060.0003/input/input5
U: Uniq=
H: Handlers=js0 event2 
B: PROP=0
B: EV=1b
B: KEY=ff 0 0 0 0 0 0 0 0 0
B: ABS=3
B: MSC=10

What do I need to do to get SDL to recognize my controller on the PocketCHIP?


Solution

  • Thanks to @genpfault, I learned that SDL uses /dev/input/event* for gamepad input capture. However, my user (chip) did not have permission to access these, so it was failing silently.

    To grant the chip user access, add the chip user to the input group.

    On Debian Linux you can simply run:

    sudo adduser chip input
    

    Or you can manually do it by editing /etc/group:

    sudo nano /etc/group
    

    Arrow down to the line that says:

    input:x:101:
    

    to:

    input:x:101:chip
    

    Type control+x, to exit. It will prompt you to save the file. Type y, then return to save the file and quit the nano text editor. Restart your PocketCHIP and SDL will now be able to read the gamepad input.