Backends: SDL2: Extend global mouse pos availability check #3950
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.
Description
This extends the run-time check that tests if global mouse position is
available to cover all SDL backends that don't support global mouse
position, instead of just Wayland. This is done by using a "allow-list"
approach of known backends that do support global mouse position, as opposed to listing backends that don't support it.
The list of known backends was determined by looking through the SDL
source code and finding all backends that expose a
GetGlobalMouseState
function. Example:
https://github.com/libsdl-org/SDL/blob/4acd1dcad41d154093ca14eb0adf35f4f99bd06a/src/video/windows/SDL_windowsmouse.c#L294
Motivation
The main purpose of this change is to have working mouse input on platforms that don't support global mouse position, like Raspberry Pi (RPI backend in SDL) or other SBCs running Linux which might be using the KMS/DRM backend to run without an X server.
Some affected platforms like Android/iOS are easily detected via compile time defines. But for the aforementioned cases like Raspberry Pi and other SBCs, there's no easy way to detect them at build time, since they all appear as generic Linux platforms in terms of available defines etc. By doing a run-time check based on the SDL backend being used, as was already done for Wayland, we can make mouse input work on these platforms as well without having to introduce custom defines into the build system.
See #2837 for some more discussion/background.