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 <peter.hutterer@who-t.net>
This commit is contained in:
Peter Hutterer 2017-02-09 11:06:01 +10:00
parent 47fbd8f98f
commit 2dd9b77c9d
2 changed files with 29 additions and 0 deletions

View file

@ -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)
{

View file

@ -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,