Commit 86c315c3 authored by spang's avatar spang Committed by Commit bot

ozone: evdev: Fix ghost touches aligned with first touch

The ABS_X and ABS_Y axes are not part of the MT protocol and should
therefore not be used to update MT slot positions.

The symptom of this was secondary touches warping to the position of the
first touch in the X and/or Y axis, since ABS_X/Y always corresponds to
the first touch.

BUG=407386
TEST=chrome on pixel with --ash-touch-hud
NOTRY=true

Review URL: https://codereview.chromium.org/506303002

Cr-Commit-Position: refs/heads/master@{#292263}
parent 8e8153d4
......@@ -203,7 +203,6 @@ void TouchEventConverterEvdev::ProcessAbs(const input_event& input) {
altered_slots_.set(current_slot_);
events_[current_slot_].major_ = input.value;
break;
case ABS_X:
case ABS_MT_POSITION_X:
altered_slots_.set(current_slot_);
events_[current_slot_].x_ = TuxelsToPixels(input.value,
......@@ -212,7 +211,6 @@ void TouchEventConverterEvdev::ProcessAbs(const input_event& input) {
x_min_pixels_,
x_num_pixels_);
break;
case ABS_Y:
case ABS_MT_POSITION_Y:
altered_slots_.set(current_slot_);
events_[current_slot_].y_ = TuxelsToPixels(input.value,
......@@ -231,7 +229,6 @@ void TouchEventConverterEvdev::ProcessAbs(const input_event& input) {
}
break;
case ABS_MT_PRESSURE:
case ABS_PRESSURE:
altered_slots_.set(current_slot_);
events_[current_slot_].pressure_ = input.value - pressure_min_;
events_[current_slot_].pressure_ /= pressure_max_ - pressure_min_;
......@@ -241,7 +238,7 @@ void TouchEventConverterEvdev::ProcessAbs(const input_event& input) {
altered_slots_.set(current_slot_);
break;
default:
NOTIMPLEMENTED() << "invalid code for EV_ABS: " << input.code;
DVLOG(5) << "unhandled code for EV_ABS: " << input.code;
}
}
......
......@@ -479,3 +479,48 @@ TEST_F(TouchEventConverterEvdevTest, Unsync) {
dev->ReadNow();
EXPECT_EQ(2u, dev->size());
}
// crbug.com/407386
TEST_F(TouchEventConverterEvdevTest,
DontChangeMultitouchPositionFromLegacyAxes) {
ui::MockTouchEventConverterEvdev* dev = device();
struct input_event mock_kernel_queue[] = {
{{0, 0}, EV_ABS, ABS_MT_SLOT, 0},
{{0, 0}, EV_ABS, ABS_MT_TRACKING_ID, 100},
{{0, 0}, EV_ABS, ABS_MT_POSITION_X, 999},
{{0, 0}, EV_ABS, ABS_MT_POSITION_Y, 888},
{{0, 0}, EV_ABS, ABS_MT_PRESSURE, 55},
{{0, 0}, EV_ABS, ABS_MT_SLOT, 1},
{{0, 0}, EV_ABS, ABS_MT_TRACKING_ID, 200},
{{0, 0}, EV_ABS, ABS_MT_PRESSURE, 44},
{{0, 0}, EV_ABS, ABS_MT_POSITION_X, 777},
{{0, 0}, EV_ABS, ABS_MT_POSITION_Y, 666},
{{0, 0}, EV_ABS, ABS_X, 999},
{{0, 0}, EV_ABS, ABS_Y, 888},
{{0, 0}, EV_ABS, ABS_PRESSURE, 55},
{{0, 0}, EV_SYN, SYN_REPORT, 0},
};
// Check that two events are generated.
dev->ConfigureReadMock(mock_kernel_queue, arraysize(mock_kernel_queue), 0);
dev->ReadNow();
const unsigned int kExpectedEventCount = 2;
EXPECT_EQ(kExpectedEventCount, dev->size());
if (kExpectedEventCount != dev->size())
return;
ui::TouchEvent* ev0 = dev->event(0);
ui::TouchEvent* ev1 = dev->event(1);
EXPECT_EQ(0, ev0->touch_id());
EXPECT_EQ(999, ev0->x());
EXPECT_EQ(888, ev0->y());
EXPECT_FLOAT_EQ(0.8333333f, ev0->force());
EXPECT_EQ(1, ev1->touch_id());
EXPECT_EQ(777, ev1->x());
EXPECT_EQ(666, ev1->y());
EXPECT_FLOAT_EQ(0.4666666f, ev1->force());
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment