mirror of
https://github.com/moonlight-stream/moonlight-android.git
synced 2025-07-04 00:35:47 +00:00
Fix NPE if we receive a SOURCE_CLASS_POSITION event with no associated device
This commit is contained in:
parent
b9031785ac
commit
f2e2e28419
@ -1280,8 +1280,10 @@ public class Game extends Activity implements SurfaceHolder.Callback,
|
|||||||
// Trackpad on newer versions of Android (Oreo and later) should be caught by the
|
// Trackpad on newer versions of Android (Oreo and later) should be caught by the
|
||||||
// relative axes case above. If we get here, we're on an older version that doesn't
|
// relative axes case above. If we get here, we're on an older version that doesn't
|
||||||
// support pointer capture.
|
// support pointer capture.
|
||||||
InputDevice.MotionRange xRange = event.getDevice().getMotionRange(MotionEvent.AXIS_X, event.getSource());
|
InputDevice device = event.getDevice();
|
||||||
InputDevice.MotionRange yRange = event.getDevice().getMotionRange(MotionEvent.AXIS_Y, event.getSource());
|
if (device != null) {
|
||||||
|
InputDevice.MotionRange xRange = device.getMotionRange(MotionEvent.AXIS_X, event.getSource());
|
||||||
|
InputDevice.MotionRange yRange = device.getMotionRange(MotionEvent.AXIS_Y, event.getSource());
|
||||||
|
|
||||||
// All touchpads coordinate planes should start at (0, 0)
|
// All touchpads coordinate planes should start at (0, 0)
|
||||||
if (xRange != null && yRange != null && xRange.getMin() == 0 && yRange.getMin() == 0) {
|
if (xRange != null && yRange != null && xRange.getMin() == 0 && yRange.getMin() == 0) {
|
||||||
@ -1290,10 +1292,9 @@ public class Game extends Activity implements SurfaceHolder.Callback,
|
|||||||
|
|
||||||
// Touchpads must be smaller than (65535, 65535)
|
// Touchpads must be smaller than (65535, 65535)
|
||||||
if (xMax <= Short.MAX_VALUE && yMax <= Short.MAX_VALUE) {
|
if (xMax <= Short.MAX_VALUE && yMax <= Short.MAX_VALUE) {
|
||||||
conn.sendMousePosition((short)event.getAxisValue(MotionEvent.AXIS_X),
|
conn.sendMousePosition((short)event.getX(), (short)event.getY(),
|
||||||
(short)event.getAxisValue(MotionEvent.AXIS_Y),
|
(short)xMax, (short)yMax);
|
||||||
(short)xMax,
|
}
|
||||||
(short)yMax);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user