mirror of
https://gitlab.freedesktop.org/libinput/libinput.git
synced 2025-12-30 18:50:08 +01:00
test: make the custom touch override methods filter-able
Let those functions return true if they handled the event or false where they didn't. This makes it more flexible to override touches in special cases only and fall back to the normal litest handling otherwise. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
parent
8fdeba9ea2
commit
56f1ac2b72
6 changed files with 57 additions and 30 deletions
|
|
@ -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 = {
|
||||
|
|
|
|||
|
|
@ -27,30 +27,37 @@
|
|||
#include "litest-int.h"
|
||||
#include <assert.h>
|
||||
|
||||
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 = {
|
||||
|
|
|
|||
|
|
@ -27,30 +27,37 @@
|
|||
#include "litest-int.h"
|
||||
#include <assert.h>
|
||||
|
||||
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 = {
|
||||
|
|
|
|||
|
|
@ -27,30 +27,37 @@
|
|||
#include "litest-int.h"
|
||||
#include <assert.h>
|
||||
|
||||
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 = {
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue