diff options
author | Peter Hutterer <peter.hutterer@who-t.net> | 2022-06-10 21:00:26 +1000 |
---|---|---|
committer | Peter Hutterer <peter.hutterer@who-t.net> | 2022-06-13 11:11:54 +1000 |
commit | 0dc0b101bf49731cdb7946835bd3bd2045d036d8 (patch) | |
tree | 1e3fd1e098551264f3f201ef0987a549680145d0 /test | |
parent | be3471293363b518eb07a1eb041fb3e548de1bef (diff) | |
download | xf86-input-wacom-0dc0b101bf49731cdb7946835bd3bd2045d036d8.tar.gz |
test: add a test for the artpen/airbrush wheel updates
This was slightly too complicated to add to the existing
test_axis_updates test, so that test is duplicated here, only testing
what we see as "wheel" axis in the driver.
The test is run for all three pens
Because the X driver unconditionally sets ds->abswheel from the kernel
events, we must take care only to send the kernel axis that matters for
our current tool - otherwise we overwrite ds->abswheel with whichever
one of ABS_Z or ABS_WHEEL is sent last in the evdev frame.
In other words, we cannot test that artpen ignores ABS_WHEEL and
airbrush ignores ABS_Z because ... they don't.
For the generic pen that doesn't matter since we're supposed to ignore
both axes anyway.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Ping Cheng <ping.cheng@wacom.com>
Tested-by: Ping Cheng <ping.cheng@wacom.com>
Diffstat (limited to 'test')
-rw-r--r-- | test/__init__.py | 1 | ||||
-rw-r--r-- | test/test_wacom.py | 84 |
2 files changed, 85 insertions, 0 deletions
diff --git a/test/__init__.py b/test/__init__.py index 83eb38c..92eddad 100644 --- a/test/__init__.py +++ b/test/__init__.py @@ -53,6 +53,7 @@ logger = logging.getLogger(__name__) class PenId(enum.IntEnum): ARTPEN = 0x100804 CINTIQ_13_PEN = 0x16802 + AIRBRUSH = 0x100902 @attr.s diff --git a/test/test_wacom.py b/test/test_wacom.py index a484f2a..26a01aa 100644 --- a/test/test_wacom.py +++ b/test/test_wacom.py @@ -243,4 +243,88 @@ def test_axis_updates(mainloop, opts, axis, stylus_type): assert first[name] == current[name], f"for axis {name}" +@pytest.mark.parametrize( + "stylus_type", [PenId.ARTPEN, PenId.CINTIQ_13_PEN, PenId.AIRBRUSH] +) +def test_axis_updates_wheel(mainloop, opts, stylus_type): + """ + Same as the above test but tests the wheel axis only, since that one is + multiplexed through a single valuator. + """ + dev = Device.from_name("PTH660", "Pen") + monitor = Monitor.new_from_device(dev, opts) + + # Send a bunch of events with only one the wheel axis changing, the rest + # remains at the device's logical center + for i in range(0, 30, 2): + extra_events = [] + + # FIXME: there's a bug in the driver - because *both* ABS_Z (artpen) + # and ABS_WHEEL (airbrush) unconditionally update ds->abswheel + # regardless of the tool currently in prox, we must not send the + # respective "other" axis for the current tool. Exception is the + # default pen which is supposed to ignore both ABS_Z and ABS_WHEEL. + + # ABS_WHEEL sets ds->abswheel in the driver which is used for airbrush + # physical wheel - both artpen and airbrush share the same valuator. + # This is *not* the wheel for touchring. That axis is for the pad. + if stylus_type != PenId.ARTPEN: + extra_events.append(Sev("ABS_WHEEL", 50 + i)) + + # ABS_Z sets ds->abswheel in the driver which is used for artpen + # physical rotation - artpen shares the same valuator with airbrush. + # This is *not* rotation. That axis is for the cursor rotation only. + if stylus_type != PenId.AIRBRUSH: + extra_events.append(Sev("ABS_Z", 50 + i)) + + ev = [ + Ev("ABS_MISC", stylus_type), + Ev("MSC_SERIAL", 0x123456), + Sev("ABS_X", 50), + Sev("ABS_Y", 50), + # expands to ABS_Z, ABS_WHEEL or both + *extra_events, + Sev("ABS_PRESSURE", 50), + Sev("ABS_DISTANCE", 0), # Distance isn't exported + Sev("ABS_TILT_X", 50), + Sev("ABS_TILT_Y", 50), + Sev("BTN_TOOL_PEN", 1), + Sev("SYN_REPORT", 0), + ] + + monitor.write_events(ev) + + mainloop.run() + logger.debug(f"We have {len(monitor.events)} events") + + # Force a prox-out so we don't get stuck buttons. We don't call + # mainloop.run() because we don't want to collect the prox out. + ev = [ + Sev("BTN_TOOL_PEN", 0), + Sev("SYN_REPORT", 0), + ] + monitor.write_events(ev) + + events = iter(monitor.events) + # Ignore the proximity event since all axes change there by necessity + _ = next(events) + + first = next(events).axes + first_wheel = first.wheel + + for e in events: + current = e.axes + current_wheel = current.wheel + + # The default pen doesn't have the axis, artpen and airbrush have it + # and we sent events for it, so expect it to be present + pen_has_axis = stylus_type in [PenId.ARTPEN, PenId.AIRBRUSH] + event_has_axis = e.axes.mask & wacom.EventAxis.AXIS_WHEEL != 0 + assert event_has_axis == pen_has_axis + if pen_has_axis: + assert first_wheel < current_wheel + else: + assert first_wheel == current_wheel + + # vim: set expandtab tabstop=4 shiftwidth=4: |