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

Commit 1db43995 authored by Harry Cutts's avatar Harry Cutts
Browse files

TouchInputMapper: don't check touchpad touches by screen bounds

Uncaptured touchpads (with DeviceMode::POINTER) still on the old stack
(i.e. the Sony DualShock 4 touchpad) were having touches ignored if they
started at coordinates that would be outside of the bounds of the
touchscreen. Since touchpads use relative motions and don't directly
relate raw touch locations to screen locations, this was incorrect, and
caused touches to be ignored with certain screen/touchpad dimension and
orientation combinations.

Bug: 280396539
Test: connect Sony DualShock 4 by USB, rotate screen to portrait, check
      touches starting in all areas of the pad are turned into pointer
      movements
Test: atest inputflinger_tests
Change-Id: I9a92ba79246ee8fc25418c2e248ae2c3839a0d58
parent 90721097
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -1889,9 +1889,9 @@ std::list<NotifyArgs> TouchInputMapper::consumeRawTouches(nsecs_t when, nsecs_t
        uint32_t id = mCurrentRawState.rawPointerData.touchingIdBits.firstMarkedBit();
        const RawPointerData::Pointer& pointer = mCurrentRawState.rawPointerData.pointerForId(id);
        // Skip checking whether the pointer is inside the physical frame if the device is in
        // unscaled mode.
        // unscaled or pointer mode.
        if (!isPointInsidePhysicalFrame(pointer.x, pointer.y) &&
            mDeviceMode != DeviceMode::UNSCALED) {
            mDeviceMode != DeviceMode::UNSCALED && mDeviceMode != DeviceMode::POINTER) {
            // If exactly one pointer went down, check for virtual key hit.
            // Otherwise, we will drop the entire stroke.
            if (mCurrentRawState.rawPointerData.touchingIdBits.count() == 1) {
+34 −0
Original line number Diff line number Diff line
@@ -5903,6 +5903,40 @@ TEST_F(SingleTouchInputMapperTest, Process_IgnoresTouchesOutsidePhysicalFrame) {
            mFakeListener->assertNotifyMotionWasCalled(WithMotionAction(AMOTION_EVENT_ACTION_UP)));
}
TEST_F(SingleTouchInputMapperTest, Process_DoesntCheckPhysicalFrameForTouchpads) {
    std::shared_ptr<FakePointerController> fakePointerController =
            std::make_shared<FakePointerController>();
    mFakePolicy->setPointerController(fakePointerController);
    addConfigurationProperty("touch.deviceType", "pointer");
    prepareAxes(POSITION);
    prepareDisplay(ui::ROTATION_0);
    auto& mapper = constructAndAddMapper<SingleTouchInputMapper>();
    // Set a physical frame in the display viewport.
    auto viewport = mFakePolicy->getDisplayViewportByType(ViewportType::INTERNAL);
    viewport->physicalLeft = 20;
    viewport->physicalTop = 600;
    viewport->physicalRight = 30;
    viewport->physicalBottom = 610;
    mFakePolicy->updateViewport(*viewport);
    configureDevice(InputReaderConfiguration::Change::DISPLAY_INFO);
    // Start the touch.
    process(mapper, ARBITRARY_TIME, READ_TIME, EV_KEY, BTN_TOUCH, 1);
    processSync(mapper);
    // Expect all input starting outside the physical frame to result in NotifyMotionArgs being
    // produced.
    const std::array<Point, 6> outsidePoints = {
            {{0, 0}, {19, 605}, {31, 605}, {25, 599}, {25, 611}, {DISPLAY_WIDTH, DISPLAY_HEIGHT}}};
    for (const auto& p : outsidePoints) {
        processMove(mapper, toRawX(p.x), toRawY(p.y));
        processSync(mapper);
        EXPECT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled());
    }
}
TEST_F(SingleTouchInputMapperTest, Process_AllAxes_DefaultCalibration) {
    addConfigurationProperty("touch.deviceType", "touchScreen");
    prepareDisplay(ui::ROTATION_0);