test: change tablet coords to doubles and pass the pointer through

All other motion/touch/... coords are already doubles so let's follow
suite here. And passing a pointer into the custom handlers
means we can modify x/y slightly and return false, leaving the rest up
to the generic event handling code.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
Peter Hutterer 2023-05-11 13:45:25 +10:00
parent 4bdec007ba
commit 160b062454
5 changed files with 26 additions and 22 deletions

View file

@ -52,7 +52,7 @@ static struct input_event motion_events[] = {
static bool
proximity_in(struct litest_device *d,
unsigned int tool_type,
double x, double y,
double *x, double *y,
struct axis_replacement *axes)
{
/* nothing special needed for the pen tool, so let litest handle
@ -61,10 +61,10 @@ proximity_in(struct litest_device *d,
return false;
/* a non-pen tool requires the pen to be in proximity as well. */
x = litest_scale(d, ABS_X, x);
y = litest_scale(d, ABS_Y, y);
litest_event(d, EV_ABS, ABS_X, x);
litest_event(d, EV_ABS, ABS_X, y);
int sx = litest_scale(d, ABS_X, *x);
int sy = litest_scale(d, ABS_Y, *y);
litest_event(d, EV_ABS, ABS_X, sx);
litest_event(d, EV_ABS, ABS_X, sy);
litest_event(d, EV_KEY, BTN_TOOL_PEN, 1);
litest_event(d, EV_SYN, SYN_REPORT, 0);

View file

@ -76,7 +76,7 @@ get_axis_default(struct litest_device *d, unsigned int evcode, int32_t *value)
static bool prox_in(struct litest_device *d,
unsigned int tool_type,
double x, double y,
double *x, double *y,
struct axis_replacement *axes)
{
struct priv *priv = d->private;
@ -95,7 +95,7 @@ static bool prox_out(struct litest_device *d, unsigned int tool_type)
static bool
tip_down(struct litest_device *d,
int x, int y,
double *x, double *y,
struct axis_replacement *axes)
{
litest_event(d, EV_KEY, BTN_TOOL_PEN, 1);
@ -104,7 +104,7 @@ tip_down(struct litest_device *d,
static bool
tip_up(struct litest_device *d,
int x, int y,
double* x, double *y,
struct axis_replacement *axes)
{
struct priv *priv = d->private;

View file

@ -116,14 +116,14 @@ struct litest_device_interface {
bool (*tablet_proximity_in)(struct litest_device *d,
unsigned int tool_type,
double x, double y,
double *x, double *y,
struct axis_replacement *axes);
bool (*tablet_proximity_out)(struct litest_device *d, unsigned int tool_type);
bool (*tablet_tip_down)(struct litest_device *d,
int x, int y,
double *x, double *y,
struct axis_replacement *axes);
bool (*tablet_tip_up)(struct litest_device *d,
int x, int y,
double *x, double *y,
struct axis_replacement *axes);
/**

View file

@ -2471,14 +2471,16 @@ litest_tool_event(struct litest_device *d, int value)
}
void
litest_tablet_proximity_in(struct litest_device *d, int x, int y, struct axis_replacement *axes)
litest_tablet_proximity_in(struct litest_device *d,
double x, double y,
struct axis_replacement *axes)
{
struct input_event *ev;
/* If the test device overrides proximity_in and says it didn't
* handle the event, let's continue normally */
if (d->interface->tablet_proximity_in &&
d->interface->tablet_proximity_in(d, d->interface->tool_type, x, y, axes))
d->interface->tablet_proximity_in(d, d->interface->tool_type, &x, &y, axes))
return;
ev = d->interface->tablet_proximity_in_events;
@ -2528,7 +2530,9 @@ litest_tablet_proximity_out(struct litest_device *d)
}
void
litest_tablet_motion(struct litest_device *d, int x, int y, struct axis_replacement *axes)
litest_tablet_motion(struct litest_device *d,
double x, double y,
struct axis_replacement *axes)
{
struct input_event *ev;
@ -2543,13 +2547,13 @@ litest_tablet_motion(struct litest_device *d, int x, int y, struct axis_replacem
void
litest_tablet_tip_down(struct litest_device *d,
int x, int y,
double x, double y,
struct axis_replacement *axes)
{
/* If the test device overrides tip_down and says it didn't
* handle the event, let's continue normally */
if (d->interface->tablet_tip_down &&
d->interface->tablet_tip_down(d, x, y, axes))
d->interface->tablet_tip_down(d, &x, &y, axes))
return;
litest_event(d, EV_KEY, BTN_TOUCH, 1);
@ -2558,13 +2562,13 @@ litest_tablet_tip_down(struct litest_device *d,
void
litest_tablet_tip_up(struct litest_device *d,
int x, int y,
double x, double y,
struct axis_replacement *axes)
{
/* If the test device overrides tip_down and says it didn't
* handle the event, let's continue normally */
if (d->interface->tablet_tip_up &&
d->interface->tablet_tip_up(d, x, y, axes))
d->interface->tablet_tip_up(d, &x, &y, axes))
return;
litest_event(d, EV_KEY, BTN_TOUCH, 0);

View file

@ -631,7 +631,7 @@ litest_tablet_set_tool_type(struct litest_device *d,
void
litest_tablet_proximity_in(struct litest_device *d,
int x, int y,
double x, double y,
struct axis_replacement *axes);
void
@ -639,17 +639,17 @@ litest_tablet_proximity_out(struct litest_device *d);
void
litest_tablet_tip_down(struct litest_device *d,
int x, int y,
double x, double y,
struct axis_replacement *axes);
void
litest_tablet_tip_up(struct litest_device *d,
int x, int y,
double x, double y,
struct axis_replacement *axes);
void
litest_tablet_motion(struct litest_device *d,
int x, int y,
double x, double y,
struct axis_replacement *axes);
void