diff options
author | Peter Hutterer <peter.hutterer@who-t.net> | 2020-09-11 08:43:58 +1000 |
---|---|---|
committer | Peter Hutterer <peter.hutterer@who-t.net> | 2020-09-22 17:35:41 +1000 |
commit | df2759706fc83e9cedc8c9101f9e94e9c9a00682 (patch) | |
tree | 3ecd5d5f78f9c8f123b09ebc33b6a34816144cd1 | |
parent | 06e7adfca39d7ff4f557163e5ffa002026f969d3 (diff) | |
download | libinput-df2759706fc83e9cedc8c9101f9e94e9c9a00682.tar.gz |
test: auto-assign the tool type for tablet tests
The current tool type test merely sends BTN_TOOL_RUBBER (and others) manually
and expects libinput to do the right thing. This only tests the perfect
sequence but not test weird devices that behave differently on a tool type
switch.
So let's fix this by setting the tool type as property on the libinput test
device itself, and then emulate the tool switch through litest.
For special devices this will need extra callbacks, this is just the initial
framework to handle those buttons.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
-rw-r--r-- | test/litest-device-elan-tablet.c | 4 | ||||
-rw-r--r-- | test/litest-device-huion-pentablet.c | 2 | ||||
-rw-r--r-- | test/litest-device-wacom-bamboo-16fg-pen.c | 4 | ||||
-rw-r--r-- | test/litest-device-wacom-bamboo-2fg-pen.c | 4 | ||||
-rw-r--r-- | test/litest-device-wacom-cintiq-12wx-pen.c | 4 | ||||
-rw-r--r-- | test/litest-device-wacom-cintiq-13hdt-pen.c | 4 | ||||
-rw-r--r-- | test/litest-device-wacom-cintiq-24hd-pen.c | 4 | ||||
-rw-r--r-- | test/litest-device-wacom-cintiq-pro-16-pen.c | 4 | ||||
-rw-r--r-- | test/litest-device-wacom-hid4800-pen.c | 4 | ||||
-rw-r--r-- | test/litest-device-wacom-intuos5-pen.c | 4 | ||||
-rw-r--r-- | test/litest-device-wacom-isdv4-4200-pen.c | 4 | ||||
-rw-r--r-- | test/litest-device-wacom-isdv4-e6-pen.c | 4 | ||||
-rw-r--r-- | test/litest-device-waltop-tablet.c | 4 | ||||
-rw-r--r-- | test/litest-int.h | 5 | ||||
-rw-r--r-- | test/litest.c | 59 | ||||
-rw-r--r-- | test/litest.h | 4 | ||||
-rw-r--r-- | test/test-tablet.c | 11 |
17 files changed, 88 insertions, 41 deletions
diff --git a/test/litest-device-elan-tablet.c b/test/litest-device-elan-tablet.c index 7b8e7022..433a03c2 100644 --- a/test/litest-device-elan-tablet.c +++ b/test/litest-device-elan-tablet.c @@ -30,13 +30,13 @@ static struct input_event proximity_in[] = { { .type = EV_ABS, .code = ABS_X, .value = LITEST_AUTO_ASSIGN }, { .type = EV_ABS, .code = ABS_Y, .value = LITEST_AUTO_ASSIGN }, { .type = EV_ABS, .code = ABS_PRESSURE, .value = LITEST_AUTO_ASSIGN }, - { .type = EV_KEY, .code = BTN_TOOL_PEN, .value = 1 }, + { .type = EV_KEY, .code = LITEST_BTN_TOOL_AUTO, .value = 1 }, { .type = EV_SYN, .code = SYN_REPORT, .value = 0 }, { .type = -1, .code = -1 }, }; static struct input_event proximity_out[] = { - { .type = EV_KEY, .code = BTN_TOOL_PEN, .value = 0 }, + { .type = EV_KEY, .code = LITEST_BTN_TOOL_AUTO, .value = 0 }, { .type = EV_SYN, .code = SYN_REPORT, .value = 0 }, { .type = -1, .code = -1 }, }; diff --git a/test/litest-device-huion-pentablet.c b/test/litest-device-huion-pentablet.c index 976d6708..8e81bc15 100644 --- a/test/litest-device-huion-pentablet.c +++ b/test/litest-device-huion-pentablet.c @@ -30,7 +30,7 @@ static struct input_event proximity_in[] = { { .type = EV_ABS, .code = ABS_X, .value = LITEST_AUTO_ASSIGN }, { .type = EV_ABS, .code = ABS_Y, .value = LITEST_AUTO_ASSIGN }, { .type = EV_ABS, .code = ABS_PRESSURE, .value = LITEST_AUTO_ASSIGN }, - { .type = EV_KEY, .code = BTN_TOOL_PEN, .value = 1 }, + { .type = EV_KEY, .code = LITEST_BTN_TOOL_AUTO, .value = 1 }, { .type = EV_SYN, .code = SYN_REPORT, .value = 0 }, { .type = -1, .code = -1 }, }; diff --git a/test/litest-device-wacom-bamboo-16fg-pen.c b/test/litest-device-wacom-bamboo-16fg-pen.c index 2427fc72..cc65afea 100644 --- a/test/litest-device-wacom-bamboo-16fg-pen.c +++ b/test/litest-device-wacom-bamboo-16fg-pen.c @@ -31,7 +31,7 @@ static struct input_event proximity_in[] = { { .type = EV_ABS, .code = ABS_Y, .value = LITEST_AUTO_ASSIGN }, { .type = EV_ABS, .code = ABS_DISTANCE, .value = LITEST_AUTO_ASSIGN }, { .type = EV_ABS, .code = ABS_PRESSURE, .value = LITEST_AUTO_ASSIGN }, - { .type = EV_KEY, .code = BTN_TOOL_PEN, .value = 1 }, + { .type = EV_KEY, .code = LITEST_BTN_TOOL_AUTO, .value = 1 }, { .type = EV_SYN, .code = SYN_REPORT, .value = 0 }, { .type = -1, .code = -1 }, }; @@ -40,7 +40,7 @@ static struct input_event proximity_out[] = { { .type = EV_ABS, .code = ABS_X, .value = 0 }, { .type = EV_ABS, .code = ABS_Y, .value = 0 }, { .type = EV_ABS, .code = ABS_DISTANCE, .value = 0 }, - { .type = EV_KEY, .code = BTN_TOOL_PEN, .value = 0 }, + { .type = EV_KEY, .code = LITEST_BTN_TOOL_AUTO, .value = 0 }, { .type = EV_SYN, .code = SYN_REPORT, .value = 0 }, { .type = -1, .code = -1 }, }; diff --git a/test/litest-device-wacom-bamboo-2fg-pen.c b/test/litest-device-wacom-bamboo-2fg-pen.c index aa1e3c24..6889ff3f 100644 --- a/test/litest-device-wacom-bamboo-2fg-pen.c +++ b/test/litest-device-wacom-bamboo-2fg-pen.c @@ -31,7 +31,7 @@ static struct input_event proximity_in[] = { { .type = EV_ABS, .code = ABS_Y, .value = LITEST_AUTO_ASSIGN }, { .type = EV_ABS, .code = ABS_DISTANCE, .value = LITEST_AUTO_ASSIGN }, { .type = EV_ABS, .code = ABS_PRESSURE, .value = LITEST_AUTO_ASSIGN }, - { .type = EV_KEY, .code = BTN_TOOL_PEN, .value = 1 }, + { .type = EV_KEY, .code = LITEST_BTN_TOOL_AUTO, .value = 1 }, { .type = EV_SYN, .code = SYN_REPORT, .value = 0 }, { .type = -1, .code = -1 }, }; @@ -40,7 +40,7 @@ static struct input_event proximity_out[] = { { .type = EV_ABS, .code = ABS_X, .value = 0 }, { .type = EV_ABS, .code = ABS_Y, .value = 0 }, { .type = EV_ABS, .code = ABS_DISTANCE, .value = 0 }, - { .type = EV_KEY, .code = BTN_TOOL_PEN, .value = 0 }, + { .type = EV_KEY, .code = LITEST_BTN_TOOL_AUTO, .value = 0 }, { .type = EV_SYN, .code = SYN_REPORT, .value = 0 }, { .type = -1, .code = -1 }, }; diff --git a/test/litest-device-wacom-cintiq-12wx-pen.c b/test/litest-device-wacom-cintiq-12wx-pen.c index ca33137c..e9c4f684 100644 --- a/test/litest-device-wacom-cintiq-12wx-pen.c +++ b/test/litest-device-wacom-cintiq-12wx-pen.c @@ -35,7 +35,7 @@ static struct input_event proximity_in[] = { { .type = EV_ABS, .code = ABS_TILT_Y, .value = LITEST_AUTO_ASSIGN }, { .type = EV_ABS, .code = ABS_MISC, .value = 2083 }, { .type = EV_MSC, .code = MSC_SERIAL, .value = 297797542 }, - { .type = EV_KEY, .code = BTN_TOOL_PEN, .value = 1 }, + { .type = EV_KEY, .code = LITEST_BTN_TOOL_AUTO, .value = 1 }, { .type = EV_SYN, .code = SYN_REPORT, .value = 0 }, { .type = -1, .code = -1 }, }; @@ -48,7 +48,7 @@ static struct input_event proximity_out[] = { { .type = EV_ABS, .code = ABS_TILT_Y, .value = 0 }, { .type = EV_ABS, .code = ABS_MISC, .value = 0 }, { .type = EV_MSC, .code = MSC_SERIAL, .value = 297797542 }, - { .type = EV_KEY, .code = BTN_TOOL_PEN, .value = 0 }, + { .type = EV_KEY, .code = LITEST_BTN_TOOL_AUTO, .value = 0 }, { .type = EV_SYN, .code = SYN_REPORT, .value = 0 }, { .type = -1, .code = -1 }, }; diff --git a/test/litest-device-wacom-cintiq-13hdt-pen.c b/test/litest-device-wacom-cintiq-13hdt-pen.c index 59755107..4adf0efd 100644 --- a/test/litest-device-wacom-cintiq-13hdt-pen.c +++ b/test/litest-device-wacom-cintiq-13hdt-pen.c @@ -35,7 +35,7 @@ static struct input_event proximity_in[] = { { .type = EV_ABS, .code = ABS_TILT_Y, .value = LITEST_AUTO_ASSIGN }, { .type = EV_ABS, .code = ABS_MISC, .value = 2083 }, { .type = EV_MSC, .code = MSC_SERIAL, .value = 297797542 }, - { .type = EV_KEY, .code = BTN_TOOL_PEN, .value = 1 }, + { .type = EV_KEY, .code = LITEST_BTN_TOOL_AUTO, .value = 1 }, { .type = EV_SYN, .code = SYN_REPORT, .value = 0 }, { .type = -1, .code = -1 }, }; @@ -48,7 +48,7 @@ static struct input_event proximity_out[] = { { .type = EV_ABS, .code = ABS_TILT_Y, .value = 0 }, { .type = EV_ABS, .code = ABS_MISC, .value = 0 }, { .type = EV_MSC, .code = MSC_SERIAL, .value = 297797542 }, - { .type = EV_KEY, .code = BTN_TOOL_PEN, .value = 0 }, + { .type = EV_KEY, .code = LITEST_BTN_TOOL_AUTO, .value = 0 }, { .type = EV_SYN, .code = SYN_REPORT, .value = 0 }, { .type = -1, .code = -1 }, }; diff --git a/test/litest-device-wacom-cintiq-24hd-pen.c b/test/litest-device-wacom-cintiq-24hd-pen.c index 2e47df9b..f8b9a57a 100644 --- a/test/litest-device-wacom-cintiq-24hd-pen.c +++ b/test/litest-device-wacom-cintiq-24hd-pen.c @@ -35,7 +35,7 @@ static struct input_event proximity_in[] = { { .type = EV_ABS, .code = ABS_TILT_Y, .value = LITEST_AUTO_ASSIGN }, { .type = EV_ABS, .code = ABS_MISC, .value = 2083 }, { .type = EV_MSC, .code = MSC_SERIAL, .value = 297797542 }, - { .type = EV_KEY, .code = BTN_TOOL_PEN, .value = 1 }, + { .type = EV_KEY, .code = LITEST_BTN_TOOL_AUTO, .value = 1 }, { .type = EV_SYN, .code = SYN_REPORT, .value = 0 }, { .type = -1, .code = -1 }, }; @@ -48,7 +48,7 @@ static struct input_event proximity_out[] = { { .type = EV_ABS, .code = ABS_TILT_Y, .value = 0 }, { .type = EV_ABS, .code = ABS_MISC, .value = 0 }, { .type = EV_MSC, .code = MSC_SERIAL, .value = 297797542 }, - { .type = EV_KEY, .code = BTN_TOOL_PEN, .value = 0 }, + { .type = EV_KEY, .code = LITEST_BTN_TOOL_AUTO, .value = 0 }, { .type = EV_SYN, .code = SYN_REPORT, .value = 0 }, { .type = -1, .code = -1 }, }; diff --git a/test/litest-device-wacom-cintiq-pro-16-pen.c b/test/litest-device-wacom-cintiq-pro-16-pen.c index 35997ae2..3b9dc1a4 100644 --- a/test/litest-device-wacom-cintiq-pro-16-pen.c +++ b/test/litest-device-wacom-cintiq-pro-16-pen.c @@ -37,7 +37,7 @@ static struct input_event proximity_in[] = { { .type = EV_ABS, .code = ABS_TILT_Y, .value = LITEST_AUTO_ASSIGN }, { .type = EV_ABS, .code = ABS_MISC, .value = 2083 }, { .type = EV_MSC, .code = MSC_SERIAL, .value = 297797542 }, - { .type = EV_KEY, .code = BTN_TOOL_PEN, .value = 1 }, + { .type = EV_KEY, .code = LITEST_BTN_TOOL_AUTO, .value = 1 }, { .type = EV_SYN, .code = SYN_REPORT, .value = 0 }, { .type = -1, .code = -1 }, }; @@ -52,7 +52,7 @@ static struct input_event proximity_out[] = { { .type = EV_ABS, .code = ABS_TILT_Y, .value = 0 }, { .type = EV_ABS, .code = ABS_MISC, .value = 0 }, { .type = EV_MSC, .code = MSC_SERIAL, .value = 297797542 }, - { .type = EV_KEY, .code = BTN_TOOL_PEN, .value = 0 }, + { .type = EV_KEY, .code = LITEST_BTN_TOOL_AUTO, .value = 0 }, { .type = EV_SYN, .code = SYN_REPORT, .value = 0 }, { .type = -1, .code = -1 }, }; diff --git a/test/litest-device-wacom-hid4800-pen.c b/test/litest-device-wacom-hid4800-pen.c index 3f424851..85f091be 100644 --- a/test/litest-device-wacom-hid4800-pen.c +++ b/test/litest-device-wacom-hid4800-pen.c @@ -30,7 +30,7 @@ static struct input_event proximity_in[] = { { .type = EV_ABS, .code = ABS_X, .value = LITEST_AUTO_ASSIGN }, { .type = EV_ABS, .code = ABS_Y, .value = LITEST_AUTO_ASSIGN }, { .type = EV_ABS, .code = ABS_PRESSURE, .value = LITEST_AUTO_ASSIGN }, - { .type = EV_KEY, .code = BTN_TOOL_PEN, .value = 1 }, + { .type = EV_KEY, .code = LITEST_BTN_TOOL_AUTO, .value = 1 }, { .type = EV_MSC, .code = MSC_SERIAL, .value = 297797542 }, { .type = EV_SYN, .code = SYN_REPORT, .value = 0 }, { .type = -1, .code = -1 }, @@ -40,7 +40,7 @@ static struct input_event proximity_out[] = { { .type = EV_ABS, .code = ABS_X, .value = 0 }, { .type = EV_ABS, .code = ABS_Y, .value = 0 }, { .type = EV_MSC, .code = MSC_SERIAL, .value = 297797542 }, - { .type = EV_KEY, .code = BTN_TOOL_PEN, .value = 0 }, + { .type = EV_KEY, .code = LITEST_BTN_TOOL_AUTO, .value = 0 }, { .type = EV_SYN, .code = SYN_REPORT, .value = 0 }, { .type = -1, .code = -1 }, }; diff --git a/test/litest-device-wacom-intuos5-pen.c b/test/litest-device-wacom-intuos5-pen.c index ae8439c0..49709093 100644 --- a/test/litest-device-wacom-intuos5-pen.c +++ b/test/litest-device-wacom-intuos5-pen.c @@ -35,7 +35,7 @@ static struct input_event proximity_in[] = { { .type = EV_ABS, .code = ABS_TILT_Y, .value = LITEST_AUTO_ASSIGN }, { .type = EV_ABS, .code = ABS_MISC, .value = 1050626 }, { .type = EV_MSC, .code = MSC_SERIAL, .value = 578837976 }, - { .type = EV_KEY, .code = BTN_TOOL_PEN, .value = 1 }, + { .type = EV_KEY, .code = LITEST_BTN_TOOL_AUTO, .value = 1 }, { .type = EV_SYN, .code = SYN_REPORT, .value = 0 }, { .type = -1, .code = -1 }, }; @@ -48,7 +48,7 @@ static struct input_event proximity_out[] = { { .type = EV_ABS, .code = ABS_TILT_Y, .value = 0 }, { .type = EV_ABS, .code = ABS_MISC, .value = 0 }, { .type = EV_MSC, .code = MSC_SERIAL, .value = 578837976 }, - { .type = EV_KEY, .code = BTN_TOOL_PEN, .value = 0 }, + { .type = EV_KEY, .code = LITEST_BTN_TOOL_AUTO, .value = 0 }, { .type = EV_SYN, .code = SYN_REPORT, .value = 0 }, { .type = -1, .code = -1 }, }; diff --git a/test/litest-device-wacom-isdv4-4200-pen.c b/test/litest-device-wacom-isdv4-4200-pen.c index 2627138f..59bf8662 100644 --- a/test/litest-device-wacom-isdv4-4200-pen.c +++ b/test/litest-device-wacom-isdv4-4200-pen.c @@ -30,13 +30,13 @@ static struct input_event proximity_in[] = { { .type = EV_ABS, .code = ABS_X, .value = LITEST_AUTO_ASSIGN }, { .type = EV_ABS, .code = ABS_Y, .value = LITEST_AUTO_ASSIGN }, { .type = EV_ABS, .code = ABS_PRESSURE, .value = LITEST_AUTO_ASSIGN }, - { .type = EV_KEY, .code = BTN_TOOL_PEN, .value = 1 }, + { .type = EV_KEY, .code = LITEST_BTN_TOOL_AUTO, .value = 1 }, { .type = EV_SYN, .code = SYN_REPORT, .value = 0 }, { .type = -1, .code = -1 }, }; static struct input_event proximity_out[] = { - { .type = EV_KEY, .code = BTN_TOOL_PEN, .value = 0 }, + { .type = EV_KEY, .code = LITEST_BTN_TOOL_AUTO, .value = 0 }, { .type = EV_SYN, .code = SYN_REPORT, .value = 0 }, { .type = -1, .code = -1 }, }; diff --git a/test/litest-device-wacom-isdv4-e6-pen.c b/test/litest-device-wacom-isdv4-e6-pen.c index 07c250a2..d1e291cf 100644 --- a/test/litest-device-wacom-isdv4-e6-pen.c +++ b/test/litest-device-wacom-isdv4-e6-pen.c @@ -30,13 +30,13 @@ static struct input_event proximity_in[] = { { .type = EV_ABS, .code = ABS_X, .value = LITEST_AUTO_ASSIGN }, { .type = EV_ABS, .code = ABS_Y, .value = LITEST_AUTO_ASSIGN }, { .type = EV_ABS, .code = ABS_PRESSURE, .value = LITEST_AUTO_ASSIGN }, - { .type = EV_KEY, .code = BTN_TOOL_PEN, .value = 1 }, + { .type = EV_KEY, .code = LITEST_BTN_TOOL_AUTO, .value = 1 }, { .type = EV_SYN, .code = SYN_REPORT, .value = 0 }, { .type = -1, .code = -1 }, }; static struct input_event proximity_out[] = { - { .type = EV_KEY, .code = BTN_TOOL_PEN, .value = 0 }, + { .type = EV_KEY, .code = LITEST_BTN_TOOL_AUTO, .value = 0 }, { .type = EV_SYN, .code = SYN_REPORT, .value = 0 }, { .type = -1, .code = -1 }, }; diff --git a/test/litest-device-waltop-tablet.c b/test/litest-device-waltop-tablet.c index 19522866..62561e15 100644 --- a/test/litest-device-waltop-tablet.c +++ b/test/litest-device-waltop-tablet.c @@ -32,7 +32,7 @@ static struct input_event proximity_in[] = { { .type = EV_ABS, .code = ABS_TILT_X, .value = LITEST_AUTO_ASSIGN }, { .type = EV_ABS, .code = ABS_TILT_Y, .value = LITEST_AUTO_ASSIGN }, { .type = EV_ABS, .code = ABS_PRESSURE, .value = LITEST_AUTO_ASSIGN }, - { .type = EV_KEY, .code = BTN_TOOL_PEN, .value = 1 }, + { .type = EV_KEY, .code = LITEST_BTN_TOOL_AUTO, .value = 1 }, { .type = EV_SYN, .code = SYN_REPORT, .value = 0 }, { .type = -1, .code = -1 }, }; @@ -42,7 +42,7 @@ static struct input_event proximity_out[] = { { .type = EV_ABS, .code = ABS_Y, .value = 0 }, { .type = EV_ABS, .code = ABS_TILT_X, .value = 0 }, { .type = EV_ABS, .code = ABS_TILT_Y, .value = 0 }, - { .type = EV_KEY, .code = BTN_TOOL_PEN, .value = 0 }, + { .type = EV_KEY, .code = LITEST_BTN_TOOL_AUTO, .value = 0 }, { .type = EV_SYN, .code = SYN_REPORT, .value = 0 }, { .type = -1, .code = -1 }, }; diff --git a/test/litest-int.h b/test/litest-int.h index c5b05e68..5bc62d9c 100644 --- a/test/litest-int.h +++ b/test/litest-int.h @@ -31,6 +31,9 @@ /* Use as designater for litest to change the value */ #define LITEST_AUTO_ASSIGN INT_MIN +/* Special event code to auto-assign the BTN_TOOL_PEN and friends */ +#define LITEST_BTN_TOOL_AUTO (KEY_MAX << 1) + struct litest_test_device { struct list node; /* global test device list */ @@ -129,6 +132,8 @@ struct litest_device_interface { int min[2]; /* x/y axis minimum */ int max[2]; /* x/y axis maximum */ + + unsigned int tool_type; }; struct path { diff --git a/test/litest.c b/test/litest.c index a10d50db..40111238 100644 --- a/test/litest.c +++ b/test/litest.c @@ -65,6 +65,8 @@ #include <linux/kd.h> +#define evbit(t, c) ((t) << 16U | (c & 0xffff)) + #define UDEV_RULES_D "/run/udev/rules.d" #define UDEV_FUZZ_OVERRIDE_RULE_FILE UDEV_RULES_D \ "/91-litest-fuzz-override-REMOVEME-XXXXXX.rules" @@ -1812,6 +1814,7 @@ litest_add_device_with_overrides(struct libinput *libinput, d->interface->min[ABS_Y] = libevdev_get_abs_minimum(d->evdev, code); d->interface->max[ABS_Y] = libevdev_get_abs_maximum(d->evdev, code); } + d->interface->tool_type = BTN_TOOL_PEN; } return d; } @@ -2444,15 +2447,50 @@ tablet_ignore_event(const struct input_event *ev, int value) } void +litest_tablet_set_tool_type(struct litest_device *d, unsigned int code) +{ + switch (code) { + case BTN_TOOL_PEN: + case BTN_TOOL_RUBBER: + case BTN_TOOL_BRUSH: + case BTN_TOOL_PENCIL: + case BTN_TOOL_AIRBRUSH: + case BTN_TOOL_MOUSE: + case BTN_TOOL_LENS: + break; + default: + abort(); + } + + d->interface->tool_type = code; +} + +static void +litest_tool_event(struct litest_device *d, int value) +{ + unsigned int tool = d->interface->tool_type; + + litest_event(d, EV_KEY, tool, value); +} + +void litest_tablet_proximity_in(struct litest_device *d, int x, int y, struct axis_replacement *axes) { struct input_event *ev; ev = d->interface->tablet_proximity_in_events; while (ev && (int16_t)ev->type != -1 && (int16_t)ev->code != -1) { - int value = auto_assign_tablet_value(d, ev, x, y, axes); - if (!tablet_ignore_event(ev, value)) - litest_event(d, ev->type, ev->code, value); + int value; + + switch (evbit(ev->type, ev->code)) { + case evbit(EV_KEY, LITEST_BTN_TOOL_AUTO): + litest_tool_event(d, ev->value); + break; + default: + value = auto_assign_tablet_value(d, ev, x, y, axes); + if (!tablet_ignore_event(ev, value)) + litest_event(d, ev->type, ev->code, value); + } ev++; } } @@ -2464,9 +2502,18 @@ litest_tablet_proximity_out(struct litest_device *d) ev = d->interface->tablet_proximity_out_events; while (ev && (int16_t)ev->type != -1 && (int16_t)ev->code != -1) { - int value = auto_assign_tablet_value(d, ev, -1, -1, NULL); - if (!tablet_ignore_event(ev, value)) - litest_event(d, ev->type, ev->code, value); + int value; + + switch (evbit(ev->type, ev->code)) { + case evbit(EV_KEY, LITEST_BTN_TOOL_AUTO): + litest_tool_event(d, ev->value); + break; + default: + value = auto_assign_tablet_value(d, ev, -1, -1, NULL); + if (!tablet_ignore_event(ev, value)) + litest_event(d, ev->type, ev->code, value); + break; + } ev++; } } diff --git a/test/litest.h b/test/litest.h index 1f4e609d..dcbb47bc 100644 --- a/test/litest.h +++ b/test/litest.h @@ -604,6 +604,10 @@ litest_touch_move_three_touches(struct litest_device *d, int steps); void +litest_tablet_set_tool_type(struct litest_device *d, + unsigned int code); + +void litest_tablet_proximity_in(struct litest_device *d, int x, int y, struct axis_replacement *axes); diff --git a/test/test-tablet.c b/test/test-tablet.c index bfc25737..d0b728ec 100644 --- a/test/test-tablet.c +++ b/test/test-tablet.c @@ -2820,12 +2820,8 @@ START_TEST(tool_type) !tablet_has_mouse(dev)) continue; - litest_push_event_frame(dev); - litest_filter_event(dev, EV_KEY, BTN_TOOL_PEN); + litest_tablet_set_tool_type(dev, tt->code); litest_tablet_proximity_in(dev, 50, 50, axes); - litest_unfilter_event(dev, EV_KEY, BTN_TOOL_PEN); - litest_event(dev, EV_KEY, tt->code, 1); - litest_pop_event_frame(dev); libinput_dispatch(li); event = libinput_get_event(li); @@ -2839,12 +2835,7 @@ START_TEST(tool_type) libinput_event_destroy(event); litest_assert_empty_queue(li); - litest_push_event_frame(dev); - litest_filter_event(dev, EV_KEY, BTN_TOOL_PEN); litest_tablet_proximity_out(dev); - litest_unfilter_event(dev, EV_KEY, BTN_TOOL_PEN); - litest_event(dev, EV_KEY, tt->code, 0); - litest_pop_event_frame(dev); litest_drain_events(li); } } |