diff --git a/test/litest-device-protocol-a-touch-screen.c b/test/litest-device-protocol-a-touch-screen.c index 258955c8..3a6bfbcc 100644 --- a/test/litest-device-protocol-a-touch-screen.c +++ b/test/litest-device-protocol-a-touch-screen.c @@ -49,7 +49,7 @@ protocolA_create(struct litest_device *d) return true; /* we want litest to create our device */ } -static void +static bool protocolA_down(struct litest_device *d, unsigned int slot, double x, double y) { struct protocolA_device *dev = d->private; @@ -90,9 +90,11 @@ protocolA_down(struct litest_device *d, unsigned int slot, double x, double y) litest_event(d, EV_KEY, BTN_TOUCH, 1); litest_event(d, EV_SYN, SYN_REPORT, 0); } + + return true; /* we handled the event */ } -static void +static bool protocolA_move(struct litest_device *d, unsigned int slot, double x, double y) { struct protocolA_device *dev = d->private; @@ -128,9 +130,11 @@ protocolA_move(struct litest_device *d, unsigned int slot, double x, double y) if (!first) litest_event(d, EV_SYN, SYN_REPORT, 0); + + return true; /* we handled the event */ } -static void +static bool protocolA_up(struct litest_device *d, unsigned int slot) { struct protocolA_device *dev = d->private; @@ -166,6 +170,8 @@ protocolA_up(struct litest_device *d, unsigned int slot) if (first) litest_event(d, EV_KEY, BTN_TOUCH, 0); litest_event(d, EV_SYN, SYN_REPORT, 0); + + return true; /* we handled the event */ } static struct litest_device_interface interface = { diff --git a/test/litest-device-qemu-usb-tablet.c b/test/litest-device-qemu-usb-tablet.c index bfcbc736..f8ed1b94 100644 --- a/test/litest-device-qemu-usb-tablet.c +++ b/test/litest-device-qemu-usb-tablet.c @@ -27,30 +27,37 @@ #include "litest-int.h" #include -static void touch_down(struct litest_device *d, unsigned int slot, - double x, double y) +static bool +touch_down(struct litest_device *d, unsigned int slot, double x, double y) { assert(slot == 0); litest_event(d, EV_ABS, ABS_X, litest_scale(d, ABS_X, x)); litest_event(d, EV_ABS, ABS_Y, litest_scale(d, ABS_Y, y)); litest_event(d, EV_SYN, SYN_REPORT, 0); + + return true; /* we handled the event */ } -static void touch_move(struct litest_device *d, unsigned int slot, - double x, double y) +static bool +touch_move(struct litest_device *d, unsigned int slot, double x, double y) { assert(slot == 0); litest_event(d, EV_ABS, ABS_X, litest_scale(d, ABS_X, x)); litest_event(d, EV_ABS, ABS_Y, litest_scale(d, ABS_Y, y)); litest_event(d, EV_SYN, SYN_REPORT, 0); + + return true; /* we handled the event */ } -static void touch_up(struct litest_device *d, unsigned int slot) +static bool +touch_up(struct litest_device *d, unsigned int slot) { assert(slot == 0); litest_event(d, EV_SYN, SYN_REPORT, 0); + + return true; /* we handled the event */ } static struct litest_device_interface interface = { diff --git a/test/litest-device-vmware-virtual-usb-mouse.c b/test/litest-device-vmware-virtual-usb-mouse.c index faefda33..81fd0b7c 100644 --- a/test/litest-device-vmware-virtual-usb-mouse.c +++ b/test/litest-device-vmware-virtual-usb-mouse.c @@ -27,30 +27,37 @@ #include "litest-int.h" #include -static void touch_down(struct litest_device *d, unsigned int slot, - double x, double y) +static bool +touch_down(struct litest_device *d, unsigned int slot, double x, double y) { assert(slot == 0); litest_event(d, EV_ABS, ABS_X, litest_scale(d, ABS_X, x)); litest_event(d, EV_ABS, ABS_Y, litest_scale(d, ABS_Y, y)); litest_event(d, EV_SYN, SYN_REPORT, 0); + + return true; /* we handled the event */ } -static void touch_move(struct litest_device *d, unsigned int slot, - double x, double y) +static bool +touch_move(struct litest_device *d, unsigned int slot, double x, double y) { assert(slot == 0); litest_event(d, EV_ABS, ABS_X, litest_scale(d, ABS_X, x)); litest_event(d, EV_ABS, ABS_Y, litest_scale(d, ABS_Y, y)); litest_event(d, EV_SYN, SYN_REPORT, 0); + + return true; /* we handled the event */ } -static void touch_up(struct litest_device *d, unsigned int slot) +static bool +touch_up(struct litest_device *d, unsigned int slot) { assert(slot == 0); litest_event(d, EV_SYN, SYN_REPORT, 0); + + return true; /* we handled the event */ } static struct litest_device_interface interface = { diff --git a/test/litest-device-xen-virtual-pointer.c b/test/litest-device-xen-virtual-pointer.c index 44d30131..79c4c555 100644 --- a/test/litest-device-xen-virtual-pointer.c +++ b/test/litest-device-xen-virtual-pointer.c @@ -27,30 +27,37 @@ #include "litest-int.h" #include -static void touch_down(struct litest_device *d, unsigned int slot, - double x, double y) +static bool +touch_down(struct litest_device *d, unsigned int slot, double x, double y) { assert(slot == 0); litest_event(d, EV_ABS, ABS_X, litest_scale(d, ABS_X, x)); litest_event(d, EV_ABS, ABS_Y, litest_scale(d, ABS_Y, y)); litest_event(d, EV_SYN, SYN_REPORT, 0); + + return true; /* we handled the event */ } -static void touch_move(struct litest_device *d, unsigned int slot, - double x, double y) +static bool +touch_move(struct litest_device *d, unsigned int slot, double x, double y) { assert(slot == 0); litest_event(d, EV_ABS, ABS_X, litest_scale(d, ABS_X, x)); litest_event(d, EV_ABS, ABS_Y, litest_scale(d, ABS_Y, y)); litest_event(d, EV_SYN, SYN_REPORT, 0); + + return true; /* we handled the event */ } -static void touch_up(struct litest_device *d, unsigned int slot) +static bool +touch_up(struct litest_device *d, unsigned int slot) { assert(slot == 0); litest_event(d, EV_SYN, SYN_REPORT, 0); + + return true; /* we handled the event */ } static struct litest_device_interface interface = { diff --git a/test/litest-int.h b/test/litest-int.h index 598c8d0a..36be7a5b 100644 --- a/test/litest-int.h +++ b/test/litest-int.h @@ -81,9 +81,9 @@ struct litest_test_device { }; struct litest_device_interface { - void (*touch_down)(struct litest_device *d, unsigned int slot, double x, double y); - void (*touch_move)(struct litest_device *d, unsigned int slot, double x, double y); - void (*touch_up)(struct litest_device *d, unsigned int slot); + bool (*touch_down)(struct litest_device *d, unsigned int slot, double x, double y); + bool (*touch_move)(struct litest_device *d, unsigned int slot, double x, double y); + bool (*touch_up)(struct litest_device *d, unsigned int slot); /** * Default value for the given EV_ABS axis. diff --git a/test/litest.c b/test/litest.c index f93eb990..9f441704 100644 --- a/test/litest.c +++ b/test/litest.c @@ -1954,10 +1954,11 @@ slot_start(struct litest_device *d, send_btntool(d, !touching); - if (d->interface->touch_down) { - d->interface->touch_down(d, slot, x, y); - return; - } + /* If the test device overrides touch_down and says it didn't + * handle the event, let's continue normally */ + if (d->interface->touch_down && + d->interface->touch_down(d, slot, x, y)) + return; for (ev = d->interface->touch_down_events; ev && (int16_t)ev->type != -1 && (int16_t)ev->code != -1; @@ -1991,10 +1992,9 @@ slot_move(struct litest_device *d, { struct input_event *ev; - if (d->interface->touch_move) { - d->interface->touch_move(d, slot, x, y); + if (d->interface->touch_move && + d->interface->touch_move(d, slot, x, y)) return; - } for (ev = d->interface->touch_move_events; ev && (int16_t)ev->type != -1 && (int16_t)ev->code != -1; @@ -2036,8 +2036,8 @@ touch_up(struct litest_device *d, unsigned int slot) send_btntool(d, false); - if (d->interface->touch_up) { - d->interface->touch_up(d, slot); + if (d->interface->touch_up && + d->interface->touch_up(d, slot)) { return; } else if (d->interface->touch_up_events) { ev = d->interface->touch_up_events;