libsdl-org / SDL

Simple Directmedia Layer
https://libsdl.org
zlib License
9.73k stars 1.81k forks source link

macOS trackpad SDL_TouchFingerEvent arriving "clumped" and late at beginning of motion #7690

Open Rojetto opened 1 year ago

Rojetto commented 1 year ago

I'm using SDL_FingerTouchEvents to implement two-finger panning and pinch-zooming for macOS trackpads (using a Macbook Air M2). This works in principle, but at the beginning of every two finger gesture, there is some visual hitching. Afterwards, all motions look smooth.

I can see in my profiler that I'm not dropping frames. Instead, the SDL events seem to get "clumped" up at the beginning of the motion, then come all in one burst 100-200 ms later, which changes the on-screen object's position in one big step, leading to the visual hitch.

image

I've noticed the same thing happening with SDL_MultiGestureEvents. Maybe there is some kind of touch threshold value I can disable?

slouken commented 4 months ago

I think what's happening here is that the OS is delaying the touch events to see whether they match a system gesture, and only passes them to the application if they don't. I think there's a way to disable system gestures, but I'm not sure.

https://github.com/libsdl-org/SDL/pull/9445 may help by providing this information directly to your app, without you having to reimplement gestures yourself.

slouken commented 1 week ago

We are scoping work for the SDL 3.2.0 release, so please let us know if this is a showstopper for you.