A bit frustrating: there is no touch mode that works cross-platform without major caveats [SOLVED! / vastly improved in hg]


#1

Today I was quite frustrated with SDL2, because it seems like there is no touch mode that works cross-platform without major caveats even just for simple single finger touch.

The problem with the dedicated SDL_TouchFingerEvent is that it lacks a windowID even though it returns window coordinates, making it useless for desktop applications that are not trivial: https://bugzilla.libsdl.org/show_bug.cgi?id=4331

The problem with SDL_TOUCH_MOUSEID is that on Android, it is forcibly mushed together with hw mouse without distinction (or alternatively entirely unavailable) meaning it can’t be used if you want to properly support hw mouses as well: https://bugzilla.libsdl.org/show_bug.cgi?id=4572 UPDATE: FIXED!! YAY

This means getting the touch to work on all platforms will require using BOTH, but just the RIGHT one of these mechanisms for the respective platform. That really is no fun, and quite complicates comprehensive event handling.

Is there some roadmap on when these problems will be possibly addressed?


#2

Use these hints:

SDL_SetHint(SDL_HINT_TOUCH_MOUSE_EVENTS, "0");
SDL_SetHint(SDL_HINT_ANDROID_SEPARATE_MOUSE_AND_TOUCH, "1");

Then multiply your touch events by window / renderer width & height and they should mirror mouse coordinates.


#3

That may be well-intentioned, but just check the tickets for the in-depth discussion if you’re curious about why these are real showstoppers. Because this works, yes, but it’s useless outside of android when you may have more than one window (and I usually do) - while SDL_TOUCH_MOUSEID works outside of android but on android is useless since not separable from actual hw mouse events.

Which means, as summed up in my initial post, no matter what you pick for one platform it won’t work

Edit: YAY!!! SDL_TOUCH_MOUSEID was now fixed to work the same on Android! So this is solved