Skip to content

Comments

sdl: add support for controller sensors#18255

Merged
LibretroAdmin merged 1 commit intolibretro:masterfrom
warmenhoven:warmenhoven/pr/sdl-sensor
Sep 15, 2025
Merged

sdl: add support for controller sensors#18255
LibretroAdmin merged 1 commit intolibretro:masterfrom
warmenhoven:warmenhoven/pr/sdl-sensor

Conversation

@warmenhoven
Copy link
Collaborator

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.

@LibretroAdmin LibretroAdmin merged commit d2c6f80 into libretro:master Sep 15, 2025
31 checks passed
@warmenhoven warmenhoven deleted the warmenhoven/pr/sdl-sensor branch September 15, 2025 12:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants