I'm trying to get my head around the basics of Android Java dev and have run into an issue handling multiple inputs at the same time.
I'm having a reproducible issue where, if multiple fingers are used, the info of the first finger's touch down is used as the touch down for the second. It's causing serious issues with buttons getting 'stuck' on as the id that leaves them is not the same one that activated them.
I have two examples of the touch event logs, the first showing touches like below where they are both initiated and ended at the same time, and the second showing the second drag starting after the first has already started. Notice that both touch_down events share the same info, for some reason.
MultiTouchHandler where the pointerIDs are assigned for new events and is found here (SO formatting isn't working for some reason?)
Am I misunderstanding how the pointerIDs are assigned or have I caused an error in the above some how?
For future googlers:
Replacing the (evidently) now deprecated
int action = event.getAction() & MotionEvent.ACTION_MASK; int pointerIndex = (event.getActionIndex() & MotionEvent.ACTION_POINTER_INDEX_MASK) >> MotionEvent.ACTION_POINTER_INDEX_SHIFT;
at the top of the onTouch override with:
int action = MotionEventCompat.getActionMasked(event); int pointerIndex = MotionEventCompat.getActionIndex(event);
-has fixed the issue.