summaryrefslogtreecommitdiff
path: root/test/litest.c
diff options
context:
space:
mode:
authorPeter Hutterer <peter.hutterer@who-t.net>2014-07-21 12:30:40 +1000
committerPeter Hutterer <peter.hutterer@who-t.net>2014-07-23 15:08:15 +1000
commit61995348d911d763960454725a91043989844e8f (patch)
tree5ad8160cf569a161f408ccf06a41de3b73635c6f /test/litest.c
parentbb10ec84d3704fc0fb40591bcbffe90f6c77966d (diff)
downloadlibinput-61995348d911d763960454725a91043989844e8f.tar.gz
test: auto-update for BTN_TOOL_* when using litest_touch_ functions
Set BTN_TOUCH, BTN_TOOL_DOUBLETAP automatically depending on the number of fingers down. This emulates real event sequences a bit better than the current approach, though it's not a 100% correct emulation: 1) On real devices, BTN_* are usually sent last before the SYN_REPORT - here they are sent first to slot in with the custom, device-specific event sequence. We should only ever look at the complete sequence anyway, so this shouldn't matter. 2) On real devices, the switch from BTN_TOOL_DOUBLETAP to TRIPLETAP and vice versa is not always toggled within the same SYN_REPORT 3) On synaptics devices, BTN_TOUCH is released in the frame where BTN_TOOL_DOUBLETAP is set. It is then immediately set again in the next frame. With the current litest framework this is hard to integrate, so we just leave BTN_TOUCH set the whole time, which is what MT devices do if they don't have BTN_TOOL_DOUBLETAP. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Diffstat (limited to 'test/litest.c')
-rw-r--r--test/litest.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/test/litest.c b/test/litest.c
index 4e79f7bc..deab0cff 100644
--- a/test/litest.c
+++ b/test/litest.c
@@ -24,6 +24,7 @@
#include "config.h"
#endif
+#include <assert.h>
#include <check.h>
#include <errno.h>
#include <fcntl.h>
@@ -620,6 +621,16 @@ auto_assign_value(struct litest_device *d,
return value;
}
+static void
+send_btntool(struct litest_device *d)
+{
+ litest_event(d, EV_KEY, BTN_TOUCH, d->ntouches_down != 0);
+ litest_event(d, EV_KEY, BTN_TOOL_FINGER, d->ntouches_down == 1);
+ litest_event(d, EV_KEY, BTN_TOOL_DOUBLETAP, d->ntouches_down == 2);
+ litest_event(d, EV_KEY, BTN_TOOL_TRIPLETAP, d->ntouches_down == 3);
+ litest_event(d, EV_KEY, BTN_TOOL_QUADTAP, d->ntouches_down == 4);
+ litest_event(d, EV_KEY, BTN_TOOL_QUINTTAP, d->ntouches_down == 5);
+}
void
litest_touch_down(struct litest_device *d, unsigned int slot,
@@ -627,6 +638,10 @@ litest_touch_down(struct litest_device *d, unsigned int slot,
{
struct input_event *ev;
+ assert(++d->ntouches_down > 0);
+
+ send_btntool(d);
+
if (d->interface->touch_down) {
d->interface->touch_down(d, slot, x, y);
return;
@@ -651,6 +666,10 @@ litest_touch_up(struct litest_device *d, unsigned int slot)
{ .type = -1, .code = -1 }
};
+ assert(--d->ntouches_down >= 0);
+
+ send_btntool(d);
+
if (d->interface->touch_up) {
d->interface->touch_up(d, slot);
return;