wtf android multitouch

March 3, 2012 @ 10:48

This blog is really starting to seem like a rant about bugs. Today’s is dealing with multitouch on Android. My conclusions:

  • Android 3.0+ handles multitouch almost perfectly, and supports multiple pointers. All devices I’ve tested have handled 4 pointers.
  • Android 2.x (I’m testing with 2.3.5 and 2.3.7) sometimes works and sometimes doesn’t, it seems to depend on hardware.

I have a Motorola Droid2, some friends have T-Mobile G2’s, and another friend has a HTC Evo something-or-rather. The G2 works fine, but the Droid2 and Evo don’t.

I wrote a test program that tracks two simultaneous touches, and the location of them. In these logs, the pointer number should be the index number of the touch event, where “touch event” is defined as from the time you touch until you release all touches. In Android 3+, it correctly keeps track of up to 4 pointers (on my hardware anyway) correctly, such that the ids of the touches don’t change. These logs are from my Droid2. “left” and “right” are as reported by the X coordinate of the touch event. The boolean is my attempt to detect when we’re in “stupid mode” as I’ve been calling it.

  1. I touch left, then tap right on and off:
D/GameView(29118): pointer 0 down false left
D/GameView(29118): pointer 1 down false right
D/GameView(29118): pointer 1 up false right
D/GameView(29118): pointer 1 down false right
D/GameView(29118): pointer 1 up false right
D/GameView(29118): all up false
  1. I touch left, touch right, then release and tap the left pointer:
D/GameView(29772): pointer 0 down false left
D/GameView(29772): pointer 1 down false right
D/GameView(29772): pointer 0 up false left
D/GameView(29772): stupid mode enabled
D/GameView(29772): pointer 0 down true right
D/GameView(29772): pointer 1 up true left
D/GameView(29772): pointer 1 down true right
D/GameView(29772): pointer 0 up true left
D/GameView(29772): pointer 0 down true right
D/GameView(29772): pointer 1 up true left
D/GameView(29772): pointer 1 down true right
D/GameView(29772): pointer 0 up true left
D/GameView(29772): all up false

You will notice in #2 there that it gets confused as to which number pointer I’ve been tapping, and it even reports the coordinates of the other pointer in the ‘down’ event. This is “stupid mode” :) Since there are still so many 2.x devices, I now have to work around this somehow. Fun!