test: change tablet coords to doubles and pass the pointer through
authorPeter Hutterer <peter.hutterer@who-t.net>
Thu, 11 May 2023 03:45:25 +0000 (13:45 +1000)
committerPeter Hutterer <peter.hutterer@who-t.net>
Tue, 6 Jun 2023 23:23:05 +0000 (09:23 +1000)
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 <peter.hutterer@who-t.net>
test/litest-device-elan-tablet.c
test/litest-device-wacom-isdv4-524c-pen.c
test/litest-int.h
test/litest.c
test/litest.h

index a55635d34016ddafed42c24748267162660af4f2..8ad78f011abed1bff5f48002afc39bcd6c1c5938 100644 (file)
@@ -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);
 
index 1b759ecb580770e6f95473d5da5f76b93f241ae3..864f23ca9562fb35e47a24a441f621c411a57f04 100644 (file)
@@ -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;
index 7a6e2475c21308aa19545c4b28dfa1e8b3251a3a..be025995707671da8d92ca8593d4b8a99b4f2358 100644 (file)
@@ -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);
 
        /**
index ecf673fb206bf0518bede0eb52ecf41a1120f5a9..3cad525a645d2d8629806f52e321f7cbd6a2eecb 100644 (file)
@@ -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);
index 71344f905629e1af4a6f32f8fc3e3a81d7be84ba..f69f83beadb5bbeda45559985c026de7d10ebe72 100644 (file)
@@ -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