Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 87feddcf authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "CapturedTouchpadEventConverter: clean up relative axes flag" into main

parents c8b689d1 2ff1d351
Loading
Loading
Loading
Loading
+0 −7
Original line number Diff line number Diff line
@@ -147,13 +147,6 @@ flag {
  bug: "310179437"
}

flag {
  name: "include_relative_axis_values_for_captured_touchpads"
  namespace: "input"
  description: "Include AXIS_RELATIVE_X and AXIS_RELATIVE_Y values when reporting touches from captured touchpads."
  bug: "330522990"
}

flag {
  name: "enable_per_device_input_latency_metrics"
  namespace: "input"
+16 −29
Original line number Diff line number Diff line
@@ -25,8 +25,6 @@
#include <linux/input-event-codes.h>
#include <log/log_main.h>

namespace input_flags = com::android::input::flags;

namespace android {

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

void CapturedTouchpadEventConverter::populateMotionRanges(InputDeviceInfo& info) const {
    if (input_flags::include_relative_axis_values_for_captured_touchpads()) {
    tryAddRawMotionRangeWithRelative(/*byref*/ info, AMOTION_EVENT_AXIS_X,
                                     AMOTION_EVENT_AXIS_RELATIVE_X, ABS_MT_POSITION_X);
    tryAddRawMotionRangeWithRelative(/*byref*/ info, AMOTION_EVENT_AXIS_Y,
                                     AMOTION_EVENT_AXIS_RELATIVE_Y, ABS_MT_POSITION_Y);
    } else {
        tryAddRawMotionRange(/*byref*/ info, AMOTION_EVENT_AXIS_X, ABS_MT_POSITION_X);
        tryAddRawMotionRange(/*byref*/ info, AMOTION_EVENT_AXIS_Y, ABS_MT_POSITION_Y);
    }
    tryAddRawMotionRange(/*byref*/ info, AMOTION_EVENT_AXIS_TOUCH_MAJOR, ABS_MT_TOUCH_MAJOR);
    tryAddRawMotionRange(/*byref*/ info, AMOTION_EVENT_AXIS_TOUCH_MINOR, ABS_MT_TOUCH_MINOR);
    tryAddRawMotionRange(/*byref*/ info, AMOTION_EVENT_AXIS_TOOL_MAJOR, ABS_MT_WIDTH_MAJOR);
@@ -213,15 +206,13 @@ std::list<NotifyArgs> CapturedTouchpadEventConverter::sync(nsecs_t when, nsecs_t
        }
        out.push_back(
                makeMotionArgs(when, readTime, AMOTION_EVENT_ACTION_MOVE, coords, properties));
        if (input_flags::include_relative_axis_values_for_captured_touchpads()) {
            // For any further events we send from this sync, the pointers won't have moved relative
            // to the positions we just reported in this MOVE event, so zero out the relative axes.
        // For any further events we send from this sync, the pointers won't have moved relative to
        // the positions we just reported in this MOVE event, so zero out the relative axes.
        for (PointerCoords& pointer : coords) {
            pointer.setAxisValue(AMOTION_EVENT_AXIS_RELATIVE_X, 0);
            pointer.setAxisValue(AMOTION_EVENT_AXIS_RELATIVE_Y, 0);
        }
    }
    }

    std::vector<size_t> upSlots, downSlots;
    for (size_t i = 0; i < mMotionAccumulator.getSlotCount(); i++) {
@@ -275,9 +266,7 @@ std::list<NotifyArgs> CapturedTouchpadEventConverter::sync(nsecs_t when, nsecs_t
                                     /*flags=*/cancel ? AMOTION_EVENT_FLAG_CANCELED : 0));

        freePointerIdForSlot(slotNumber);
        if (input_flags::include_relative_axis_values_for_captured_touchpads()) {
        mPreviousCoordsForSlotNumber.erase(slotNumber);
        }
        coords.erase(coords.begin() + indexToRemove);
        properties.erase(properties.begin() + indexToRemove);
        // Now that we've removed some coords and properties, we might have to update the slot
@@ -336,7 +325,6 @@ PointerCoords CapturedTouchpadEventConverter::makePointerCoordsForSlot(size_t sl
    coords.clear();
    coords.setAxisValue(AMOTION_EVENT_AXIS_X, slot.getX());
    coords.setAxisValue(AMOTION_EVENT_AXIS_Y, slot.getY());
    if (input_flags::include_relative_axis_values_for_captured_touchpads()) {
    if (auto it = mPreviousCoordsForSlotNumber.find(slotNumber);
        it != mPreviousCoordsForSlotNumber.end()) {
        auto [oldX, oldY] = it->second;
@@ -344,7 +332,6 @@ PointerCoords CapturedTouchpadEventConverter::makePointerCoordsForSlot(size_t sl
        coords.setAxisValue(AMOTION_EVENT_AXIS_RELATIVE_Y, slot.getY() - oldY);
    }
    mPreviousCoordsForSlotNumber[slotNumber] = std::make_pair(slot.getX(), slot.getY());
    }

    coords.setAxisValue(AMOTION_EVENT_AXIS_TOUCH_MAJOR, slot.getTouchMajor());
    coords.setAxisValue(AMOTION_EVENT_AXIS_TOUCH_MINOR, slot.getTouchMinor());
+0 −4
Original line number Diff line number Diff line
@@ -33,8 +33,6 @@
#include "TestEventMatchers.h"
#include "TestInputListener.h"

namespace input_flags = com::android::input::flags;

namespace android {

using testing::AllOf;
@@ -50,8 +48,6 @@ public:
            mReader(mFakeEventHub, mFakePolicy, mFakeListener),
            mDevice(newDevice()),
            mDeviceContext(*mDevice, EVENTHUB_ID) {
        input_flags::include_relative_axis_values_for_captured_touchpads(true);

        const size_t slotCount = 8;
        mFakeEventHub->addAbsoluteAxis(EVENTHUB_ID, ABS_MT_SLOT, 0, slotCount - 1, 0, 0, 0);
        mAccumulator.configure(mDeviceContext, slotCount, /*usingSlotsProtocol=*/true);