We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 2558 - Missing FINGERUP in Android
Summary: Missing FINGERUP in Android
Status: RESOLVED FIXED
Alias: None
Product: SDL
Classification: Unclassified
Component: *don't know* (show other bugs)
Version: HG 2.1
Hardware: All Android (All)
: P2 normal
Assignee: Gabriel Jacobo
QA Contact: Sam Lantinga
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-05-22 19:02 UTC by Sylvain
Modified: 2014-06-16 02:33 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Sylvain 2014-05-22 19:02:57 UTC
Hello,

This one is critical :)

If you play with the TouchScreen with +3 fingers randomly / pressing simultaneously all fingers.

You triggers FINGER DOWN events, but not always all the associated FINGER UP events.

So, after a while SDL_GetNumFingers() can report a wrong number of fingers pressed !


The explanation is hidden there : http://developer.android.com/reference/android/view/MotionEvent.html

Each pointer has a unique id that is assigned when it first goes down (indicated by ACTION_DOWN or ACTION_POINTER_DOWN). 
A pointer id remains valid until the pointer eventually goes up (indicated by ACTION_UP or ACTION_POINTER_UP) or when the gesture is canceled (indicated by ACTION_CANCEL). 

in ACTION_CANCEL : 

The current gesture has been aborted. You will not receive any more points in it. You should treat this as an up event, but not perform any action that you normally would.
Constant Value: 3 (0x00000003) 


A working patch : in SDLActivity.java (in onTouch())

<             case MotionEvent.ACTION_CANCEL:
<                 for (i = 0; i < pointerCount; i++) {
<                     pointerFingerId = event.getPointerId(i);
<                     x = event.getX(i) / mWidth;
<                     y = event.getY(i) / mHeight;
<                     p = event.getPressure(i);
<                     SDLActivity.onNativeTouch(touchDevId, pointerFingerId, MotionEvent.ACTION_UP, x, y, p);
<                 }
<                 break;

Cheers,

Sylvain
Comment 1 Sylvain 2014-05-24 08:12:34 UTC
Also ..
it does not appear with (old) Nexus7.
it appears with HTC ONE.
Comment 2 Sam Lantinga 2014-06-16 02:33:07 UTC
Fixed, thanks!
https://hg.libsdl.org/SDL/rev/e7abd1102676