Skip to content

Commit 87feddc

Browse files
Treehugger RobotAndroid (Google) Code Review
authored andcommitted
Merge "CapturedTouchpadEventConverter: clean up relative axes flag" into main
2 parents c8b689d + 2ff1d35 commit 87feddc

3 files changed

Lines changed: 16 additions & 40 deletions

File tree

libs/input/input_flags.aconfig

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -147,13 +147,6 @@ flag {
147147
bug: "310179437"
148148
}
149149

150-
flag {
151-
name: "include_relative_axis_values_for_captured_touchpads"
152-
namespace: "input"
153-
description: "Include AXIS_RELATIVE_X and AXIS_RELATIVE_Y values when reporting touches from captured touchpads."
154-
bug: "330522990"
155-
}
156-
157150
flag {
158151
name: "enable_per_device_input_latency_metrics"
159152
namespace: "input"

services/inputflinger/reader/mapper/CapturedTouchpadEventConverter.cpp

Lines changed: 16 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@
2525
#include <linux/input-event-codes.h>
2626
#include <log/log_main.h>
2727

28-
namespace input_flags = com::android::input::flags;
29-
3028
namespace android {
3129

3230
namespace {
@@ -119,15 +117,10 @@ std::string CapturedTouchpadEventConverter::dump() const {
119117
}
120118

121119
void CapturedTouchpadEventConverter::populateMotionRanges(InputDeviceInfo& info) const {
122-
if (input_flags::include_relative_axis_values_for_captured_touchpads()) {
123-
tryAddRawMotionRangeWithRelative(/*byref*/ info, AMOTION_EVENT_AXIS_X,
124-
AMOTION_EVENT_AXIS_RELATIVE_X, ABS_MT_POSITION_X);
125-
tryAddRawMotionRangeWithRelative(/*byref*/ info, AMOTION_EVENT_AXIS_Y,
126-
AMOTION_EVENT_AXIS_RELATIVE_Y, ABS_MT_POSITION_Y);
127-
} else {
128-
tryAddRawMotionRange(/*byref*/ info, AMOTION_EVENT_AXIS_X, ABS_MT_POSITION_X);
129-
tryAddRawMotionRange(/*byref*/ info, AMOTION_EVENT_AXIS_Y, ABS_MT_POSITION_Y);
130-
}
120+
tryAddRawMotionRangeWithRelative(/*byref*/ info, AMOTION_EVENT_AXIS_X,
121+
AMOTION_EVENT_AXIS_RELATIVE_X, ABS_MT_POSITION_X);
122+
tryAddRawMotionRangeWithRelative(/*byref*/ info, AMOTION_EVENT_AXIS_Y,
123+
AMOTION_EVENT_AXIS_RELATIVE_Y, ABS_MT_POSITION_Y);
131124
tryAddRawMotionRange(/*byref*/ info, AMOTION_EVENT_AXIS_TOUCH_MAJOR, ABS_MT_TOUCH_MAJOR);
132125
tryAddRawMotionRange(/*byref*/ info, AMOTION_EVENT_AXIS_TOUCH_MINOR, ABS_MT_TOUCH_MINOR);
133126
tryAddRawMotionRange(/*byref*/ info, AMOTION_EVENT_AXIS_TOOL_MAJOR, ABS_MT_WIDTH_MAJOR);
@@ -213,13 +206,11 @@ std::list<NotifyArgs> CapturedTouchpadEventConverter::sync(nsecs_t when, nsecs_t
213206
}
214207
out.push_back(
215208
makeMotionArgs(when, readTime, AMOTION_EVENT_ACTION_MOVE, coords, properties));
216-
if (input_flags::include_relative_axis_values_for_captured_touchpads()) {
217-
// For any further events we send from this sync, the pointers won't have moved relative
218-
// to the positions we just reported in this MOVE event, so zero out the relative axes.
219-
for (PointerCoords& pointer : coords) {
220-
pointer.setAxisValue(AMOTION_EVENT_AXIS_RELATIVE_X, 0);
221-
pointer.setAxisValue(AMOTION_EVENT_AXIS_RELATIVE_Y, 0);
222-
}
209+
// For any further events we send from this sync, the pointers won't have moved relative to
210+
// the positions we just reported in this MOVE event, so zero out the relative axes.
211+
for (PointerCoords& pointer : coords) {
212+
pointer.setAxisValue(AMOTION_EVENT_AXIS_RELATIVE_X, 0);
213+
pointer.setAxisValue(AMOTION_EVENT_AXIS_RELATIVE_Y, 0);
223214
}
224215
}
225216

@@ -275,9 +266,7 @@ std::list<NotifyArgs> CapturedTouchpadEventConverter::sync(nsecs_t when, nsecs_t
275266
/*flags=*/cancel ? AMOTION_EVENT_FLAG_CANCELED : 0));
276267

277268
freePointerIdForSlot(slotNumber);
278-
if (input_flags::include_relative_axis_values_for_captured_touchpads()) {
279-
mPreviousCoordsForSlotNumber.erase(slotNumber);
280-
}
269+
mPreviousCoordsForSlotNumber.erase(slotNumber);
281270
coords.erase(coords.begin() + indexToRemove);
282271
properties.erase(properties.begin() + indexToRemove);
283272
// Now that we've removed some coords and properties, we might have to update the slot
@@ -336,15 +325,13 @@ PointerCoords CapturedTouchpadEventConverter::makePointerCoordsForSlot(size_t sl
336325
coords.clear();
337326
coords.setAxisValue(AMOTION_EVENT_AXIS_X, slot.getX());
338327
coords.setAxisValue(AMOTION_EVENT_AXIS_Y, slot.getY());
339-
if (input_flags::include_relative_axis_values_for_captured_touchpads()) {
340-
if (auto it = mPreviousCoordsForSlotNumber.find(slotNumber);
341-
it != mPreviousCoordsForSlotNumber.end()) {
342-
auto [oldX, oldY] = it->second;
343-
coords.setAxisValue(AMOTION_EVENT_AXIS_RELATIVE_X, slot.getX() - oldX);
344-
coords.setAxisValue(AMOTION_EVENT_AXIS_RELATIVE_Y, slot.getY() - oldY);
345-
}
346-
mPreviousCoordsForSlotNumber[slotNumber] = std::make_pair(slot.getX(), slot.getY());
328+
if (auto it = mPreviousCoordsForSlotNumber.find(slotNumber);
329+
it != mPreviousCoordsForSlotNumber.end()) {
330+
auto [oldX, oldY] = it->second;
331+
coords.setAxisValue(AMOTION_EVENT_AXIS_RELATIVE_X, slot.getX() - oldX);
332+
coords.setAxisValue(AMOTION_EVENT_AXIS_RELATIVE_Y, slot.getY() - oldY);
347333
}
334+
mPreviousCoordsForSlotNumber[slotNumber] = std::make_pair(slot.getX(), slot.getY());
348335

349336
coords.setAxisValue(AMOTION_EVENT_AXIS_TOUCH_MAJOR, slot.getTouchMajor());
350337
coords.setAxisValue(AMOTION_EVENT_AXIS_TOUCH_MINOR, slot.getTouchMinor());

services/inputflinger/tests/CapturedTouchpadEventConverter_test.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,6 @@
3333
#include "TestEventMatchers.h"
3434
#include "TestInputListener.h"
3535

36-
namespace input_flags = com::android::input::flags;
37-
3836
namespace android {
3937

4038
using testing::AllOf;
@@ -50,8 +48,6 @@ class CapturedTouchpadEventConverterTest : public testing::Test {
5048
mReader(mFakeEventHub, mFakePolicy, mFakeListener),
5149
mDevice(newDevice()),
5250
mDeviceContext(*mDevice, EVENTHUB_ID) {
53-
input_flags::include_relative_axis_values_for_captured_touchpads(true);
54-
5551
const size_t slotCount = 8;
5652
mFakeEventHub->addAbsoluteAxis(EVENTHUB_ID, ABS_MT_SLOT, 0, slotCount - 1, 0, 0, 0);
5753
mAccumulator.configure(mDeviceContext, slotCount, /*usingSlotsProtocol=*/true);

0 commit comments

Comments
 (0)