Skip to content
  • Peter Hutterer's avatar
    test: add litest helper functions for creating uinput devices · 04d52d71
    Peter Hutterer authored
    
    
    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: default avatarPeter Hutterer <peter.hutterer@who-t.net>
    Reviewed-by: default avatarHans de Goede <hdegoede@redhat.com>
    04d52d71