mpv icon indicating copy to clipboard operation
mpv copied to clipboard

input: add gamepad support through evdev

Open linkmauve opened this issue 2 years ago • 1 comments

This is based on the existing SDL2 code, but without any additional dependency on Linux.

Both buttons and axes are supported, but just like in the SDL2 code, axes are transformed into buttons in order to fit into the existing mpv code. A possible future improvement would be to expose them as proper axes, and take into account their movement.

I’ve tested this code on both PS3, PS4 and Switch controllers, in USB and Bluetooth when possible, on Linux 5.18.

Unlike the SDL2 code, this supports more than one controller plugged in, as it wasn’t much more code to handle that and it’s a useful feature to me.

linkmauve avatar Jul 17 '22 14:07 linkmauve

In this latest version I’ve fixed all of your comments, and opted to use eventfd for the signaling that this thread should exit, this avoids a timeout in poll() which would wake up this thread in a useless context switch. I’ve also extracted EV_ABS handling to its own function.

linkmauve avatar Jul 23 '22 16:07 linkmauve