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

Commit 54baf1ab authored by Harry Cutts's avatar Harry Cutts Committed by Automerger Merge Worker
Browse files

Merge "Fix touchpad palm filtering logic" into udc-dev am: 49075cc3

parents 1e89bb4c 49075cc3
Loading
Loading
Loading
Loading
+6 −14
Original line number Diff line number Diff line
@@ -14,6 +14,9 @@
 * limitations under the License.
 */

// clang-format off
#include "../Macros.h"
// clang-format on
#include "gestures/HardwareStateConverter.h"

#include <chrono>
@@ -80,14 +83,9 @@ SelfContainedHardwareState HardwareStateConverter::produceHardwareState(nsecs_t
    schs.fingers.clear();
    for (size_t i = 0; i < mMotionAccumulator.getSlotCount(); i++) {
        MultiTouchMotionAccumulator::Slot slot = mMotionAccumulator.getSlot(i);
        if (!slot.isInUse()) {
            continue;
        }
        // Some touchpads continue to report contacts even after they've identified them as palms.
        // We want to exclude these contacts from the HardwareStates, but still need to report a
        // tracking ID of -1 if a finger turns into a palm.
        const bool isPalm = slot.getToolType() == AMOTION_EVENT_TOOL_TYPE_PALM;
        if (isPalm && mFingerSlots.find(i) == mFingerSlots.end()) {
        // We want to exclude these contacts from the HardwareStates.
        if (!slot.isInUse() || slot.getToolType() == AMOTION_EVENT_TOOL_TYPE_PALM) {
            continue;
        }

@@ -101,12 +99,7 @@ SelfContainedHardwareState HardwareStateConverter::produceHardwareState(nsecs_t
        fingerState.orientation = slot.getOrientation();
        fingerState.position_x = slot.getX();
        fingerState.position_y = slot.getY();
        fingerState.tracking_id = isPalm ? -1 : slot.getTrackingId();
        if (fingerState.tracking_id == -1) {
            mFingerSlots.erase(i);
        } else {
            mFingerSlots.insert(i);
        }
        fingerState.tracking_id = slot.getTrackingId();
    }
    schs.state.fingers = schs.fingers.data();
    schs.state.finger_cnt = schs.fingers.size();
@@ -117,7 +110,6 @@ SelfContainedHardwareState HardwareStateConverter::produceHardwareState(nsecs_t
void HardwareStateConverter::reset() {
    mCursorButtonAccumulator.reset(mDeviceContext);
    mTouchButtonAccumulator.reset();
    mFingerSlots.clear();
    mMscTimestamp = 0;
}

+0 −1
Original line number Diff line number Diff line
@@ -54,7 +54,6 @@ private:
    MultiTouchMotionAccumulator mMotionAccumulator;
    TouchButtonAccumulator mTouchButtonAccumulator;
    int32_t mMscTimestamp = 0;
    std::set<size_t> mFingerSlots;
};

} // namespace android
+1 −2
Original line number Diff line number Diff line
@@ -231,8 +231,7 @@ TEST_F(HardwareStateConverterTest, OneFingerTurningIntoAPalm) {

    schs = processSync(conv, time);
    ASSERT_TRUE(schs.has_value());
    ASSERT_EQ(1, schs->state.finger_cnt);
    EXPECT_EQ(-1, schs->state.fingers[0].tracking_id);
    ASSERT_EQ(0, schs->state.finger_cnt);

    processAxis(conv, time, EV_ABS, ABS_MT_POSITION_X, 53);
    processAxis(conv, time, EV_ABS, ABS_MT_POSITION_Y, 97);