Kevin
Kevin

Reputation: 1200

Android multi-touch headaches

I've getting a real problem trying to deal with multi-touch events. Basically I need to detect if someone has released a finger while touching the screen elsewhere.

According to this previously answered question, I should be using MotionEvent.ACTION_POINTER_UP MotionEvent.ACTION_UP.

As far as I can tell, the following code should tell me if a finger has been lifted:

    int action = event.getActionMasked();
    mCurUp = ( action == MotionEvent.ACTION_UP ) || ( action == MotionEvent.ACTION_POINTER_UP );

What I am seeing in practice, is that this works some of the time. If I am really careful I can hold my left finger on the screen and lift my right finger and no events are fired at all! Usually at some point my left finger will wobble, generating a ACTION_MOVE event. At this point it generates an event (262) which I think correlates to ACTION_POINTER_UP

So I'm wondering if any other folks have seen this, and I also suspect it might be the notoriously poor touchscreen on my HTC Desire causing this. Or perhaps I am doing something fundamentally wrong. Does anyone have some tested code that can reliably detect lifting either finger from the touchscreen?

Upvotes: 3

Views: 943

Answers (2)

Philzen
Philzen

Reputation: 4647

This class looks like it has a workaround for your problem and many others caused by buggy multitouch implementation on some android 1.x/2.x devices

http://code.google.com/p/android-multitouch-controller/

The issue you mentioned is explained there as follows:

NOTE: rotation is quirky on older touchscreen devices that use a Synaptics or Synaptics-like "2x1D" sensor (G1, MyTouch, Droid, Nexus One) and not a true 2D sensor like the HTC Incredible or HTC EVO 4G. The quirky behavior results from "axis snapping" when the two points get close together in X or Y, and "ordinate confusion" where (x1,y1) and (x2,y2) get confused for (x1,y2) and (x2,y1). There is no way around this other than to keep the two fingers in the same two relative quadrants (i.e. keep them on a leading or a trailing diagonal), or to disallow rotation on these devices. (In spite of misinformation on the Web, there is also no firmware or software update that can fix this problem, it is a hardware limitation. Hopefully all newer phones will have a true 2D touch sensor.)

Upvotes: 0

Rokey Ge
Rokey Ge

Reputation: 681

it is possible that the weird behaviour is caused by your device (HTC Desire == Nexus One screen), rather than your code.

Do you know although Android support multi-touch, not every phone support real multitouch?

Have a read of this

http://androidandme.com/2010/03/news/is-multitouch-broken-on-the-nexus-one/

and this

http://groups.google.com/group/android-developers/msg/70e9dd235d519955

Cheers

Upvotes: 1

Related Questions