Commit c018b4bc authored by Mathew King's avatar Mathew King Committed by Commit Bot

touch: Ignore tool events if another is active

On the Drallion stylus when the errse button is pressed the digitizer
will send an BTN_TOOL_RUBBER event before a BTN_TOUCH event and then a
BTN_TOOL_PEN. This sequence should be considered an POINTER_TYPE_ERASER
and not a POINTER_TYPE_PEN.

Bug: b:139781900
Change-Id: I268ef0d72e25fa374832ed529a4b54559bc0f805
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2076530Reviewed-by: default avatarSean O'Brien <seobrien@chromium.org>
Commit-Queue: Mathew King <mathewk@chromium.org>
Cr-Commit-Position: refs/heads/master@{#746660}
parent 5ad0f909
......@@ -995,6 +995,39 @@ const DeviceCapabilities kXboxElite = {
base::size(kXboxEliteAxes),
};
const DeviceAbsoluteAxis kDrallionStylusAxes[] = {
{ABS_X, {0, 0, 30931, 0, 0, 100}},
{ABS_Y, {0, 0, 17399, 0, 0, 100}},
{ABS_PRESSURE, {0, 0, 4095, 0, 0, 0}},
{ABS_TILT_X, {0, -90, 90, 0, 0, 57}},
{ABS_TILT_Y, {0, -90, 90, 0, 0, 57}},
{ABS_MISC, {0, 0, 65535, 0, 0, 0}},
};
const DeviceCapabilities kDrallionStylus = {
/* path */
"/sys/devices/pci0000:00/0000:00:15.0/i2c_designware.0/i2c-7/"
"i2c-WCOM48E2:00/0018:2D1F:4971.0001/input/input6/event5",
/* name */ "WCOM48E2:00 2D1F:4971 Pen",
/* phys */ "i2c-WCOM48E2:00",
/* uniq */ "",
/* bustype */ "0018",
/* vendor */ "2d1f",
/* product */ "4971",
/* version */ "0100",
/* prop */ "0",
/* ev */ "1b",
/* key */ "1c03 0 0 0 0 0",
/* rel */ "0",
/* abs */ "1000d000003",
/* msc */ "11",
/* sw */ "0",
/* led */ "0",
/* ff */ "0",
kDrallionStylusAxes,
base::size(kDrallionStylusAxes),
};
// NB: Please use the capture_device_capabilities.py script to add more
// test data here. This will help ensure the data matches what the kernel
// reports for a real device and is entered correctly.
......
......@@ -88,6 +88,7 @@ extern const DeviceCapabilities kNocturneStylus;
extern const DeviceCapabilities kKohakuTouchscreen;
extern const DeviceCapabilities kKohakuStylus;
extern const DeviceCapabilities kXboxElite;
extern const DeviceCapabilities kDrallionStylus;
} // namspace ui
#endif // UI_EVENTS_OZONE_EVDEV_EVENT_DEVICE_TEST_UTIL_H_
......@@ -364,8 +364,12 @@ void TouchEventConverterEvdev::ProcessKey(const input_event& input) {
case BTN_TOOL_PEN:
case BTN_TOOL_RUBBER:
if (input.value > 0) {
if (events_[current_slot_].tool_code != 0)
break;
events_[current_slot_].tool_code = input.code;
} else {
if (events_[current_slot_].tool_code != input.code)
break;
events_[current_slot_].tool_code = 0;
}
events_[current_slot_].altered = true;
......
......@@ -1624,6 +1624,55 @@ TEST_F(TouchEventConverterEvdevTest, ActiveStylusMotion) {
EXPECT_EQ(0.f / 1024, event.pointer_details.force);
}
TEST_F(TouchEventConverterEvdevTest, ActiveStylusDrallionRubberSequence) {
ui::MockTouchEventConverterEvdev* dev = device();
EventDeviceInfo devinfo;
EXPECT_TRUE(CapabilitiesToDeviceInfo(kDrallionStylus, &devinfo));
dev->Initialize(devinfo);
struct input_event mock_kernel_queue[] = {
{{0, 0}, EV_KEY, BTN_TOOL_RUBBER, 1},
{{0, 0}, EV_KEY, BTN_TOUCH, 1},
{{0, 0}, EV_KEY, BTN_TOOL_PEN, 1},
{{0, 0}, EV_SYN, SYN_REPORT, 0},
{{0, 0}, EV_ABS, ABS_X, 4008},
{{0, 0}, EV_ABS, ABS_Y, 11247},
{{0, 0}, EV_SYN, SYN_REPORT, 0},
{{0, 0}, EV_ABS, ABS_X, 4004},
{{0, 0}, EV_ABS, ABS_Y, 11248},
{{0, 0}, EV_SYN, SYN_REPORT, 0},
{{0, 0}, EV_KEY, BTN_TOUCH, 0},
{{0, 0}, EV_KEY, BTN_TOOL_PEN, 0},
{{0, 0}, EV_KEY, BTN_TOOL_RUBBER, 0},
{{0, 0}, EV_SYN, SYN_REPORT, 0},
};
dev->ConfigureReadMock(mock_kernel_queue, base::size(mock_kernel_queue), 0);
dev->ReadNow();
EXPECT_EQ(4u, size());
ui::TouchEventParams event = dispatched_touch_event(0);
EXPECT_EQ(ET_TOUCH_PRESSED, event.type);
EXPECT_EQ(EventPointerType::POINTER_TYPE_ERASER,
event.pointer_details.pointer_type);
event = dispatched_touch_event(1);
EXPECT_EQ(ET_TOUCH_MOVED, event.type);
EXPECT_EQ(EventPointerType::POINTER_TYPE_ERASER,
event.pointer_details.pointer_type);
event = dispatched_touch_event(2);
EXPECT_EQ(ET_TOUCH_MOVED, event.type);
EXPECT_EQ(EventPointerType::POINTER_TYPE_ERASER,
event.pointer_details.pointer_type);
event = dispatched_touch_event(3);
EXPECT_EQ(ET_TOUCH_RELEASED, event.type);
EXPECT_EQ(EventPointerType::POINTER_TYPE_ERASER,
event.pointer_details.pointer_type);
}
TEST_F(TouchEventConverterEvdevTest, ActiveStylusBarrelButtonWhileHovering) {
ui::MockTouchEventConverterEvdev* dev = device();
EventDeviceInfo devinfo;
......
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