mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-11-12 22:17:26 +01:00
cmd/ebitenmobile: bug fix: multiple touches were not updated correctly on Android
Closes #2220
This commit is contained in:
parent
bcb020627d
commit
64b051cc38
@ -419,11 +419,16 @@ public class EbitenView extends ViewGroup implements InputManager.InputDeviceLis
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onTouchEvent(MotionEvent e) {
|
public boolean onTouchEvent(MotionEvent e) {
|
||||||
|
// getActionIndex returns a valid value only for the action whose index is the returned value of getActionIndex (#2220).
|
||||||
|
// See https://developer.android.com/reference/android/view/MotionEvent#getActionMasked().
|
||||||
|
// For other pointers, treat their actions as MotionEvent.ACTION_MOVE.
|
||||||
|
int touchIndex = e.getActionIndex();
|
||||||
for (int i = 0; i < e.getPointerCount(); i++) {
|
for (int i = 0; i < e.getPointerCount(); i++) {
|
||||||
int id = e.getPointerId(i);
|
int id = e.getPointerId(i);
|
||||||
int x = (int)e.getX(i);
|
int x = (int)e.getX(i);
|
||||||
int y = (int)e.getY(i);
|
int y = (int)e.getY(i);
|
||||||
Ebitenmobileview.updateTouchesOnAndroid(e.getActionMasked(), id, (int)pxToDp(x), (int)pxToDp(y));
|
int action = (i == touchIndex) ? e.getActionMasked() : MotionEvent.ACTION_MOVE;
|
||||||
|
Ebitenmobileview.updateTouchesOnAndroid(action, id, (int)pxToDp(x), (int)pxToDp(y));
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user