EmscriptenTouchEvent

178 views
Skip to first unread message

McLaurin Entertainment

unread,
Sep 10, 2018, 5:39:48 PM9/10/18
to emscripten-discuss
I am using Emscripten to get a number of C++ games running under HTML5.  The client requires that these games also run in a mobile web browser, they do not want to make a native app.

The games require me to properly handle multitouch events - if the user applies three fingers to the screen, I have to react accordingly to all three fingers.  However, I'm seeing an issue when testing on Safari on an iPad Mini, and I expect it happens elsewhere as well (though so far I'm not seeing it on Android).

What I'm finding is that when a touch callback is hit, for instance if I set a callback via emscripten_set_touchend_callback, then whenever a touchend event occurs, that callback gets hit with all active touchpoints included in the EmscriptenTouchEvent.  As such, I don't know which touchpoint the event applies to.  For instance if three fingers are down, and you lift the second finger, all three touchpoints are passed to the touchend callback.  Is there a way for me to determine which touchpoint the touchend event applies to?  If this is a bug, is there a known workaround?

Thank you in advance.

John



Floh

unread,
Sep 11, 2018, 8:00:50 AM9/11/18
to emscripten-discuss
I think the "isChanged" member in EmscriptenTouchPoint gives you this information, together with the "identifier" member to associate the touch point with touches in previous events. 

Basically, when you get a TOUCHEND event, the touch point(s) which have isChanged set to true should be the ones that have been 'lifted', and the other touch points are the state of the remaining active touches

Interestingly I just noticed that in my own gesture recognizer (copied more or less from the Android NDK), the isChanged information isn't even used, the recognizers just get the same information from some followup event (e.g. a MOVE) which has fewer touch points then expected.

Cheers!
-Floh.

McLaurin Entertainment

unread,
Sep 11, 2018, 8:52:13 AM9/11/18
to emscripten-discuss
Thank you Floh!

I actually found a solution to the problem on this website:


Basically, you're right that the isChanged field is supposed to convey the information to the user, but it wasn't being set properly on some platforms - the Javascript code on the above link fixes the problem (and I was able to confirm the fix).

John
Reply all
Reply to author
Forward
0 new messages