Skip to content

Conversation

ashley68k
Copy link
Contributor

Fixes #118

I have tested this and it seems to fix the issue. Further testing across different system configurations and some code review is necessary. It still works gracefully irregardless of mouse sensitivity, threshold, holding strafe modifier, fullscreen/windowed etc.

Copy link
Owner

@fabiangreffrath fabiangreffrath left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you very much! Improvement of input handling is rather high on my priority list for this project, so this is highly appreciated.

@fabiangreffrath fabiangreffrath merged commit 0e7a215 into fabiangreffrath:main Sep 4, 2025
3 of 4 checks passed
@ashley68k
Copy link
Contributor Author

Looking at this again with fresh eyes in the morning, and it's also worth noting that the sdl_mouse_motion_filter() function in rt_in.c might be unnecessary with this change as this patch means that you're no longer manually tracking mouse state. I tried gutting the function and it seems to still work fine. Essentially the point of the function is to directly parse out the mouse delta from motion event and propagate sdl_mouse_delta to be fed back to the caller of INL_GetMouseDelta(). This is basically what SDL_GetRelativeMouseState() and the new solution does, but it completely bypasses the filter as mouse_relative_x and mouse_relative_y are set but no longer passed along.. I worry it could possibly break trackballs, as SDL_JOYBALLMOTION represents a trackball event. However I think that most trackballs trigger mouse movements anyways, or maybe analog stick input on controllers. If this is the case, the function is superfluous as mouse_relative_x and mouse_relative_y are no longer passed thru INL_GetMouseDelta() and SDL now handles mouse motion state. If not, the old filter function might have to be adjusted to use GetRelativeMouseState if not a joyball, and use old joyball logic for joyballs.

@fabiangreffrath
Copy link
Owner

I don't care about trackballs (and I don't think other ports do), so if you see more opportunity for further cleaning up that code, please feel free to file another PR.

@ashley68k
Copy link
Contributor Author

Sure! I think it also removes the need for the sdl_mouse_grabbed stuff. It seems that the mouse is automatically grabbed by fullscreen, but the issue is that it isn't grabbed in windowed mode either before or after, so I may look into that as well. Thanks!

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.

Mouse precision issues on Linux
2 participants