Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SDL][Joypad] Support for SDL2 HIDAPI drivers #14421

Open
lucasmr opened this issue Sep 16, 2022 · 3 comments
Open

[SDL][Joypad] Support for SDL2 HIDAPI drivers #14421

lucasmr opened this issue Sep 16, 2022 · 3 comments
Labels
feature request New enhancement to RetroArch. input: sdl2

Comments

@lucasmr
Copy link
Contributor

lucasmr commented Sep 16, 2022

Speaking on the Linux side:
Linux gamepad specification
If you have a non-standard controller with many axes or triggers (DS2, DS3, DS4, any controller with triggers or pressure-sensitive buttons), the drivers might simply not support them to conform to this spec. For example, Sony dropped pressure sensitivity in their hid-sony driver in this commit.
Currently, the SDL GameController API follows the evdev implementation, so different controllers with more axes will never get properly configured. The axes are not even reported on evdev because the drivers won't support them all.
What could be done:

  • Convince the maintainers to improve the gamepad specification and update every Linux driver to report all axes.
  • Talk to the gamepad directly via HIDAPI (hidraw or libusb backends). Every userspace application would need their own drivers. Some emulators do this.
  • Use an external library that does this.

Luckily, SDL2 has been implementing lots of HIDAPI drivers:

/* This is the full set of HIDAPI drivers available */                          
#define SDL_JOYSTICK_HIDAPI_GAMECUBE                                            
#define SDL_JOYSTICK_HIDAPI_LUNA                                                
#define SDL_JOYSTICK_HIDAPI_PS3                                                 
#define SDL_JOYSTICK_HIDAPI_PS4                                                 
#define SDL_JOYSTICK_HIDAPI_PS5                                                 
#define SDL_JOYSTICK_HIDAPI_STADIA                                              
#define SDL_JOYSTICK_HIDAPI_SWITCH                                              
#define SDL_JOYSTICK_HIDAPI_WII                                                 
#define SDL_JOYSTICK_HIDAPI_XBOX360                                             
#define SDL_JOYSTICK_HIDAPI_XBOXONE                                             
#define SDL_JOYSTICK_HIDAPI_SHIELD

By using SDL2, you can finally get all functionality from these controllers. However, you cannot use the GameController API and should fallback to the Joystick API, so some code changes are required.
SDL_GameController
SDL_Joystick

Relevant issues: #11721 #6920

@lucasmr lucasmr changed the title Support for SDL2 HIDAPI drivers [SDL][Joypad] Support for SDL2 HIDAPI drivers Sep 16, 2022
@lucasmr
Copy link
Contributor Author

lucasmr commented Sep 16, 2022

For reference, here's a DualShock 3 controller with every pressure-sensitive button working via SDL2 HIDAPI driver and sdl2-jstest:
image
Digital buttons (15): ×, ○, □, △, Select, PS, Start, L3, R3, L1, R1, ↑, ↓, ←, →
Analog axes (16): Left Analog X, Left Analog Y, Right Analog X, Right Analog Y, L2, R2, ×, ○, □, △, L1, R1, ↑, ↓, ←, →,

@soredake
Copy link

@eVenent
Copy link

eVenent commented Aug 26, 2024

Looks like SDL has finally support for pressure-sensitive buttons on Linux, MacOS and Windows: libsdl-org/SDL#5148.

Maybe now it will be easier to put it into RetroArch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request New enhancement to RetroArch. input: sdl2
Projects
None yet
Development

No branches or pull requests

4 participants