struct libevdev *dev = NULL;
 int fd;
 int rc = 1;

 fd = open("/dev/input/event0", O_RDONLY|O_NONBLOCK);
 rc = libevdev_new_from_fd(fd, &dev);
 if (rc < 0) {
         fprintf(stderr, "Failed to init libevdev (%s)\n", strerror(-rc));
         exit(1);
 }
 printf("Input device name: \"%s\"\n", libevdev_get_name(dev));
 printf("Input device ID: bus %#x vendor %#x product %#x\n",
        libevdev_get_id_bustype(dev),
        libevdev_get_id_vendor(dev),
        libevdev_get_id_product(dev));
 if (!libevdev_has_event_type(dev, EV_REL) ||
     !libevdev_has_event_code(dev, EV_KEY, BTN_LEFT)) {
         printf("This device does not look like a mouse\n");
         exit(1);
 }

 do {
         struct input_event ev;
         rc = libevdev_next_event(dev, LIBEVDEV_READ_FLAG_NORMAL, &ev);
         if (rc == 0)
                 printf("Event: %s %s %d\n",
                        libevdev_event_type_get_name(ev.type),
                        libevdev_event_code_get_name(ev.type, ev.code),
                        ev.value);
 } while (rc == 1 || rc == 0 || rc == -EAGAIN);

libevdev

libevdev is a wrapper library for evdev devices. it moves the common tasks when dealing with evdev devices into a library and provides a library interface to the callers, thus avoiding erroneous ioctls, etc.

The eventual goal is that libevdev wraps all ioctls available to evdev devices, thus making direct access unnecessary.

This wiki page is largely a placeholder, documentation about libevdev and examples are available in the API documentation.

Releases

Older releases

git Repository

  • git://anongit.freedesktop.org/libevdev
  • ssh://git.freedesktop.org/git/libevdev

cgit Web Frontend

Documentation

API documentation:

Documentation for pre-releases

Downloads

Source tarballs are available http://www.freedesktop.org/software/libevdev/

Development

Please submit patches to the input-tools@lists.freedesktop.org mailing list.

Reporting Bugs

libevdev has a bugzilla component in the freedesktop.org Bugzilla