Ignore non-relative MotionEvents on Oreo to fix mouse jumping when toggling capture

This commit is contained in:
Cameron Gutman 2018-03-20 20:21:21 -07:00
parent 8bac873e67
commit 40c406051c

View File

@ -970,6 +970,12 @@ public class Game extends Activity implements SurfaceHolder.Callback,
lastMouseX = (int)event.getX(); lastMouseX = (int)event.getX();
lastMouseY = (int)event.getY(); lastMouseY = (int)event.getY();
} }
else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
// We get a normal (non-relative) MotionEvent when starting pointer capture to synchronize the
// location of the cursor with our app. We don't want this, so we must discard this event.
lastMouseX = (int)event.getX();
lastMouseY = (int)event.getY();
}
else { else {
// First process the history // First process the history
for (int i = 0; i < event.getHistorySize(); i++) { for (int i = 0; i < event.getHistorySize(); i++) {