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

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?

1 Like

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.