Merge pull request #11686 from t895/index-fix

Android: Ignore input from invalid pointer identifier
This commit is contained in:
JosJuice 2023-03-24 17:57:19 +01:00 committed by GitHub
commit 7de01597c6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 5 deletions

View File

@ -108,20 +108,21 @@ public class InputOverlayPointer
break; break;
} }
if (trackId == -1) int eventPointerIndex = event.findPointerIndex(trackId);
if (trackId == -1 || eventPointerIndex == -1)
return; return;
if (mMode == MODE_FOLLOW) if (mMode == MODE_FOLLOW)
{ {
mCurrentX = (event.getX(event.findPointerIndex(trackId)) - mGameCenterX) * mGameWidthHalfInv; mCurrentX = (event.getX(eventPointerIndex) - mGameCenterX) * mGameWidthHalfInv;
mCurrentY = (event.getY(event.findPointerIndex(trackId)) - mGameCenterY) * mGameHeightHalfInv; mCurrentY = (event.getY(eventPointerIndex) - mGameCenterY) * mGameHeightHalfInv;
} }
else if (mMode == MODE_DRAG) else if (mMode == MODE_DRAG)
{ {
mCurrentX = mOldX + mCurrentX = mOldX +
(event.getX(event.findPointerIndex(trackId)) - mTouchStartX) * mGameWidthHalfInv; (event.getX(eventPointerIndex) - mTouchStartX) * mGameWidthHalfInv;
mCurrentY = mOldY + mCurrentY = mOldY +
(event.getY(event.findPointerIndex(trackId)) - mTouchStartY) * mGameHeightHalfInv; (event.getY(eventPointerIndex) - mTouchStartY) * mGameHeightHalfInv;
} }
} }