summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Chris Ye <lzye@google.com> 2020-10-10 19:59:52 +0000
committer Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> 2020-10-10 19:59:52 +0000
commitdcd5d0b7f44b98d369b86b7f4f5420cf1e9877d3 (patch)
tree01a88e266d473f2f35e2a44314d8d2ee68460288
parentfd03b1b4df37b09263279d7d69c69c841f873e1f (diff)
parent96fb6c70ad77bfff035c9f25d53ef446407b40f3 (diff)
Populate RELATIVE_X and RELATIVE_Y motion range for touchpad pointer capture mode. am: 1fb4530260 am: 8ed0e785be am: 96fb6c70ad
Original change: https://android-review.googlesource.com/c/platform/frameworks/native/+/1447899 Change-Id: Ia86ae64f61f8408b394d5a22cc71cc52a856b57e
-rw-r--r--services/inputflinger/reader/mapper/TouchInputMapper.cpp13
-rw-r--r--services/inputflinger/tests/InputReader_test.cpp14
2 files changed, 27 insertions, 0 deletions
diff --git a/services/inputflinger/reader/mapper/TouchInputMapper.cpp b/services/inputflinger/reader/mapper/TouchInputMapper.cpp
index 2770c14f81..394c9e49b5 100644
--- a/services/inputflinger/reader/mapper/TouchInputMapper.cpp
+++ b/services/inputflinger/reader/mapper/TouchInputMapper.cpp
@@ -190,6 +190,19 @@ void TouchInputMapper::populateDeviceInfo(InputDeviceInfo* info) {
info->addMotionRange(mOrientedRanges.y);
info->addMotionRange(mOrientedRanges.pressure);
+ if (mDeviceMode == DeviceMode::UNSCALED && mSource == AINPUT_SOURCE_TOUCHPAD) {
+ // Populate RELATIVE_X and RELATIVE_Y motion range for touchpad capture mode
+ // RELATIVE_X and RELATIVE_Y motion range is the largest possible hardware relative
+ // motion, e.g. the hardware size finger moved completely across the touchpad in one
+ // sample cycle.
+ const InputDeviceInfo::MotionRange& x = mOrientedRanges.x;
+ const InputDeviceInfo::MotionRange& y = mOrientedRanges.y;
+ info->addMotionRange(AMOTION_EVENT_AXIS_RELATIVE_X, mSource, -x.max, x.max, x.flat,
+ x.fuzz, x.resolution);
+ info->addMotionRange(AMOTION_EVENT_AXIS_RELATIVE_Y, mSource, -y.max, y.max, y.flat,
+ y.fuzz, y.resolution);
+ }
+
if (mOrientedRanges.haveSize) {
info->addMotionRange(mOrientedRanges.size);
}
diff --git a/services/inputflinger/tests/InputReader_test.cpp b/services/inputflinger/tests/InputReader_test.cpp
index d589a62bd2..58f83b518d 100644
--- a/services/inputflinger/tests/InputReader_test.cpp
+++ b/services/inputflinger/tests/InputReader_test.cpp
@@ -7554,6 +7554,20 @@ TEST_F(MultiTouchInputMapperTest, Process_TouchpadCapture) {
ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyDeviceResetWasCalled(&resetArgs));
ASSERT_EQ(AINPUT_SOURCE_TOUCHPAD, mapper.getSources());
+ InputDeviceInfo deviceInfo;
+ mDevice->getDeviceInfo(&deviceInfo);
+
+ const InputDeviceInfo::MotionRange* relRangeX =
+ deviceInfo.getMotionRange(AMOTION_EVENT_AXIS_RELATIVE_X, AINPUT_SOURCE_TOUCHPAD);
+ ASSERT_NE(relRangeX, nullptr);
+ ASSERT_EQ(relRangeX->min, -(RAW_X_MAX - RAW_X_MIN));
+ ASSERT_EQ(relRangeX->max, RAW_X_MAX - RAW_X_MIN);
+ const InputDeviceInfo::MotionRange* relRangeY =
+ deviceInfo.getMotionRange(AMOTION_EVENT_AXIS_RELATIVE_Y, AINPUT_SOURCE_TOUCHPAD);
+ ASSERT_NE(relRangeY, nullptr);
+ ASSERT_EQ(relRangeY->min, -(RAW_Y_MAX - RAW_Y_MIN));
+ ASSERT_EQ(relRangeY->max, RAW_Y_MAX - RAW_Y_MIN);
+
// run captured pointer tests - note that this is unscaled, so input listener events should be
// identical to what the hardware sends (accounting for any
// calibration).