[PATCH libinput v3 1/5] litest: add axis_replacement from tablet branch
Andreas Pokorny
andreas.pokorny at canonical.com
Mon Jun 22 03:48:04 PDT 2015
This change adds strict axis_replacemnt and litest_touch_move_extended
and litest_touch_down_extended to simulate changes to other axes during
touch down and move events.
Signed-off-by: Andreas Pokorny <andreas.pokorny at canonical.com>
---
test/litest.c | 95 +++++++++++++++++++++++++++++++++++++++++++++++------------
test/litest.h | 16 ++++++++++
2 files changed, 92 insertions(+), 19 deletions(-)
diff --git a/test/litest.c b/test/litest.c
index 82df550..f47ae89 100644
--- a/test/litest.c
+++ b/test/litest.c
@@ -1234,10 +1234,26 @@ litest_event(struct litest_device *d, unsigned int type,
litest_assert_int_eq(ret, 0);
}
+static int32_t
+axis_replacement_value(struct axis_replacement *axes,
+ int32_t evcode)
+{
+ struct axis_replacement *axis = axes;
+
+ while (axis->evcode != -1) {
+ if (axis->evcode == evcode)
+ return axis->value;
+ axis++;
+ }
+
+ return -1;
+}
+
int
litest_auto_assign_value(struct litest_device *d,
const struct input_event *ev,
int slot, double x, double y,
+ struct axis_replacement *axes,
bool touching)
{
static int tracking_id;
@@ -1264,6 +1280,10 @@ litest_auto_assign_value(struct litest_device *d,
case ABS_MT_DISTANCE:
value = touching ? 0 : 1;
break;
+ default:
+ if (axes)
+ value = axis_replacement_value(axes, ev->code);
+ break;
}
return value;
@@ -1281,8 +1301,12 @@ send_btntool(struct litest_device *d)
}
static void
-litest_slot_start(struct litest_device *d, unsigned int slot,
- double x, double y, bool touching)
+litest_slot_start(struct litest_device *d,
+ unsigned int slot,
+ double x,
+ double y,
+ struct axis_replacement *axes,
+ bool touching)
{
struct input_event *ev;
@@ -1303,6 +1327,7 @@ litest_slot_start(struct litest_device *d, unsigned int slot,
slot,
x,
y,
+ axes,
touching);
litest_event(d, ev->type, ev->code, value);
@@ -1311,10 +1336,22 @@ litest_slot_start(struct litest_device *d, unsigned int slot,
}
void
-litest_touch_down(struct litest_device *d, unsigned int slot,
- double x, double y)
+litest_touch_down(struct litest_device *d,
+ unsigned int slot,
+ double x,
+ double y)
{
- litest_slot_start(d, slot, x, y, 1);
+ litest_slot_start(d, slot, x, y, NULL, true);
+}
+
+void
+litest_touch_down_extended(struct litest_device *d,
+ unsigned int slot,
+ double x,
+ double y,
+ struct axis_replacement *axes)
+{
+ litest_slot_start(d, slot, x, y, axes, true);
}
void
@@ -1347,6 +1384,7 @@ litest_touch_up(struct litest_device *d, unsigned int slot)
slot,
0,
0,
+ NULL,
false);
litest_event(d, ev->type, ev->code, value);
ev++;
@@ -1354,8 +1392,12 @@ litest_touch_up(struct litest_device *d, unsigned int slot)
}
static void
-litest_slot_move(struct litest_device *d, unsigned int slot,
- double x, double y, bool touching)
+litest_slot_move(struct litest_device *d,
+ unsigned int slot,
+ double x,
+ double y,
+ struct axis_replacement *axes,
+ bool touching)
{
struct input_event *ev;
@@ -1371,6 +1413,7 @@ litest_slot_move(struct litest_device *d, unsigned int slot,
slot,
x,
y,
+ axes,
touching);
litest_event(d, ev->type, ev->code, value);
ev++;
@@ -1378,10 +1421,22 @@ litest_slot_move(struct litest_device *d, unsigned int slot,
}
void
-litest_touch_move(struct litest_device *d, unsigned int slot,
- double x, double y)
+litest_touch_move(struct litest_device *d,
+ unsigned int slot,
+ double x,
+ double y)
+{
+ litest_slot_move(d, slot, x, y, NULL, true);
+}
+
+void
+litest_touch_move_extended(struct litest_device *d,
+ unsigned int slot,
+ double x,
+ double y,
+ struct axis_replacement *axes)
{
- litest_slot_move(d, slot, x, y, true);
+ litest_slot_move(d, slot, x, y, axes, true);
}
void
@@ -1427,10 +1482,12 @@ litest_touch_move_two_touches(struct litest_device *d,
}
void
-litest_hover_start(struct litest_device *d, unsigned int slot,
- double x, double y)
+litest_hover_start(struct litest_device *d,
+ unsigned int slot,
+ double x,
+ double y)
{
- litest_slot_start(d, slot, x, y, 0);
+ litest_slot_start(d, slot, x, y, NULL, 0);
}
void
@@ -1459,7 +1516,7 @@ litest_hover_end(struct litest_device *d, unsigned int slot)
ev = up;
while (ev && (int16_t)ev->type != -1 && (int16_t)ev->code != -1) {
- int value = litest_auto_assign_value(d, ev, slot, 0, 0, 0);
+ int value = litest_auto_assign_value(d, ev, slot, 0, 0, NULL, false);
litest_event(d, ev->type, ev->code, value);
ev++;
}
@@ -1469,7 +1526,7 @@ void
litest_hover_move(struct litest_device *d, unsigned int slot,
double x, double y)
{
- litest_slot_move(d, slot, x, y, false);
+ litest_slot_move(d, slot, x, y, NULL, false);
}
void
@@ -2154,11 +2211,11 @@ send_abs_xy(struct litest_device *d, double x, double y)
e.type = EV_ABS;
e.code = ABS_X;
e.value = LITEST_AUTO_ASSIGN;
- val = litest_auto_assign_value(d, &e, 0, x, y, true);
+ val = litest_auto_assign_value(d, &e, 0, x, y, NULL, true);
litest_event(d, EV_ABS, ABS_X, val);
e.code = ABS_Y;
- val = litest_auto_assign_value(d, &e, 0, x, y, true);
+ val = litest_auto_assign_value(d, &e, 0, x, y, NULL, true);
litest_event(d, EV_ABS, ABS_Y, val);
}
@@ -2171,12 +2228,12 @@ send_abs_mt_xy(struct litest_device *d, double x, double y)
e.type = EV_ABS;
e.code = ABS_MT_POSITION_X;
e.value = LITEST_AUTO_ASSIGN;
- val = litest_auto_assign_value(d, &e, 0, x, y, true);
+ val = litest_auto_assign_value(d, &e, 0, x, y, NULL, true);
litest_event(d, EV_ABS, ABS_MT_POSITION_X, val);
e.code = ABS_MT_POSITION_Y;
e.value = LITEST_AUTO_ASSIGN;
- val = litest_auto_assign_value(d, &e, 0, x, y, true);
+ val = litest_auto_assign_value(d, &e, 0, x, y, NULL, true);
litest_event(d, EV_ABS, ABS_MT_POSITION_Y, val);
}
diff --git a/test/litest.h b/test/litest.h
index b08ac40..583eae4 100644
--- a/test/litest.h
+++ b/test/litest.h
@@ -176,6 +176,11 @@ struct litest_device {
char *udev_rule_file;
};
+struct axis_replacement {
+ int32_t evcode;
+ int32_t value;
+};
+
/* A loop range, resolves to:
for (i = lower; i < upper; i++)
*/
@@ -284,16 +289,27 @@ void litest_event(struct litest_device *t,
int litest_auto_assign_value(struct litest_device *d,
const struct input_event *ev,
int slot, double x, double y,
+ struct axis_replacement *axes,
bool touching);
void litest_touch_up(struct litest_device *d, unsigned int slot);
void litest_touch_move(struct litest_device *d,
unsigned int slot,
double x,
double y);
+void litest_touch_move_extended(struct litest_device *d,
+ unsigned int slot,
+ double x,
+ double y,
+ struct axis_replacement *axes);
void litest_touch_down(struct litest_device *d,
unsigned int slot,
double x,
double y);
+void litest_touch_down_extended(struct litest_device *d,
+ unsigned int slot,
+ double x,
+ double y,
+ struct axis_replacement *axes);
void litest_touch_move_to(struct litest_device *d,
unsigned int slot,
double x_from, double y_from,
--
2.1.4
More information about the wayland-devel
mailing list