From 8dfdf6b76fcaf88a88dd3e2b9ad9a0c0e3f9794d Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Thu, 19 Jan 2017 17:35:04 +1000 Subject: [PATCH] test: switch the semi-mt devices to use the litest semi-mt handling Signed-off-by: Peter Hutterer --- test/litest-device-alps-dualpoint.c | 66 ++++++++++----------------- test/litest-device-alps-semi-mt.c | 66 ++++++++++----------------- test/litest-device-synaptics-hover.c | 68 ++++++++++------------------ 3 files changed, 69 insertions(+), 131 deletions(-) diff --git a/test/litest-device-alps-dualpoint.c b/test/litest-device-alps-dualpoint.c index fe8cf967..de025e59 100644 --- a/test/litest-device-alps-dualpoint.c +++ b/test/litest-device-alps-dualpoint.c @@ -30,8 +30,6 @@ #include "litest.h" #include "litest-int.h" -static void alps_dualpoint_create(struct litest_device *d); - static void litest_alps_dualpoint_setup(void) { @@ -39,34 +37,32 @@ litest_alps_dualpoint_setup(void) litest_set_current_device(d); } -static void -alps_dualpoint_touch_down(struct litest_device *d, unsigned int slot, double x, double y) -{ - struct litest_semi_mt *semi_mt = d->private; +static struct input_event down[] = { + { .type = EV_ABS, .code = ABS_X, .value = LITEST_AUTO_ASSIGN }, + { .type = EV_ABS, .code = ABS_Y, .value = LITEST_AUTO_ASSIGN }, + { .type = EV_ABS, .code = ABS_PRESSURE, .value = LITEST_AUTO_ASSIGN }, + { .type = EV_ABS, .code = ABS_MT_SLOT, .value = LITEST_AUTO_ASSIGN }, + { .type = EV_ABS, .code = ABS_MT_TRACKING_ID, .value = LITEST_AUTO_ASSIGN }, + { .type = EV_ABS, .code = ABS_MT_POSITION_X, .value = LITEST_AUTO_ASSIGN }, + { .type = EV_ABS, .code = ABS_MT_POSITION_Y, .value = LITEST_AUTO_ASSIGN }, + { .type = EV_SYN, .code = SYN_REPORT, .value = 0 }, + { .type = -1, .code = -1 }, +}; - litest_semi_mt_touch_down(d, semi_mt, slot, x, y); -} - -static void -alps_dualpoint_touch_move(struct litest_device *d, unsigned int slot, double x, double y) -{ - struct litest_semi_mt *semi_mt = d->private; - - litest_semi_mt_touch_move(d, semi_mt, slot, x, y); -} - -static void -alps_dualpoint_touch_up(struct litest_device *d, unsigned int slot) -{ - struct litest_semi_mt *semi_mt = d->private; - - litest_semi_mt_touch_up(d, semi_mt, slot); -} +static struct input_event move[] = { + { .type = EV_ABS, .code = ABS_MT_SLOT, .value = LITEST_AUTO_ASSIGN }, + { .type = EV_ABS, .code = ABS_X, .value = LITEST_AUTO_ASSIGN }, + { .type = EV_ABS, .code = ABS_Y, .value = LITEST_AUTO_ASSIGN }, + { .type = EV_ABS, .code = ABS_PRESSURE, .value = LITEST_AUTO_ASSIGN }, + { .type = EV_ABS, .code = ABS_MT_POSITION_X, .value = LITEST_AUTO_ASSIGN }, + { .type = EV_ABS, .code = ABS_MT_POSITION_Y, .value = LITEST_AUTO_ASSIGN }, + { .type = EV_SYN, .code = SYN_REPORT, .value = 0 }, + { .type = -1, .code = -1 }, +}; static struct litest_device_interface interface = { - .touch_down = alps_dualpoint_touch_down, - .touch_move = alps_dualpoint_touch_move, - .touch_up = alps_dualpoint_touch_up, + .touch_down_events = down, + .touch_move_events = move, }; static struct input_id input_id = { @@ -116,7 +112,6 @@ struct litest_test_device litest_alps_dualpoint_device = { .shortname = "alps dualpoint", .setup = litest_alps_dualpoint_setup, .interface = &interface, - .create = alps_dualpoint_create, .name = "AlpsPS/2 ALPS DualPoint TouchPad", .id = &input_id, @@ -124,18 +119,3 @@ struct litest_test_device litest_alps_dualpoint_device = { .absinfo = absinfo, .udev_rule = udev_rule, }; - -static void -alps_dualpoint_create(struct litest_device *d) -{ - struct litest_semi_mt *semi_mt = zalloc(sizeof(*semi_mt)); - assert(semi_mt); - - d->private = semi_mt; - - d->uinput = litest_create_uinput_device_from_description(litest_alps_dualpoint_device.name, - litest_alps_dualpoint_device.id, - absinfo, - events); - d->interface = &interface; -} diff --git a/test/litest-device-alps-semi-mt.c b/test/litest-device-alps-semi-mt.c index 7325a429..d78adcab 100644 --- a/test/litest-device-alps-semi-mt.c +++ b/test/litest-device-alps-semi-mt.c @@ -30,8 +30,6 @@ #include "litest.h" #include "litest-int.h" -static void alps_create(struct litest_device *d); - static void litest_alps_setup(void) { @@ -39,34 +37,32 @@ litest_alps_setup(void) litest_set_current_device(d); } -static void -alps_touch_down(struct litest_device *d, unsigned int slot, double x, double y) -{ - struct litest_semi_mt *semi_mt = d->private; +static struct input_event down[] = { + { .type = EV_ABS, .code = ABS_X, .value = LITEST_AUTO_ASSIGN }, + { .type = EV_ABS, .code = ABS_Y, .value = LITEST_AUTO_ASSIGN }, + { .type = EV_ABS, .code = ABS_PRESSURE, .value = LITEST_AUTO_ASSIGN }, + { .type = EV_ABS, .code = ABS_MT_SLOT, .value = LITEST_AUTO_ASSIGN }, + { .type = EV_ABS, .code = ABS_MT_TRACKING_ID, .value = LITEST_AUTO_ASSIGN }, + { .type = EV_ABS, .code = ABS_MT_POSITION_X, .value = LITEST_AUTO_ASSIGN }, + { .type = EV_ABS, .code = ABS_MT_POSITION_Y, .value = LITEST_AUTO_ASSIGN }, + { .type = EV_SYN, .code = SYN_REPORT, .value = 0 }, + { .type = -1, .code = -1 }, +}; - litest_semi_mt_touch_down(d, semi_mt, slot, x, y); -} - -static void -alps_touch_move(struct litest_device *d, unsigned int slot, double x, double y) -{ - struct litest_semi_mt *semi_mt = d->private; - - litest_semi_mt_touch_move(d, semi_mt, slot, x, y); -} - -static void -alps_touch_up(struct litest_device *d, unsigned int slot) -{ - struct litest_semi_mt *semi_mt = d->private; - - litest_semi_mt_touch_up(d, semi_mt, slot); -} +static struct input_event move[] = { + { .type = EV_ABS, .code = ABS_MT_SLOT, .value = LITEST_AUTO_ASSIGN }, + { .type = EV_ABS, .code = ABS_X, .value = LITEST_AUTO_ASSIGN }, + { .type = EV_ABS, .code = ABS_Y, .value = LITEST_AUTO_ASSIGN }, + { .type = EV_ABS, .code = ABS_PRESSURE, .value = LITEST_AUTO_ASSIGN }, + { .type = EV_ABS, .code = ABS_MT_POSITION_X, .value = LITEST_AUTO_ASSIGN }, + { .type = EV_ABS, .code = ABS_MT_POSITION_Y, .value = LITEST_AUTO_ASSIGN }, + { .type = EV_SYN, .code = SYN_REPORT, .value = 0 }, + { .type = -1, .code = -1 }, +}; static struct litest_device_interface interface = { - .touch_down = alps_touch_down, - .touch_move = alps_touch_move, - .touch_up = alps_touch_up, + .touch_down_events = down, + .touch_move_events = move, }; static struct input_id input_id = { @@ -106,25 +102,9 @@ struct litest_test_device litest_alps_device = { .shortname = "alps semi-mt", .setup = litest_alps_setup, .interface = &interface, - .create = alps_create, .name = "AlpsPS/2 ALPS GlidePoint", .id = &input_id, .events = events, .absinfo = absinfo, }; - -static void -alps_create(struct litest_device *d) -{ - struct litest_semi_mt *semi_mt = zalloc(sizeof(*semi_mt)); - assert(semi_mt); - - d->private = semi_mt; - - d->uinput = litest_create_uinput_device_from_description(litest_alps_device.name, - litest_alps_device.id, - absinfo, - events); - d->interface = &interface; -} diff --git a/test/litest-device-synaptics-hover.c b/test/litest-device-synaptics-hover.c index 6184ff63..8439f10f 100644 --- a/test/litest-device-synaptics-hover.c +++ b/test/litest-device-synaptics-hover.c @@ -30,9 +30,6 @@ #include "litest.h" #include "litest-int.h" -static void -synaptics_hover_create(struct litest_device *d); - static void litest_synaptics_hover_setup(void) { @@ -40,34 +37,32 @@ litest_synaptics_hover_setup(void) litest_set_current_device(d); } -static void -synaptics_hover_touch_down(struct litest_device *d, unsigned int slot, double x, double y) -{ - struct litest_semi_mt *semi_mt = d->private; +static struct input_event down[] = { + { .type = EV_ABS, .code = ABS_X, .value = LITEST_AUTO_ASSIGN }, + { .type = EV_ABS, .code = ABS_Y, .value = LITEST_AUTO_ASSIGN }, + { .type = EV_ABS, .code = ABS_PRESSURE, .value = LITEST_AUTO_ASSIGN }, + { .type = EV_ABS, .code = ABS_MT_SLOT, .value = LITEST_AUTO_ASSIGN }, + { .type = EV_ABS, .code = ABS_MT_TRACKING_ID, .value = LITEST_AUTO_ASSIGN }, + { .type = EV_ABS, .code = ABS_MT_POSITION_X, .value = LITEST_AUTO_ASSIGN }, + { .type = EV_ABS, .code = ABS_MT_POSITION_Y, .value = LITEST_AUTO_ASSIGN }, + { .type = EV_SYN, .code = SYN_REPORT, .value = 0 }, + { .type = -1, .code = -1 }, +}; - litest_semi_mt_touch_down(d, semi_mt, slot, x, y); -} - -static void -synaptics_hover_touch_move(struct litest_device *d, unsigned int slot, double x, double y) -{ - struct litest_semi_mt *semi_mt = d->private; - - litest_semi_mt_touch_move(d, semi_mt, slot, x, y); -} - -static void -synaptics_hover_touch_up(struct litest_device *d, unsigned int slot) -{ - struct litest_semi_mt *semi_mt = d->private; - - litest_semi_mt_touch_up(d, semi_mt, slot); -} +static struct input_event move[] = { + { .type = EV_ABS, .code = ABS_MT_SLOT, .value = LITEST_AUTO_ASSIGN }, + { .type = EV_ABS, .code = ABS_X, .value = LITEST_AUTO_ASSIGN }, + { .type = EV_ABS, .code = ABS_Y, .value = LITEST_AUTO_ASSIGN }, + { .type = EV_ABS, .code = ABS_PRESSURE, .value = LITEST_AUTO_ASSIGN }, + { .type = EV_ABS, .code = ABS_MT_POSITION_X, .value = LITEST_AUTO_ASSIGN }, + { .type = EV_ABS, .code = ABS_MT_POSITION_Y, .value = LITEST_AUTO_ASSIGN }, + { .type = EV_SYN, .code = SYN_REPORT, .value = 0 }, + { .type = -1, .code = -1 }, +}; static struct litest_device_interface interface = { - .touch_down = synaptics_hover_touch_down, - .touch_move = synaptics_hover_touch_move, - .touch_up = synaptics_hover_touch_up, + .touch_down_events = down, + .touch_move_events = move, }; static struct input_id input_id = { @@ -115,7 +110,6 @@ struct litest_test_device litest_synaptics_hover_device = { .shortname = "synaptics hover", .setup = litest_synaptics_hover_setup, .interface = &interface, - .create = synaptics_hover_create, .name = "SynPS/2 Synaptics TouchPad", .id = &input_id, @@ -123,19 +117,3 @@ struct litest_test_device litest_synaptics_hover_device = { .absinfo = absinfo, .udev_rule = udev_rule, }; - -static void -synaptics_hover_create(struct litest_device *d) -{ - struct litest_semi_mt *semi_mt = zalloc(sizeof(*semi_mt)); - assert(semi_mt); - - d->private = semi_mt; - - d->uinput = litest_create_uinput_device_from_description( - litest_synaptics_hover_device.name, - litest_synaptics_hover_device.id, - absinfo, - events); - d->interface = &interface; -}