summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Harry Cutts <hcutts@google.com> 2023-01-13 17:21:00 +0000
committer Harry Cutts <hcutts@google.com> 2023-01-26 14:59:54 +0000
commita546ba8dfb64ef493c06dae1402fb02b024f8262 (patch)
tree892109ed4cd1c069f8b9960ab401538e3243d085
parent3ea5e0d27f8f2001eb4e1740c455135fe6aa6aec (diff)
Add plumbing from settings to gesture properties
Because we don't have the Android curve parameters yet (or the code to put them into the custom curve gesture properties), the fifteen different speed settings get mapped onto the five ChromeOS curves built-in to the gestures library Bug: 251196347, 247080509, 265798483 Test: Use settings command in ADB shell to change values Change-Id: I414d6e63c56d8e42c5848ca4aa150510956c70e3
-rw-r--r--services/inputflinger/InputReaderBase.cpp3
-rw-r--r--services/inputflinger/include/InputReaderBase.h23
-rw-r--r--services/inputflinger/reader/mapper/TouchpadInputMapper.cpp12
-rw-r--r--services/inputflinger/reader/mapper/gestures/GestureConverter.cpp8
-rw-r--r--services/inputflinger/tests/GestureConverter_test.cpp12
5 files changed, 47 insertions, 11 deletions
diff --git a/services/inputflinger/InputReaderBase.cpp b/services/inputflinger/InputReaderBase.cpp
index a864cf8202..2450235ec1 100644
--- a/services/inputflinger/InputReaderBase.cpp
+++ b/services/inputflinger/InputReaderBase.cpp
@@ -73,6 +73,9 @@ std::string InputReaderConfiguration::changesToString(uint32_t changes) {
if (changes & CHANGE_ENABLED_STATE) {
result += "ENABLED_STATE | ";
}
+ if (changes & CHANGE_TOUCHPAD_SETTINGS) {
+ result += "TOUCHPAD_SETTINGS | ";
+ }
if (changes & CHANGE_MUST_REOPEN) {
result += "MUST_REOPEN | ";
}
diff --git a/services/inputflinger/include/InputReaderBase.h b/services/inputflinger/include/InputReaderBase.h
index d55ab28ff6..2173117fed 100644
--- a/services/inputflinger/include/InputReaderBase.h
+++ b/services/inputflinger/include/InputReaderBase.h
@@ -161,7 +161,7 @@ public:
struct InputReaderConfiguration {
// Describes changes that have occurred.
enum {
- // The pointer speed changed.
+ // The mouse pointer speed changed.
CHANGE_POINTER_SPEED = 1 << 0,
// The pointer gesture control changed.
@@ -200,6 +200,9 @@ struct InputReaderConfiguration {
// The stylus button reporting configurations has changed.
CHANGE_STYLUS_BUTTON_REPORTING = 1 << 12,
+ // The touchpad settings changed.
+ CHANGE_TOUCHPAD_SETTINGS = 1 << 13,
+
// All devices must be reopened.
CHANGE_MUST_REOPEN = 1 << 31,
};
@@ -309,6 +312,20 @@ struct InputReaderConfiguration {
// The latest request to enable or disable Pointer Capture.
PointerCaptureRequest pointerCaptureRequest;
+ // The touchpad pointer speed, as a number from -7 (slowest) to 7 (fastest).
+ int32_t touchpadPointerSpeed;
+
+ // True to invert the touchpad scrolling direction, so that moving two fingers downwards on the
+ // touchpad scrolls the content upwards.
+ bool touchpadNaturalScrollingEnabled;
+
+ // True to enable tap-to-click on touchpads.
+ bool touchpadTapToClickEnabled;
+
+ // True to enable a zone on the right-hand side of touchpads where clicks will be turned into
+ // context (a.k.a. "right") clicks.
+ bool touchpadRightClickZoneEnabled;
+
// The set of currently disabled input devices.
std::set<int32_t> disabledDevices;
@@ -337,6 +354,10 @@ struct InputReaderConfiguration {
pointerGestureZoomSpeedRatio(0.3f),
showTouches(false),
pointerCaptureRequest(),
+ touchpadPointerSpeed(0),
+ touchpadNaturalScrollingEnabled(true),
+ touchpadTapToClickEnabled(true),
+ touchpadRightClickZoneEnabled(false),
stylusButtonMotionEventsEnabled(true) {}
static std::string changesToString(uint32_t changes);
diff --git a/services/inputflinger/reader/mapper/TouchpadInputMapper.cpp b/services/inputflinger/reader/mapper/TouchpadInputMapper.cpp
index b6313a1049..9f32311e14 100644
--- a/services/inputflinger/reader/mapper/TouchpadInputMapper.cpp
+++ b/services/inputflinger/reader/mapper/TouchpadInputMapper.cpp
@@ -146,6 +146,18 @@ std::list<NotifyArgs> TouchpadInputMapper::configure(nsecs_t when,
}
mGestureConverter.setOrientation(orientation);
}
+ if (!changes || (changes & InputReaderConfiguration::CHANGE_TOUCHPAD_SETTINGS)) {
+ // TODO(b/265798483): load an Android-specific acceleration curve instead of mapping to one
+ // of five ChromeOS curves.
+ const int pointerSensitivity = (config->touchpadPointerSpeed + 7) / 3 + 1;
+ mPropertyProvider.getProperty("Pointer Sensitivity").setIntValues({pointerSensitivity});
+ mPropertyProvider.getProperty("Invert Scrolling")
+ .setBoolValues({config->touchpadNaturalScrollingEnabled});
+ mPropertyProvider.getProperty("Tap Enable")
+ .setBoolValues({config->touchpadTapToClickEnabled});
+ mPropertyProvider.getProperty("Button Right Click Zone Enable")
+ .setBoolValues({config->touchpadRightClickZoneEnabled});
+ }
return {};
}
diff --git a/services/inputflinger/reader/mapper/gestures/GestureConverter.cpp b/services/inputflinger/reader/mapper/gestures/GestureConverter.cpp
index 561b1f819a..d636d4458f 100644
--- a/services/inputflinger/reader/mapper/gestures/GestureConverter.cpp
+++ b/services/inputflinger/reader/mapper/gestures/GestureConverter.cpp
@@ -219,11 +219,11 @@ std::list<NotifyArgs> GestureConverter::handleScroll(nsecs_t when, nsecs_t readT
float deltaY = gesture.details.scroll.dy;
rotateDelta(mOrientation, &deltaX, &deltaY);
- coords.setAxisValue(AMOTION_EVENT_AXIS_X, coords.getAxisValue(AMOTION_EVENT_AXIS_X) - deltaX);
- coords.setAxisValue(AMOTION_EVENT_AXIS_Y, coords.getAxisValue(AMOTION_EVENT_AXIS_Y) - deltaY);
+ coords.setAxisValue(AMOTION_EVENT_AXIS_X, coords.getAxisValue(AMOTION_EVENT_AXIS_X) + deltaX);
+ coords.setAxisValue(AMOTION_EVENT_AXIS_Y, coords.getAxisValue(AMOTION_EVENT_AXIS_Y) + deltaY);
// TODO(b/262876643): set AXIS_GESTURE_{X,Y}_OFFSET.
- coords.setAxisValue(AMOTION_EVENT_AXIS_GESTURE_SCROLL_X_DISTANCE, gesture.details.scroll.dx);
- coords.setAxisValue(AMOTION_EVENT_AXIS_GESTURE_SCROLL_Y_DISTANCE, gesture.details.scroll.dy);
+ coords.setAxisValue(AMOTION_EVENT_AXIS_GESTURE_SCROLL_X_DISTANCE, -gesture.details.scroll.dx);
+ coords.setAxisValue(AMOTION_EVENT_AXIS_GESTURE_SCROLL_Y_DISTANCE, -gesture.details.scroll.dy);
out.push_back(makeMotionArgs(when, readTime, AMOTION_EVENT_ACTION_MOVE, /* actionButton= */ 0,
mButtonState, /* pointerCount= */ 1, mFingerProps.data(),
mFakeFingerCoords.data(), xCursorPosition, yCursorPosition));
diff --git a/services/inputflinger/tests/GestureConverter_test.cpp b/services/inputflinger/tests/GestureConverter_test.cpp
index 36a39bb2c6..9c624ba560 100644
--- a/services/inputflinger/tests/GestureConverter_test.cpp
+++ b/services/inputflinger/tests/GestureConverter_test.cpp
@@ -244,7 +244,7 @@ TEST_F(GestureConverterTest, Scroll) {
InputDeviceContext deviceContext(*mDevice, EVENTHUB_ID);
GestureConverter converter(*mReader->getContext(), deviceContext, DEVICE_ID);
- Gesture startGesture(kGestureScroll, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, 0, 10);
+ Gesture startGesture(kGestureScroll, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, 0, -10);
std::list<NotifyArgs> args = converter.handleGesture(downTime, READ_TIME, startGesture);
ASSERT_EQ(2u, args.size());
@@ -261,7 +261,7 @@ TEST_F(GestureConverterTest, Scroll) {
WithMotionClassification(MotionClassification::TWO_FINGER_SWIPE),
WithToolType(AMOTION_EVENT_TOOL_TYPE_FINGER)));
- Gesture continueGesture(kGestureScroll, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, 0, 5);
+ Gesture continueGesture(kGestureScroll, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, 0, -5);
args = converter.handleGesture(ARBITRARY_TIME, READ_TIME, continueGesture);
ASSERT_EQ(1u, args.size());
ASSERT_THAT(std::get<NotifyMotionArgs>(args.front()),
@@ -289,7 +289,7 @@ TEST_F(GestureConverterTest, Scroll_Rotated) {
GestureConverter converter(*mReader->getContext(), deviceContext, DEVICE_ID);
converter.setOrientation(ui::ROTATION_90);
- Gesture startGesture(kGestureScroll, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, 0, 10);
+ Gesture startGesture(kGestureScroll, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, 0, -10);
std::list<NotifyArgs> args = converter.handleGesture(downTime, READ_TIME, startGesture);
ASSERT_EQ(2u, args.size());
@@ -306,7 +306,7 @@ TEST_F(GestureConverterTest, Scroll_Rotated) {
WithMotionClassification(MotionClassification::TWO_FINGER_SWIPE),
WithToolType(AMOTION_EVENT_TOOL_TYPE_FINGER)));
- Gesture continueGesture(kGestureScroll, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, 0, 5);
+ Gesture continueGesture(kGestureScroll, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, 0, -5);
args = converter.handleGesture(ARBITRARY_TIME, READ_TIME, continueGesture);
ASSERT_EQ(1u, args.size());
ASSERT_THAT(std::get<NotifyMotionArgs>(args.front()),
@@ -332,10 +332,10 @@ TEST_F(GestureConverterTest, Scroll_ClearsClassificationAndOffsetsAfterGesture)
InputDeviceContext deviceContext(*mDevice, EVENTHUB_ID);
GestureConverter converter(*mReader->getContext(), deviceContext, DEVICE_ID);
- Gesture startGesture(kGestureScroll, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, 0, 10);
+ Gesture startGesture(kGestureScroll, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, 0, -10);
std::list<NotifyArgs> args = converter.handleGesture(ARBITRARY_TIME, READ_TIME, startGesture);
- Gesture continueGesture(kGestureScroll, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, 0, 5);
+ Gesture continueGesture(kGestureScroll, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, 0, -5);
args = converter.handleGesture(ARBITRARY_TIME, READ_TIME, continueGesture);
Gesture flingGesture(kGestureFling, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, 1, 1,