Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android multi-touch interference

I'm currently developing an air-hockey simulation for android. For the multiplayer mode I'm tracking two touch events on the screen, which works well as long as the touch points don't get to close. Normal Touch

When the two fingers get to close, android only recognizes one touch event, in the middle of both points.

Two events overlapping

To make it even worse, android sometimes messes up the IDs after the collision.

Wrong IDs assigned

I already thought about estimating the next touch points ans assigning IDs manually, does anybody know a better way, or knows about somebody who already fixed this problem programmatically?

NOTE: I'm testing on a Samsung Galaxy S 3

like image 462
NCode Avatar asked Sep 19 '12 18:09

NCode


People also ask

How does Android handle multiple touch?

To support multiple touch pointers, you can cache all active pointers with their IDs at their individual ACTION_POINTER_DOWN and ACTION_DOWN event time; remove the pointers from your cache at their ACTION_POINTER_UP and ACTION_UP events.

What is multitouch interface?

Multi-touch interfaces are input devices that recognize two or more simultaneous touches, allowing one or more users to interact with computer applications through various gestures created by fingers on a surface. Some devices also recognize differences in pressure and temperature.

How do I fix my Samsung multitouch?

You can test the multi touch function of the display by calling *#*#4636#*#* on your keypad, it will open up some troubleshooting options, one of which asks you to touch the screen with all fingers and it will show you how many are being recognised and help you to identify if it really is a display issue, or an issue ...


1 Answers

Not necessarily a logical fix to the issue, nevertheless a possible solution to the application:

If I'm not completely mistaken, air-hockey games shouldn't allow opponents to intrude on each others game field. If we assume a thick border cross the center of the screen (in portrait mode), then I wouldn't be allowed to do anything beyond that border, hence there is no point in tracking my finger after it reaches the border line.

Encapsulating your tracked touch events into valid physical locations as described might just help you in ignoring invalid points (given that the physical locations doesn't intersect, that is).

You might also have to keep track of direction of the touch vector: if the vector is stretching from the center of the screen towards "your end" it might be the opponents intruding finger or your own returning finger. In neither case should they affect the hockey puck (perhaps).

like image 197
dbm Avatar answered Sep 20 '22 20:09

dbm