visionOS: fixed mousewheel values

Here are the observed values using a Bluetooth mouse on visionOS 26.5

Slow scroll up:
Mouse scroll: 0,-0.017334
Mouse scroll: 0,0
Mouse scroll: 0,-0.017334
Mouse scroll: 0,0

Slow scroll down:
Mouse scroll: 0,0.017334
Mouse scroll: 0,0
Mouse scroll: 0,0.017334
Mouse scroll: 0,0

Fast scroll up:
Mouse scroll: 0,-0.017334
Mouse scroll: 0,-9.36021
Mouse scroll: 0,-100.08
Mouse scroll: 0,-75.2287
Mouse scroll: 0,-82.2284
Mouse scroll: 0,-92.0137
Mouse scroll: 0,-95.1917
Mouse scroll: 0,-101.846
Mouse scroll: 0,-203.266
Mouse scroll: 0,0

Fast scroll down:
Mouse scroll: 0,0.017334
Mouse scroll: 0,11.424
Mouse scroll: 0,59.3571
Mouse scroll: 0,68.7859
Mouse scroll: 0,267.834
Mouse scroll: 0,95.0823
Mouse scroll: 0,201.809
Mouse scroll: 0,0
This commit is contained in:
Sam Lantinga
2026-05-19 15:41:04 -07:00
parent cfed9b3aca
commit f9380e15de

View File

@@ -359,15 +359,18 @@ static void OnGCMouseConnected(GCMouse *mouse) API_AVAILABLE(macos(11.0), ios(14
mouse.mouseInput.scroll.valueChangedHandler = ^(GCControllerDirectionPad *dpad, float xValue, float yValue) {
Uint64 timestamp = SDL_GetTicksNS();
#ifdef SDL_PLATFORM_VISIONOS
/* Mouse scroll values on visionOS have swapped axes compared to other platforms.
* There is also an acceleration ramp applied, so clamp to a single tick per event.
*/
float vertical = yValue < 0 ? -1 : yValue > 0 ? 1 : 0;
float horizontal = xValue < 0 ? -1 : xValue > 0 ? 1 : 0;
#else
/* Raw scroll values come in here, vertical values in the first axis, horizontal values in the second axis.
* The vertical values are negative moving the mouse wheel up and positive moving it down.
* The horizontal values are negative moving the mouse wheel left and positive moving it right.
* The vertical values are inverted compared to SDL, and the horizontal values are as expected.
*/
#ifdef SDL_PLATFORM_VISIONOS
float vertical = -yValue;
float horizontal = xValue;
#else
float vertical = -xValue;
float horizontal = yValue;
#endif