From 160b062454d30ffe62c0b0c610cb8431ddbe237d Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Thu, 11 May 2023 13:45:25 +1000 Subject: [PATCH] test: change tablet coords to doubles and pass the pointer through All other motion/touch/... coords are already doubles so let's follow suite here. And passing a pointer into the custom handlers means we can modify x/y slightly and return false, leaving the rest up to the generic event handling code. Signed-off-by: Peter Hutterer --- test/litest-device-elan-tablet.c | 10 +++++----- test/litest-device-wacom-isdv4-524c-pen.c | 6 +++--- test/litest-int.h | 6 +++--- test/litest.c | 18 +++++++++++------- test/litest.h | 8 ++++---- 5 files changed, 26 insertions(+), 22 deletions(-) diff --git a/test/litest-device-elan-tablet.c b/test/litest-device-elan-tablet.c index a55635d3..8ad78f01 100644 --- a/test/litest-device-elan-tablet.c +++ b/test/litest-device-elan-tablet.c @@ -52,7 +52,7 @@ static struct input_event motion_events[] = { static bool proximity_in(struct litest_device *d, unsigned int tool_type, - double x, double y, + double *x, double *y, struct axis_replacement *axes) { /* nothing special needed for the pen tool, so let litest handle @@ -61,10 +61,10 @@ proximity_in(struct litest_device *d, return false; /* a non-pen tool requires the pen to be in proximity as well. */ - x = litest_scale(d, ABS_X, x); - y = litest_scale(d, ABS_Y, y); - litest_event(d, EV_ABS, ABS_X, x); - litest_event(d, EV_ABS, ABS_X, y); + int sx = litest_scale(d, ABS_X, *x); + int sy = litest_scale(d, ABS_Y, *y); + litest_event(d, EV_ABS, ABS_X, sx); + litest_event(d, EV_ABS, ABS_X, sy); litest_event(d, EV_KEY, BTN_TOOL_PEN, 1); litest_event(d, EV_SYN, SYN_REPORT, 0); diff --git a/test/litest-device-wacom-isdv4-524c-pen.c b/test/litest-device-wacom-isdv4-524c-pen.c index 1b759ecb..864f23ca 100644 --- a/test/litest-device-wacom-isdv4-524c-pen.c +++ b/test/litest-device-wacom-isdv4-524c-pen.c @@ -76,7 +76,7 @@ get_axis_default(struct litest_device *d, unsigned int evcode, int32_t *value) static bool prox_in(struct litest_device *d, unsigned int tool_type, - double x, double y, + double *x, double *y, struct axis_replacement *axes) { struct priv *priv = d->private; @@ -95,7 +95,7 @@ static bool prox_out(struct litest_device *d, unsigned int tool_type) static bool tip_down(struct litest_device *d, - int x, int y, + double *x, double *y, struct axis_replacement *axes) { litest_event(d, EV_KEY, BTN_TOOL_PEN, 1); @@ -104,7 +104,7 @@ tip_down(struct litest_device *d, static bool tip_up(struct litest_device *d, - int x, int y, + double* x, double *y, struct axis_replacement *axes) { struct priv *priv = d->private; diff --git a/test/litest-int.h b/test/litest-int.h index 7a6e2475..be025995 100644 --- a/test/litest-int.h +++ b/test/litest-int.h @@ -116,14 +116,14 @@ struct litest_device_interface { bool (*tablet_proximity_in)(struct litest_device *d, unsigned int tool_type, - double x, double y, + double *x, double *y, struct axis_replacement *axes); bool (*tablet_proximity_out)(struct litest_device *d, unsigned int tool_type); bool (*tablet_tip_down)(struct litest_device *d, - int x, int y, + double *x, double *y, struct axis_replacement *axes); bool (*tablet_tip_up)(struct litest_device *d, - int x, int y, + double *x, double *y, struct axis_replacement *axes); /** diff --git a/test/litest.c b/test/litest.c index ecf673fb..3cad525a 100644 --- a/test/litest.c +++ b/test/litest.c @@ -2471,14 +2471,16 @@ litest_tool_event(struct litest_device *d, int value) } void -litest_tablet_proximity_in(struct litest_device *d, int x, int y, struct axis_replacement *axes) +litest_tablet_proximity_in(struct litest_device *d, + double x, double y, + struct axis_replacement *axes) { struct input_event *ev; /* If the test device overrides proximity_in and says it didn't * handle the event, let's continue normally */ if (d->interface->tablet_proximity_in && - d->interface->tablet_proximity_in(d, d->interface->tool_type, x, y, axes)) + d->interface->tablet_proximity_in(d, d->interface->tool_type, &x, &y, axes)) return; ev = d->interface->tablet_proximity_in_events; @@ -2528,7 +2530,9 @@ litest_tablet_proximity_out(struct litest_device *d) } void -litest_tablet_motion(struct litest_device *d, int x, int y, struct axis_replacement *axes) +litest_tablet_motion(struct litest_device *d, + double x, double y, + struct axis_replacement *axes) { struct input_event *ev; @@ -2543,13 +2547,13 @@ litest_tablet_motion(struct litest_device *d, int x, int y, struct axis_replacem void litest_tablet_tip_down(struct litest_device *d, - int x, int y, + double x, double y, struct axis_replacement *axes) { /* If the test device overrides tip_down and says it didn't * handle the event, let's continue normally */ if (d->interface->tablet_tip_down && - d->interface->tablet_tip_down(d, x, y, axes)) + d->interface->tablet_tip_down(d, &x, &y, axes)) return; litest_event(d, EV_KEY, BTN_TOUCH, 1); @@ -2558,13 +2562,13 @@ litest_tablet_tip_down(struct litest_device *d, void litest_tablet_tip_up(struct litest_device *d, - int x, int y, + double x, double y, struct axis_replacement *axes) { /* If the test device overrides tip_down and says it didn't * handle the event, let's continue normally */ if (d->interface->tablet_tip_up && - d->interface->tablet_tip_up(d, x, y, axes)) + d->interface->tablet_tip_up(d, &x, &y, axes)) return; litest_event(d, EV_KEY, BTN_TOUCH, 0); diff --git a/test/litest.h b/test/litest.h index 71344f90..f69f83be 100644 --- a/test/litest.h +++ b/test/litest.h @@ -631,7 +631,7 @@ litest_tablet_set_tool_type(struct litest_device *d, void litest_tablet_proximity_in(struct litest_device *d, - int x, int y, + double x, double y, struct axis_replacement *axes); void @@ -639,17 +639,17 @@ litest_tablet_proximity_out(struct litest_device *d); void litest_tablet_tip_down(struct litest_device *d, - int x, int y, + double x, double y, struct axis_replacement *axes); void litest_tablet_tip_up(struct litest_device *d, - int x, int y, + double x, double y, struct axis_replacement *axes); void litest_tablet_motion(struct litest_device *d, - int x, int y, + double x, double y, struct axis_replacement *axes); void -- 2.34.1