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

SDL_SetRelativeMouseMode(false) doesn't work? #327

Open
sfan5 opened this issue Feb 8, 2025 · 4 comments
Open

SDL_SetRelativeMouseMode(false) doesn't work? #327

sfan5 opened this issue Feb 8, 2025 · 4 comments
Assignees
Labels
Milestone

Comments

@sfan5
Copy link

sfan5 commented Feb 8, 2025

In Luanti we use SDL_WarpMouseInWindow to fix the mouse at the middle of window in typical FPS style.
Relative mode isn't used except for certain platforms (e.g. Linux+Wayland), because some people reported problems with it on Linux+X11.

This does not seem to work anymore with sdl2-compat in use.
SDL_HINT_MOUSE_EMULATE_WARP_WITH_RELATIVE sounds like it could be related and I'm wondering if it should be turned off by default when using sdl2-compat.

note: if you want to test this with Luanti right now you will need to use -DUSE_SDL2=ON

versions:

sdl2-compat 2.30.52-1
sdl3 3.2.2-1
@icculus icculus added this to the 2.30.56 milestone Feb 8, 2025
@slouken slouken modified the milestones: 2.32.50, 2.32.52 Feb 8, 2025
@sfan5
Copy link
Author

sfan5 commented Feb 8, 2025

Forgot to mention: I noticed this by chance while having the game open when connected via a VNC session.
With relative mode disabled, the camera can be successfully moved by carefully moving the mouse around the crosshair (since just the warping won't work).
With relative mode enabled, the camera cannot be controlled no matter what and will spin endlessly.

@slouken
Copy link
Collaborator

slouken commented Feb 14, 2025

I have it built, but I have no idea how to test relative mode. Can you give me a quick start with repro steps for dummies?

@Desour
Copy link

Desour commented Feb 14, 2025

I have it built, but I have no idea how to test relative mode. Can you give me a quick start with repro steps for dummies?

To en-/disable relative mouse mode, the easiest way is probably to use luanti-org/luanti#15770 and search for the enable_relative_mouse_mode setting in-game (or esc -> settings -> keyboard and mouse, tick Show technical names). (And remove the SDL_SetHint line if you want to test this as well.)

The difference between relative and non-relative mode is - for me at least - very apparent. Non-relative is much slower and not as smooth.

SDL_HINT_MOUSE_EMULATE_WARP_WITH_RELATIVE is essentially working as intended.

In luanti, we have disabled relative mode in response to an issue, which apparently doesn't happen without relative mode. (Idk how common such issues are.) And SDL_HINT_MOUSE_EMULATE_WARP_WITH_RELATIVE would undo this "fix". So it could perhaps break some games for some users.
(At least this is how I understood this issue.)

Users could of course also disable the hint via environment variable.

@sfan5
Copy link
Author

sfan5 commented Feb 14, 2025

As I mentioned for me the VNC quirk is the only way to see if relative mode is enabled or not.
The gist of this issue is not that there's something wrong with relative mode. More a question of whether SDL3 + sdl2-compat should differ in behavior from SDL2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants