sokol icon indicating copy to clipboard operation
sokol copied to clipboard

Trackpad touch events

Open bmcorser opened this issue 3 years ago • 1 comments

I've been having a great time using Sokol over the past few weeks (making a sort of wavetable synth toy). I had the opportunity to "demo" my app to a few people this weekend on an Apple laptop; almost all of them immediately reached for pinch and scroll using the trackpad -- rather using than the Vim keybindings I'd set up!

sokol_app.h supports low-level touch events via SAPP_EVENTTYPE_TOUCHES_* on iOS, Android and HTML5.

I wonder if there's any appetite for implementing these event types for macOS (and I suppose Windows, Linux) targets too?

bmcorser avatar Mar 29 '21 19:03 bmcorser

Separate from your actual question: if it's just about scrolling via the touchpad, this can be done by reacting to MOUSE_SCROLL events, like here in the Dear ImGui rendering backend:

https://github.com/floooh/sokol/blob/52898ed656d7fa5290c8b1cab13d9752c45f59af/util/sokol_imgui.h#L2087-L2090

On macOS, Linux and Windows this lets me scroll vertically and horizontally via two-finger-dragging on the touchpad.

Actual touch event support might make sense too, but IMHO the "important part" of drag-scrolling is already covered by the mouse-wheel events. Actual touch event support would be needed for high-level multi-touch gestures such as zoom and rotate though (I haven't looked at "desktop multi-touch APIs" yet, we'd need to figure out how this is implemented on Windows, macOS and Linux, and whether those touch events match the usual begin/moved/finished/cancelled events with per-touch-point-ids).

floooh avatar Mar 30 '21 11:03 floooh