From 2dd9b77c9d4dc678719fd1775adc1d4c50d44ea3 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Thu, 9 Feb 2017 11:06:01 +1000 Subject: [PATCH] test: add helper functions to filter an event Simplest implementation for what we need right now, it turns off an event on the evdev device and turns it back on again. This allows us to change bits in the 'normal' event stream, such as changing the tool type without triggering proximity events for the BTN_TOOL_PEN that all test devices send by default. This won't work for absolute devices because we need to re-enable with a struct input_absinfo. But we don't need that ability for now anyway. Signed-off-by: Peter Hutterer --- test/litest.c | 20 ++++++++++++++++++++ test/litest.h | 9 +++++++++ 2 files changed, 29 insertions(+) diff --git a/test/litest.c b/test/litest.c index 78ef5dfc..00336a74 100644 --- a/test/litest.c +++ b/test/litest.c @@ -3248,6 +3248,26 @@ litest_pop_event_frame(struct litest_device *dev) litest_event(dev, EV_SYN, SYN_REPORT, 0); } +void +litest_filter_event(struct litest_device *dev, + unsigned int type, + unsigned int code) +{ + libevdev_disable_event_code(dev->evdev, type, code); +} + +void +litest_unfilter_event(struct litest_device *dev, + unsigned int type, + unsigned int code) +{ + /* would need an non-NULL argument for re-enabling, so simply abort + * until we need to be more sophisticated */ + litest_assert(type != EV_ABS); + + libevdev_enable_event_code(dev->evdev, type, code, NULL); +} + static void send_abs_xy(struct litest_device *d, double x, double y) { diff --git a/test/litest.h b/test/litest.h index d6b0ef0e..f5d91b91 100644 --- a/test/litest.h +++ b/test/litest.h @@ -707,6 +707,15 @@ litest_push_event_frame(struct litest_device *dev); void litest_pop_event_frame(struct litest_device *dev); +void +litest_filter_event(struct litest_device *dev, + unsigned int type, + unsigned int code); + +void +litest_unfilter_event(struct litest_device *dev, + unsigned int type, + unsigned int code); void litest_semi_mt_touch_down(struct litest_device *d, struct litest_semi_mt *semi_mt,