We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 5448 - Switch Pro Controller broken with HIDAPI when SDL is compiled without threading
Summary: Switch Pro Controller broken with HIDAPI when SDL is compiled without threading
Status: ASSIGNED
Alias: None
Product: SDL
Classification: Unclassified
Component: joystick (show other bugs)
Version: 2.0.15
Hardware: x86 Windows 10
: P2 normal
Assignee: Ryan C. Gordon
QA Contact: Sam Lantinga
URL:
Keywords: target-2.0.16
Depends on:
Blocks:
 
Reported: 2021-01-06 10:17 UTC by Lukas Meller
Modified: 2021-01-23 19:27 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Lukas Meller 2021-01-06 10:17:54 UTC
In an attempt to strip the SDL library to the minimal functionality as it's currently only being used for input handling on our side, I disabled as many subsystems and other build flags as seemed reasonable to me, and this included the threads flag. SDL does check for certain build flags dependencies during compilation, so I thought it would not cause any issues to disable as much as I can.

Anyhow, everything seemed fine at first: the Game Controller API was working fine and dandy for all controllers I've tested: Xbox 360, Logitech Dual Action, PS4 Dual Shock - however it breaks Switch Pro controllers.

The core issue is that the HIDAPI Switch code calls SDL_HIDAPI_LockRumble, which in turn relies on threading support. (Grepping for this function yields results for PS5 and Xbox One as well, so I assume those have similar issues but I wasn't able to test that.) This makes SDL report the error "Couldn't load stick calibration".

SDL_GameControllerOpen will end up returning null on SDL_CONTROLLERDEVICEADDED caused by the joystick driver failing to be opened.

Now, personally, I just enabled threading support to fix this issue. However, it would be nice if the issue had been less obscure. I think requiring threading to be enabled when using HIDAPI during compilation is a pretty simple solution - requiring threading to handle modern gamepads on desktop platforms doesn't seem like a lot to ask even if you're not going to end up ever using any of these few specially handled gamepads.
Comment 1 Lukas Meller 2021-01-06 10:28:19 UTC
Okay, all of the rumble functionality handled via HIDAPI actually requires threading (which seems obvious given the function name that fails!), so it's not even just the Switch Pro controllers and a few others that are at least somewhat broken without threading. Adding a build script requirement definitely seems reasonable :)
Comment 2 Sam Lantinga 2021-01-23 19:27:37 UTC
At this point there are several subsystems that require thread support for correct functionality, so maybe we need to prevent disabling threads?