The optional axis_replacement provides additional replacement values for touch down and touch move litest functions.
Signed-off-by: Andreas Pokorny <andreas.poko...@canonical.com> --- test/litest.c | 59 ++++++++++++++++++++++++++++++++++++++++++++++++----------- test/litest.h | 16 ++++++++++++++++ 2 files changed, 64 insertions(+), 11 deletions(-) diff --git a/test/litest.c b/test/litest.c index 591c02a..2d4a37a 100644 --- a/test/litest.c +++ b/test/litest.c @@ -1226,10 +1226,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; @@ -1256,6 +1272,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; @@ -1274,7 +1294,7 @@ send_btntool(struct litest_device *d) static void litest_slot_start(struct litest_device *d, unsigned int slot, - double x, double y, bool touching) + double x, double y, struct axis_replacement *axes, bool touching) { struct input_event *ev; @@ -1295,6 +1315,7 @@ litest_slot_start(struct litest_device *d, unsigned int slot, slot, x, y, + axes, touching); litest_event(d, ev->type, ev->code, value); @@ -1306,7 +1327,14 @@ void 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 @@ -1339,6 +1367,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++; @@ -1347,7 +1376,7 @@ 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) + double x, double y, struct axis_replacement *axes, bool touching) { struct input_event *ev; @@ -1363,6 +1392,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++; @@ -1373,7 +1403,14 @@ void litest_touch_move(struct litest_device *d, unsigned int slot, double x, double y) { - litest_slot_move(d, slot, x, y, true); + 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, axes, true); } void @@ -1422,7 +1459,7 @@ void 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 @@ -1451,7 +1488,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++; } @@ -1461,7 +1498,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 @@ -2146,11 +2183,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); } @@ -2163,12 +2200,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 e49cd0c..3c4c88a 100644 --- a/test/litest.h +++ b/test/litest.h @@ -175,6 +175,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++) */ @@ -283,16 +288,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 _______________________________________________ wayland-devel mailing list wayland-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/wayland-devel