struct uinput_device* uidev;
struct libevdev *dev;
int rc;
- int fd;
struct input_event ev;
- rc = uinput_device_new_with_events(&uidev, "test device", DEFAULT_IDS,
- EV_REL, REL_X,
- EV_REL, REL_Y,
- EV_KEY, BTN_LEFT,
- -1);
- ck_assert_msg(rc == 0, "Failed to create uinput device: %s", strerror(-rc));
-
- fd = uinput_device_get_fd(uidev);
- rc = fcntl(fd, F_SETFL, O_NONBLOCK);
- ck_assert_int_eq(rc, 0);
- rc = libevdev_new_from_fd(fd, &dev);
- ck_assert_msg(rc == 0, "Failed to init device: %s", strerror(-rc));;
+ rc = test_create_device(&uidev, &dev,
+ EV_REL, REL_X,
+ EV_REL, REL_Y,
+ EV_KEY, BTN_LEFT,
+ -1);
+ ck_assert_msg(rc == 0, "Failed to create device: %s", strerror(-rc));
rc = libevdev_next_event(dev, LIBEVDEV_READ_NORMAL, &ev);
ck_assert_int_eq(rc, -EAGAIN);
struct uinput_device* uidev;
struct libevdev *dev;
int rc;
- int fd;
struct input_event ev;
int pipefd[2];
- rc = uinput_device_new_with_events(&uidev, "test device", DEFAULT_IDS,
- EV_SYN, SYN_REPORT,
- EV_SYN, SYN_DROPPED,
- EV_REL, REL_X,
- EV_REL, REL_Y,
- EV_KEY, BTN_LEFT,
- -1);
- ck_assert_msg(rc == 0, "Failed to create uinput device: %s", strerror(-rc));
-
- fd = uinput_device_get_fd(uidev);
- rc = fcntl(fd, F_SETFL, O_NONBLOCK);
- ck_assert_int_eq(rc, 0);
- rc = libevdev_new_from_fd(fd, &dev);
- ck_assert_msg(rc == 0, "Failed to init device: %s", strerror(-rc));;
+ rc = test_create_device(&uidev, &dev,
+ EV_SYN, SYN_REPORT,
+ EV_SYN, SYN_DROPPED,
+ EV_REL, REL_X,
+ EV_REL, REL_Y,
+ EV_KEY, BTN_LEFT,
+ -1);
+ ck_assert_msg(rc == 0, "Failed to create device: %s", strerror(-rc));
/* This is a bid complicated:
we can't get SYN_DROPPED through uinput, so we push two events down
ck_assert_int_eq(rc, sizeof(ev));
rc = libevdev_next_event(dev, LIBEVDEV_READ_NORMAL, &ev);
- libevdev_change_fd(dev, fd);
+ libevdev_change_fd(dev, uinput_device_get_fd(uidev));
ck_assert_int_eq(rc, 0);
ck_assert_int_eq(ev.type, EV_SYN);
struct uinput_device* uidev;
struct libevdev *dev;
int rc;
- int fd;
struct input_event ev;
- rc = uinput_device_new_with_events(&uidev, "test device", DEFAULT_IDS,
- EV_SYN, SYN_REPORT,
- EV_SYN, SYN_DROPPED,
- EV_REL, REL_X,
- EV_REL, REL_Y,
- EV_KEY, BTN_LEFT,
- EV_KEY, BTN_MIDDLE,
- EV_KEY, BTN_RIGHT,
- -1);
- ck_assert_msg(rc == 0, "Failed to create uinput device: %s", strerror(-rc));
-
- fd = uinput_device_get_fd(uidev);
- rc = fcntl(fd, F_SETFL, O_NONBLOCK);
- ck_assert_int_eq(rc, 0);
- rc = libevdev_new_from_fd(fd, &dev);
- ck_assert_msg(rc == 0, "Failed to init device: %s", strerror(-rc));;
+ rc = test_create_device(&uidev, &dev,
+ EV_SYN, SYN_REPORT,
+ EV_SYN, SYN_DROPPED,
+ EV_REL, REL_X,
+ EV_REL, REL_Y,
+ EV_KEY, BTN_LEFT,
+ EV_KEY, BTN_MIDDLE,
+ EV_KEY, BTN_RIGHT,
+ -1);
+ ck_assert_msg(rc == 0, "Failed to create device: %s", strerror(-rc));
uinput_device_event(uidev, EV_KEY, BTN_LEFT, 1);
uinput_device_event(uidev, EV_KEY, BTN_RIGHT, 1);
struct libevdev *dev;
int i, rc;
- rc = uinput_device_new_with_events(&uidev, "test device", DEFAULT_IDS,
- *evbit, 0,
- -1);
- ck_assert_msg(rc == 0, "%s: Failed to create uinput device with: %s",
- libevdev_get_event_type_name(*evbit),
- strerror(-rc));
- rc = libevdev_new_from_fd(uinput_device_get_fd(uidev), &dev);
- ck_assert_msg(rc == 0, "%s: Failed to init device: %s",
+ rc = test_create_device(&uidev, &dev,
+ *evbit, 0,
+ -1);
+ ck_assert_msg(rc == 0, "%s: Failed to create device with: %s",
libevdev_get_event_type_name(*evbit),
strerror(-rc));
struct libevdev *dev;
int rc;
- rc = uinput_device_new_with_events(&uidev, "test device", DEFAULT_IDS,
- *evbit, 0,
- -1);
- ck_assert_msg(rc == 0, "Failed to create uinput device: %s", strerror(-rc));
- rc = libevdev_new_from_fd(uinput_device_get_fd(uidev), &dev);
- ck_assert_msg(rc == 0, "Failed to init device: %s", strerror(-rc));;
+ rc = test_create_device(&uidev, &dev,
+ *evbit, 0,
+ -1);
+ ck_assert_msg(rc == 0, "Failed to create device: %s", strerror(-rc));
ck_assert_int_eq(libevdev_has_event_type(dev, EV_MAX + 1), 0);
ck_assert_int_eq(libevdev_has_event_type(dev, INT_MAX), 0);
max = libevdev_get_event_type_max(*evbit);
for (code = 1; code < max; code += 10) {
- rc = uinput_device_new_with_events(&uidev, "test device", DEFAULT_IDS,
- *evbit, code,
- -1);
- ck_assert_msg(rc == 0, "Failed to create uinput device: %s", strerror(-rc));
- rc = libevdev_new_from_fd(uinput_device_get_fd(uidev), &dev);
- ck_assert_msg(rc == 0, "Failed to init device: %s", strerror(-rc));;
+ rc = test_create_device(&uidev, &dev,
+ *evbit, code,
+ -1);
+ ck_assert_msg(rc == 0, "Failed to create device: %s", strerror(-rc));
ck_assert_msg(libevdev_has_event_type(dev, *evbit), "for event type %d\n", *evbit);
ck_assert_msg(libevdev_has_event_code(dev, *evbit, code), "for type %d code %d", *evbit, code);
max = libevdev_get_event_type_max(*evbit);
ck_assert(max != -1);
- rc = uinput_device_new_with_events(&uidev, "test device", DEFAULT_IDS,
- *evbit, 1,
- -1);
- ck_assert_msg(rc == 0, "Failed to create uinput device: %s", strerror(-rc));
- rc = libevdev_new_from_fd(uinput_device_get_fd(uidev), &dev);
- ck_assert_msg(rc == 0, "Failed to init device: %s", strerror(-rc));;
+ rc = test_create_device(&uidev, &dev,
+ *evbit, 1,
+ -1);
+ ck_assert_msg(rc == 0, "Failed to create device: %s", strerror(-rc));
ck_assert_msg(!libevdev_has_event_code(dev, *evbit, max), "for type %d code %d", *evbit, max);
ck_assert_msg(!libevdev_has_event_code(dev, *evbit, INT_MAX), "for type %d code %d", *evbit, INT_MAX);
/* EV_REP is special, it's always fully set if set at all, can't set
it through uinput though. */
- rc = uinput_device_new_with_events(&uidev, "test device", DEFAULT_IDS,
- -1);
- ck_assert_msg(rc == 0, "Failed to create uinput device: %s", strerror(-rc));
- rc = libevdev_new_from_fd(uinput_device_get_fd(uidev), &dev);
- ck_assert_msg(rc == 0, "Failed to init device: %s", strerror(-rc));;
+ rc = test_create_device(&uidev, &dev, -1);
+ ck_assert_msg(rc == 0, "Failed to create device: %s", strerror(-rc));
ck_assert_int_eq(libevdev_get_repeat(dev, NULL, NULL), -1);
ck_assert_int_eq(libevdev_get_repeat(dev, &delay, NULL), -1);
struct libevdev *dev;
int rc;
- rc = uinput_device_new_with_events(&uidev, "test device", DEFAULT_IDS,
- EV_ABS, ABS_X,
- -1);
- ck_assert_msg(rc == 0, "Failed to create uinput device: %s", strerror(-rc));
- rc = libevdev_new_from_fd(uinput_device_get_fd(uidev), &dev);
- ck_assert_msg(rc == 0, "Failed to init device: %s", strerror(-rc));;
+ rc = test_create_device(&uidev, &dev,
+ EV_ABS, ABS_X,
+ -1);
+ ck_assert_msg(rc == 0, "Failed to create device: %s", strerror(-rc));
ck_assert_int_eq(libevdev_has_property(dev, INPUT_PROP_MAX + 1), 0);
ck_assert_int_eq(libevdev_has_property(dev, INPUT_PROP_MAX), 0);
ck_assert(str != NULL);
ck_assert_int_eq(strlen(str), 0);
- rc = uinput_device_new_with_events(&uidev, "test device", DEFAULT_IDS,
- EV_ABS, ABS_X,
- EV_ABS, ABS_Y,
- EV_ABS, ABS_MT_POSITION_X,
- EV_ABS, ABS_MT_POSITION_Y,
- -1);
- ck_assert_msg(rc == 0, "Failed to create uinput device: %s", strerror(-rc));
- rc = libevdev_set_fd(dev, uinput_device_get_fd(uidev));
- ck_assert_msg(rc == 0, "Failed to init device: %s", strerror(-rc));;
+ rc = test_create_device(&uidev, &dev,
+ EV_ABS, ABS_X,
+ EV_ABS, ABS_Y,
+ EV_ABS, ABS_MT_POSITION_X,
+ EV_ABS, ABS_MT_POSITION_Y,
+ -1);
+ ck_assert_msg(rc == 0, "Failed to create device: %s", strerror(-rc));
ck_assert_int_eq(libevdev_get_num_slots(dev), -1);
ck_assert_int_eq(libevdev_get_current_slot(dev), -1);
ck_assert(str != NULL);
ck_assert_int_eq(strlen(str), 0);
- rc = uinput_device_new_with_events(&uidev, "test device", DEFAULT_IDS,
- EV_ABS, ABS_X,
- EV_ABS, ABS_Y,
- EV_ABS, ABS_MT_POSITION_X,
- EV_ABS, ABS_MT_POSITION_Y,
- EV_ABS, ABS_MT_SLOT,
- -1);
- ck_assert_msg(rc == 0, "Failed to create uinput device: %s", strerror(-rc));
- rc = libevdev_set_fd(dev, uinput_device_get_fd(uidev));
- ck_assert_msg(rc == 0, "Failed to init device: %s", strerror(-rc));;
+ rc = test_create_device(&uidev, &dev,
+ EV_ABS, ABS_X,
+ EV_ABS, ABS_Y,
+ EV_ABS, ABS_MT_POSITION_X,
+ EV_ABS, ABS_MT_POSITION_Y,
+ EV_ABS, ABS_MT_SLOT,
+ -1);
+ ck_assert_msg(rc == 0, "Failed to uinput device: %s", strerror(-rc));
ck_assert_int_eq(libevdev_get_num_slots(dev), 1);
ck_assert_int_eq(libevdev_get_current_slot(dev), 0);
struct input_absinfo abs;
int rc;
- rc = uinput_device_new_with_events(&uidev, "test device", DEFAULT_IDS,
- EV_ABS, ABS_X,
- -1);
- ck_assert_msg(rc == 0, "Failed to create uinput device: %s", strerror(-rc));
- rc = libevdev_new_from_fd(uinput_device_get_fd(uidev), &dev);
- ck_assert_msg(rc == 0, "Failed to init device: %s", strerror(-rc));
+ rc = test_create_device(&uidev, &dev,
+ EV_ABS, ABS_X,
+ -1);
+ ck_assert_msg(rc == 0, "Failed to create device: %s", strerror(-rc));
ck_assert(!libevdev_has_event_code(dev, EV_ABS, ABS_Y));
ck_assert(!libevdev_has_event_type(dev, EV_REL));
struct input_absinfo abs = {0};
int rc;
- rc = uinput_device_new_with_events(&uidev, "test device", DEFAULT_IDS,
- EV_ABS, ABS_X,
- -1);
- ck_assert_msg(rc == 0, "Failed to create uinput device: %s", strerror(-rc));
- rc = libevdev_new_from_fd(uinput_device_get_fd(uidev), &dev);
- ck_assert_msg(rc == 0, "Failed to init device: %s", strerror(-rc));
-
+ rc = test_create_device(&uidev, &dev,
+ EV_ABS, ABS_X,
+ -1);
+ ck_assert_msg(rc == 0, "Failed to create device: %s", strerror(-rc));
ck_assert_int_eq(libevdev_enable_event_code(dev, EV_ABS, ABS_MAX + 1, &abs), -1);
ck_assert_int_eq(libevdev_enable_event_type(dev, EV_MAX + 1), -1);
struct libevdev *dev, *dev2;
int rc;
- rc = uinput_device_new_with_events(&uidev, "test device", DEFAULT_IDS,
- EV_ABS, ABS_X,
- EV_ABS, ABS_Y,
- EV_REL, REL_X,
- EV_REL, REL_Y,
- -1);
- ck_assert_msg(rc == 0, "Failed to create uinput device: %s", strerror(-rc));
- rc = libevdev_new_from_fd(uinput_device_get_fd(uidev), &dev);
- ck_assert_msg(rc == 0, "Failed to init device: %s", strerror(-rc));
+ rc = test_create_device(&uidev, &dev,
+ EV_ABS, ABS_X,
+ EV_ABS, ABS_Y,
+ EV_REL, REL_X,
+ EV_REL, REL_Y,
+ -1);
+ ck_assert_msg(rc == 0, "Failed to create device: %s", strerror(-rc));
ck_assert(libevdev_has_event_code(dev, EV_ABS, ABS_X));
ck_assert(libevdev_has_event_code(dev, EV_ABS, ABS_Y));