Loading services/inputflinger/reader/mapper/gestures/HardwareStateConverter.cpp +6 −14 Original line number Diff line number Diff line Loading @@ -14,6 +14,9 @@ * limitations under the License. */ // clang-format off #include "../Macros.h" // clang-format on #include "gestures/HardwareStateConverter.h" #include <chrono> Loading Loading @@ -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; } Loading @@ -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(); Loading @@ -117,7 +110,6 @@ SelfContainedHardwareState HardwareStateConverter::produceHardwareState(nsecs_t void HardwareStateConverter::reset() { mCursorButtonAccumulator.reset(mDeviceContext); mTouchButtonAccumulator.reset(); mFingerSlots.clear(); mMscTimestamp = 0; } Loading services/inputflinger/reader/mapper/gestures/HardwareStateConverter.h +0 −1 Original line number Diff line number Diff line Loading @@ -54,7 +54,6 @@ private: MultiTouchMotionAccumulator mMotionAccumulator; TouchButtonAccumulator mTouchButtonAccumulator; int32_t mMscTimestamp = 0; std::set<size_t> mFingerSlots; }; } // namespace android services/inputflinger/tests/HardwareStateConverter_test.cpp +1 −2 Original line number Diff line number Diff line Loading @@ -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); Loading Loading
services/inputflinger/reader/mapper/gestures/HardwareStateConverter.cpp +6 −14 Original line number Diff line number Diff line Loading @@ -14,6 +14,9 @@ * limitations under the License. */ // clang-format off #include "../Macros.h" // clang-format on #include "gestures/HardwareStateConverter.h" #include <chrono> Loading Loading @@ -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; } Loading @@ -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(); Loading @@ -117,7 +110,6 @@ SelfContainedHardwareState HardwareStateConverter::produceHardwareState(nsecs_t void HardwareStateConverter::reset() { mCursorButtonAccumulator.reset(mDeviceContext); mTouchButtonAccumulator.reset(); mFingerSlots.clear(); mMscTimestamp = 0; } Loading
services/inputflinger/reader/mapper/gestures/HardwareStateConverter.h +0 −1 Original line number Diff line number Diff line Loading @@ -54,7 +54,6 @@ private: MultiTouchMotionAccumulator mMotionAccumulator; TouchButtonAccumulator mTouchButtonAccumulator; int32_t mMscTimestamp = 0; std::set<size_t> mFingerSlots; }; } // namespace android
services/inputflinger/tests/HardwareStateConverter_test.cpp +1 −2 Original line number Diff line number Diff line Loading @@ -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); Loading