SDL2 and controllers

Hi all,

Any ideas on how to use SDL2 in a snap and have it recognise controllers?

I figured connecting the joystick interface might help but it doesn’t, maybe it does for older joysticks but I’m testing with modern gamepads, so ps3/ps4/360/xbone.

I’m using the SDL2 provided by the system, eg libsdl2-dev

My snapcraft.yaml :


The joystick plug is the solution (added to your snapcraft.yaml then manually connected after installation). Certainly, it works for my SDL snaps and xbox360 controllers.

BTW, it looks like the joystick interface is being extended to support a broader set of devices in the incoming snapd 2.33. See:

Maybe some of your controllers do not work now, but will do once the above patches land. I’m sure @jdstrand would be happy to see somebody testing his PR… :wink:

@mcphail that’s what I tried, without any luck. Maybe it is happier with older controllers?

@robepisc This sounds perfect I’ll keep an eye on it and see if I can get it working.

Certainly x360 controllers (and Steam controllers masquerading as x360 controllers via sc-controller) work perfectly for me. I don’t have anything more modern :slight_smile: .

The interface work I did for 2.33 is to add support for accessing controllers via the modern /dev/input/event* evdev interface as opposed to the older /dev/input/js* interface. Controllers can typically be accessed with either and it depends on the libraries you are using as to which is used. I suspect that sdl2 is using the modern evdev interfaces. It looks like the new code to support evdev joysticks is already in edge. You might try ‘sudo snap refresh core --edge’


Yeah, that’s what I think is going on, have tried updating the core which is now at,

core 16-2.33~rc1+git762.1725171 4770 edge canonical core

but that did not work.

I’ll see if I can track down what SDL2 is up to and try some older controllers to see if that helps.