floooh / sokol

minimal cross-platform standalone C headers
https://floooh.github.io/sokol-html5
zlib License
6.84k stars 480 forks source link

windows WM_TOUCH events? #1089

Open voidware opened 1 month ago

voidware commented 1 month ago

Sorry if asked already. Are there any plans to support WM_TOUCH under windows. Or Maybe there is a patch?

Thanks.

floooh commented 1 month ago

Currently none of the desktop OS backends support the touch events.

I'm curious, what is your use case, laptops with touch screen or gesture recognition via touchpad?

voidware commented 1 month ago

I have a pinch-and-zoom action on Android/iOS and I wondered if this could work on a Windows touch-screen laptop.

But after investigation, i ran into more problems. The Windows laptop seems to do pinch-and-zoom itself. I don't know whether this can be changed, but i can pinch any app and it does it. Although sometimes it seems Windows converts an apparent pinch/zoom into scroll-wheel zoom. This means Windows might not be sending the WM_TOUCH in such case.

I cannot figure out whether this can be adjusted. Presumably Windows must still send WM_TOUCH for 3 and 4 finger touches, but maybe it converts to scroll-wheel for 2 finger. Is this even optional.

This whole thing came about because I was debugging my pinch/zoom code. Turns out if I compile for Web then run this under Windows, the touches work as expected. So weirdly the browser here must be intercepting the touch events and sending those as web touch events (or something similar) and it all works.

So I don't think WM_TOUCH for windows is a priority, but I guess at some point it makes sense.

floooh commented 1 month ago

If WM_TOUCH is fundamentally compatible with the cross-platform low level touch events exposed by sokol_app.h (e.g. TOUCHES_BEGAN/MOVED/ENDED/CANCELLED) then it should be relatively easy.

This doesn't include any sort of gesture recognition though (e.g. pinch/zoom/rotate). Some platforms have integrated gesture recognition, some don't, so it's hard to expose gestures as a cross-platform feature. Instead gesture recognition would need to be done on top of the lower level touch events and could go into a new sokol_gestures.h header (I had a small number of gesture recognizers which were ported from example code in the Android NDK: https://github.com/floooh/oryol/blob/master/code/Modules/Input/private/gestureDetectors.h).