summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Hutterer <peter.hutterer@who-t.net>2022-05-24 11:07:37 -0700
committerPeter Hutterer <peter.hutterer@who-t.net>2022-06-01 11:20:53 +1000
commit073556d13e3937735983fb32e2704a5aaa51e435 (patch)
tree390edae2029a97c783e8157da20afa29127292b6
parent817e77f5a7502cc9258d1e41e5f2863a498d104f (diff)
downloadxf86-input-wacom-073556d13e3937735983fb32e2704a5aaa51e435.tar.gz
test: Ensure standard pen does not report the "wheel" axis
The event data has a mask field that specifies which fields are actually present (zero may be a valid value for an axis after all). Let's check that mask for each event and ensure that if the pen supports the axis, the axis is also present in the event. We still send kernel events for all axes to ensure the unsupported ones are correctly ignored by the driver. This allows us to parametrize the test with different stylus types and re-use the rest. Here we add a standard Cintiq pen and make sure the wheel axis is never set. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
-rw-r--r--test/__init__.py1
-rw-r--r--test/test_wacom.py33
2 files changed, 29 insertions, 5 deletions
diff --git a/test/__init__.py b/test/__init__.py
index 7a10f16..5f9a482 100644
--- a/test/__init__.py
+++ b/test/__init__.py
@@ -44,6 +44,7 @@ logger = logging.getLogger(__name__)
class PenId(enum.IntEnum):
ARTPEN = 0x100804
+ CINTIQ_13_PEN = 0x16802
@attr.s
diff --git a/test/test_wacom.py b/test/test_wacom.py
index f7dffd3..896d5c1 100644
--- a/test/test_wacom.py
+++ b/test/test_wacom.py
@@ -20,8 +20,12 @@ from . import Device, Monitor, Ev, Sev, Proximity, PenId
import pytest
import logging
+import gi
from gi.repository import GLib
+gi.require_version("wacom", "1.0")
+from gi.repository import wacom
+
logger = logging.getLogger(__name__)
@@ -147,7 +151,8 @@ def test_relative_motion(mainloop, opts, rotate):
@pytest.mark.parametrize("axis", ["x", "y", "pressure", "tilt_x", "tilt_y", "wheel"])
-def test_axis_updates(mainloop, opts, axis):
+@pytest.mark.parametrize("stylus_type", [PenId.ARTPEN, PenId.CINTIQ_13_PEN])
+def test_axis_updates(mainloop, opts, axis, stylus_type):
"""
Check that the various axes come through correctly
"""
@@ -175,7 +180,7 @@ def test_axis_updates(mainloop, opts, axis):
return axes[map[axis]]
ev = [
- Ev("ABS_MISC", PenId.ARTPEN),
+ Ev("ABS_MISC", stylus_type),
Ev("MSC_SERIAL", 0x123456),
Sev("ABS_X", 50 + axval("x")),
Sev("ABS_Y", 50 + axval("y")),
@@ -183,6 +188,8 @@ def test_axis_updates(mainloop, opts, axis):
# physical rotation and airbrush wheel - both share the
# same valuator. This is *not* rotation, that axis is for the
# cursor rotation only.
+ # Here we send this event even for the Cintiq Pen to ensure it
+ # gets correctly ignored by the driver
Sev("ABS_Z", 50 + axval("wheel")),
Sev("ABS_PRESSURE", 50 + axval("pressure")),
Sev("ABS_DISTANCE", 0), # Distance isn't exported
@@ -209,12 +216,28 @@ def test_axis_updates(mainloop, opts, axis):
# Ignore the proximity event since all axes change there by necessity
_ = next(events)
+ # bitflags to indicate which axis is actually present in the event
+ mask_map = {
+ "x": wacom.EventAxis.AXIS_X,
+ "y": wacom.EventAxis.AXIS_Y,
+ "pressure": wacom.EventAxis.AXIS_PRESSURE,
+ "tilt_x": wacom.EventAxis.AXIS_TILT_X,
+ "tilt_y": wacom.EventAxis.AXIS_TILT_X,
+ "wheel": wacom.EventAxis.AXIS_WHEEL,
+ }
+
first = {name: getattr(next(events).axes, name) for name in map}
for e in events:
current = {name: getattr(e.axes, name) for name in map}
for name in map:
- if name == axis:
- assert first[name] < current[name]
+ # Artpen has rotation via our 'wheel' axis but the cintiq pen does
+ # not send that axis even when the kernel sends events for it
+ pen_has_axis = name != "wheel" or stylus_type == PenId.ARTPEN
+ event_has_axis = e.axes.mask & mask_map[name] != 0
+
+ assert event_has_axis == pen_has_axis, f"for axis {name}"
+ if event_has_axis and name == axis:
+ assert first[name] < current[name], f"for axis {name}"
else:
- assert first[name] == current[name]
+ assert first[name] == current[name], f"for axis {name}"