Skip to content

Commit

Permalink
Provide a default pressure range if a MotionEvent does not have a dev…
Browse files Browse the repository at this point in the history
  • Loading branch information
jason-simmons authored Feb 11, 2019
1 parent 5dfa029 commit 694300d
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions shell/platform/android/io/flutter/view/FlutterView.java
Original file line number Diff line number Diff line change
Expand Up @@ -472,10 +472,15 @@ private void addPointerForIndex(MotionEvent event, int pointerIndex, int pointer

packet.putLong(0); // obscured

InputDevice.MotionRange pressureRange = event.getDevice().getMotionRange(MotionEvent.AXIS_PRESSURE);
packet.putDouble(event.getPressure(pointerIndex)); // pressure
packet.putDouble(pressureRange.getMin()); // pressure_min
packet.putDouble(pressureRange.getMax()); // pressure_max
if (event.getDevice() != null) {
InputDevice.MotionRange pressureRange = event.getDevice().getMotionRange(MotionEvent.AXIS_PRESSURE);
packet.putDouble(pressureRange.getMin()); // pressure_min
packet.putDouble(pressureRange.getMax()); // pressure_max
} else {
packet.putDouble(0.0); // pressure_min
packet.putDouble(1.0); // pressure_max
}

if (pointerKind == kPointerDeviceKindStylus) {
packet.putDouble(event.getAxisValue(MotionEvent.AXIS_DISTANCE, pointerIndex)); // distance
Expand Down

0 comments on commit 694300d

Please sign in to comment.