Skip to content

Commit

Permalink
ozone: evdev: Fix ghost touches aligned with first touch
Browse files Browse the repository at this point in the history
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}
  • Loading branch information
mspang authored and Commit bot committed Aug 27, 2014
1 parent 8e8153d commit 86c315c
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 4 deletions.
5 changes: 1 addition & 4 deletions ui/events/ozone/evdev/touch_event_converter_evdev.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -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_;
Expand All @@ -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;
}
}

Expand Down
45 changes: 45 additions & 0 deletions ui/events/ozone/evdev/touch_event_converter_evdev_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}

0 comments on commit 86c315c

Please sign in to comment.