macos: Integrate GCMouse for raw mouse input #14741
Open
+284
−10
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.
Happy New Years btw 🎆🍾
Description
macOS 11.0+ now use GCMouse while remaining backwards compatabile with
NSEventbased mouse handling in older versions of Mac. This gives us raw mouse input data instead of the acceleration-based data fromNSEvent.Existing Issue(s)
Closes #10146
Tested
Built SDL3 locally, on macOS
12.6.7, usingtest/testrelativewith some added tempSDL_LOG. Apologies but I don't have a Mac device I can locally test the fallback originalNSEventimplementation on macOS 11 or older.I tested in both my branch and main branch with these similar movements: slow horizontal swipe, then fast horizontal swipe left and right.
These logs are long, but they print out rows formatted roughly
<Apple Input Handler Framework>: <deltaX>, <deltaY>.tldr is that it shows
GCMousehas raw deltaXs that increase linearly based on speed, andNSEventoutput raw deltaXs that are multiplied by acceleration.FYI
GCMouselogged more events likely due to less OS-level event coalescing and our high-priority dispatch queue, though the primary benefit is raw (unaccelerated) deltas rather than guaranteed higher frequency.GCMouselogs:NSEventlogs:Last Note
Didn't implement
SDL_MOUSE_RELATIVE_MODE_CENTERsupport in this PR since GCMouse delivers raw deltas directly from the mouse hardware, so cursor confinement location doesn't affect the input values and from what I understand the hint only matters for fallback scenarios where SDL uses cursor position to calculate movement. Lmk if i'm wrong and this can always be implemented in a future PR.