input: add gamepad support through SDL2

The code is very basic:

- only handles gamepads, could be extended for generic joysticks in the
  future.
- only has button mappings for controllers natively supported by SDL2.
  I heard more can be added through env vars, there's also ways to load
  mappings from text files, but I'd rather not go there yet. Common ones
  like Dualshock are supported natively.
- analog buttons (TRIGGER and AXIS) are mapped to discrete buttons using an
  activation threshold.
- only supports one gamepad at a time. the feature is intented to use
  gamepads as evolved remote controls, not play multiplayer games in mpv :)
This commit is contained in:
Stefano Pigozzi
2019-10-22 16:41:19 +02:00
parent 79b15f50e3
commit 899e0bd16b
12 changed files with 378 additions and 8 deletions

4
test/input-gamepad.conf Normal file
View File

@@ -0,0 +1,4 @@
GAMEPAD_RIGHT_STICK_LEFT seek -10
GAMEPAD_RIGHT_STICK_RIGHT seek 10
GAMEPAD_LEFT_TRIGGER seek -1
GAMEPAD_RIGHT_TRIGGER seek 1