|
25 | 25 | #include <linux/input-event-codes.h> |
26 | 26 | #include <log/log_main.h> |
27 | 27 |
|
28 | | -namespace input_flags = com::android::input::flags; |
29 | | - |
30 | 28 | namespace android { |
31 | 29 |
|
32 | 30 | namespace { |
@@ -119,15 +117,10 @@ std::string CapturedTouchpadEventConverter::dump() const { |
119 | 117 | } |
120 | 118 |
|
121 | 119 | 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); |
131 | 124 | tryAddRawMotionRange(/*byref*/ info, AMOTION_EVENT_AXIS_TOUCH_MAJOR, ABS_MT_TOUCH_MAJOR); |
132 | 125 | tryAddRawMotionRange(/*byref*/ info, AMOTION_EVENT_AXIS_TOUCH_MINOR, ABS_MT_TOUCH_MINOR); |
133 | 126 | 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 |
213 | 206 | } |
214 | 207 | out.push_back( |
215 | 208 | 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); |
223 | 214 | } |
224 | 215 | } |
225 | 216 |
|
@@ -275,9 +266,7 @@ std::list<NotifyArgs> CapturedTouchpadEventConverter::sync(nsecs_t when, nsecs_t |
275 | 266 | /*flags=*/cancel ? AMOTION_EVENT_FLAG_CANCELED : 0)); |
276 | 267 |
|
277 | 268 | freePointerIdForSlot(slotNumber); |
278 | | - if (input_flags::include_relative_axis_values_for_captured_touchpads()) { |
279 | | - mPreviousCoordsForSlotNumber.erase(slotNumber); |
280 | | - } |
| 269 | + mPreviousCoordsForSlotNumber.erase(slotNumber); |
281 | 270 | coords.erase(coords.begin() + indexToRemove); |
282 | 271 | properties.erase(properties.begin() + indexToRemove); |
283 | 272 | // 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 |
336 | 325 | coords.clear(); |
337 | 326 | coords.setAxisValue(AMOTION_EVENT_AXIS_X, slot.getX()); |
338 | 327 | 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); |
347 | 333 | } |
| 334 | + mPreviousCoordsForSlotNumber[slotNumber] = std::make_pair(slot.getX(), slot.getY()); |
348 | 335 |
|
349 | 336 | coords.setAxisValue(AMOTION_EVENT_AXIS_TOUCH_MAJOR, slot.getTouchMajor()); |
350 | 337 | coords.setAxisValue(AMOTION_EVENT_AXIS_TOUCH_MINOR, slot.getTouchMinor()); |
|
0 commit comments