summaryrefslogtreecommitdiff
path: root/test/litest-synaptics-st.c
diff options
context:
space:
mode:
authorPeter Hutterer <peter.hutterer@who-t.net>2014-03-26 20:09:42 +1000
committerPeter Hutterer <peter.hutterer@who-t.net>2014-04-08 15:07:02 +1000
commit04d52d718fa71992212cc70d11d0cab06579b2a5 (patch)
treec6b2e3861caa7da9b7e2ee8b9a59b52e2cef3747 /test/litest-synaptics-st.c
parent32e513226cea7c55f379d98460562c845405d97c (diff)
downloadlibinput-04d52d718fa71992212cc70d11d0cab06579b2a5.tar.gz
test: add litest helper functions for creating uinput devices
Both functions accept a series of event types/codes tuples, terminated by -1. For the even type INPUT_PROP_MAX (an invalid type otherwise) the code is used as a property to enable. The _abs function als takes an array of absinfo, with absinfo.value determining the axis to change. If none are given, abs axes are initialized with default settings. Both functions abort on failure, so the caller does not need to check the return value. Example code for creating a rel device: struct libevdev_uinput *uinput; struct input_id id = { ... }; uinput = litest_create_uinput_device("foo", &id, EV_REL, REL_X, EV_REL, REL_Y, EV_KEY, BTN_LEFT, INPUT_PROP_MAX, INPUT_PROP_BUTTONPAD, -1); libevdev_uinput_write_event(uinput, EV_REL, REL_X, -1); libevdev_uinput_write_event(uinput, EV_SYN, SYN_REPORT, 0); ... libevdev_uinput_destroy(uinput); Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Diffstat (limited to 'test/litest-synaptics-st.c')
-rw-r--r--test/litest-synaptics-st.c37
1 files changed, 13 insertions, 24 deletions
diff --git a/test/litest-synaptics-st.c b/test/litest-synaptics-st.c
index 2c7d371f..d13d9a2e 100644
--- a/test/litest-synaptics-st.c
+++ b/test/litest-synaptics-st.c
@@ -98,38 +98,27 @@ static struct litest_device_interface interface = {
void
litest_create_synaptics_touchpad(struct litest_device *d)
{
- struct libevdev *dev;
struct input_absinfo abs[] = {
{ ABS_X, 1472, 5472, 75 },
{ ABS_Y, 1408, 4448, 129 },
{ ABS_PRESSURE, 0, 255, 0 },
{ ABS_TOOL_WIDTH, 0, 15, 0 },
+ { .value = -1 },
+ };
+ struct input_id id = {
+ .bustype = 0x11,
+ .vendor = 0x2,
+ .product = 0x7,
};
- struct input_absinfo *a;
- int rc;
d->interface = &interface;
-
- dev = libevdev_new();
- ck_assert(dev != NULL);
-
- libevdev_set_name(dev, "SynPS/2 Synaptics TouchPad");
- libevdev_set_id_bustype(dev, 0x11);
- libevdev_set_id_vendor(dev, 0x2);
- libevdev_set_id_product(dev, 0x7);
- libevdev_enable_event_code(dev, EV_KEY, BTN_LEFT, NULL);
- libevdev_enable_event_code(dev, EV_KEY, BTN_RIGHT, NULL);
- libevdev_enable_event_code(dev, EV_KEY, BTN_TOOL_FINGER, NULL);
- libevdev_enable_event_code(dev, EV_KEY, BTN_TOUCH, NULL);
-
- ARRAY_FOR_EACH(abs, a)
- libevdev_enable_event_code(dev, EV_ABS, a->value, a);
-
- rc = libevdev_uinput_create_from_device(dev,
- LIBEVDEV_UINPUT_OPEN_MANAGED,
- &d->uinput);
- ck_assert_int_eq(rc, 0);
- libevdev_free(dev);
+ d->uinput = litest_create_uinput_abs_device("SynPS/2 Synaptics TouchPad", &id,
+ abs,
+ EV_KEY, BTN_LEFT,
+ EV_KEY, BTN_RIGHT,
+ EV_KEY, BTN_TOOL_FINGER,
+ EV_KEY, BTN_TOUCH,
+ -1, -1);
}
struct litest_test_device litest_synaptics_touchpad_device = {