From 1fb38b7b23e2a00110e83959bd3cb966fdf8215b Mon Sep 17 00:00:00 2001 From: Sandro Meier Date: Mon, 14 Nov 2022 14:05:00 +0000 Subject: [PATCH] Add documentation about pressure to VirtualTouchEvent The underlying input devices are configured with a pressure range of 0-255. MotionEvent uses a normalized range of 0.0-1.0, which has caused some confusion. This change adds documentation about the expected range. Test: Documentation only change Bug: 259554911 Change-Id: Iddb6cd5b5cd23bb15f75620041d7d3cbf49959db --- .../java/android/hardware/input/VirtualTouchEvent.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/core/java/android/hardware/input/VirtualTouchEvent.java b/core/java/android/hardware/input/VirtualTouchEvent.java index c7450d8fa65d7..ad51eb894e221 100644 --- a/core/java/android/hardware/input/VirtualTouchEvent.java +++ b/core/java/android/hardware/input/VirtualTouchEvent.java @@ -262,6 +262,16 @@ public final class VirtualTouchEvent implements Parcelable { /** * Sets the pressure of the event. This field is optional and can be omitted. * + * @param pressure The pressure of the touch. + * Note: The VirtualTouchscreen, consuming VirtualTouchEvents, is + * configured with a pressure axis range from 0.0 to 255.0. Only the + * lower end of the range is enforced. You can pass values larger than + * 255.0. With physical input devices this could happen if the + * calibration is off. Values larger than 255.0 will not be trimmed and + * passed on as is. + * + * @throws IllegalArgumentException if the pressure is smaller than 0. + * * @return this builder, to allow for chaining of calls */ public @NonNull Builder setPressure(@FloatRange(from = 0f) float pressure) {