sdl: add support for controller sensors#18255
Merged
LibretroAdmin merged 1 commit intolibretro:masterfrom Sep 15, 2025
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Continuing to break #16188 up into more manageable bits....
Part 2: SDL GameController sensors
SDL has two sensor APIs, one added in 2.0.9 (SDL_Sensor) and one added in 2.0.14 (SDL_GameControllerHasSensor). The original PR was trying to support them both, but it ended up making the code needlessly complex (and buggy, I have a list).
Instead we're going to divide and conquer. And the first step of that is distinguishing system sensors from joypad sensors. To that end, input_driver.c its sensor management so that when a core asks to enable a type of sensor, both system and joypad sensors will be enabled (previously only one was, and system was tried first); and so that when querying an input port for its sensor state, the joypad on that port will be queried first, and if it doesn't handle it, the system sensor will be polled. This is a pretty small and relatively inconsequential change as there aren't currently any joypad driver sensor functions.
The rest of this PR is adding support for the SDL 2.0.14 SDL_GameController sensors, in a way already tied into the existing joypad driver management.