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

Backends: SDL2: Extend global mouse pos availability check #3950

Conversation

lethal-guitar
Copy link
Contributor

@lethal-guitar lethal-guitar commented Mar 20, 2021

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.

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.

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
@ocornut
Copy link
Owner

ocornut commented Mar 22, 2021

Thank for the PR and details.
I have now merged this with slight modifications: see 186b734

@ocornut ocornut closed this Mar 22, 2021
@hinxx hinxx mentioned this pull request Mar 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants