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
All released versions can be found at: https://www.freedesktop.org/software/libevdev/
- 0.2 - released July 23, 2013
- 0.2.1 - released July 25, 2013
- 0.3 - released Aug 8, 2013
- 0.4 - released Sep 18, 2013
- 0.4.1 - released Nov 5, 2013
- 0.5 - released Nov 22, 2013
- 0.6 - released Dec 23, 2013
- 0.9.1 - released Jan 29, 2014
- 1.0 - released Feb 18, 2014
- 1.0.1 - released Mar 6, 2014
- 1.1 - released Mar 25, 2014
- 1.2 - released Apr 30, 2014
- 1.3 - released Sep 9, 2014
- 1.3.1 - released Nov 12, 2014
- 1.3.2 - released Dec 4, 2014
- 1.4 - released Mar 4, 2015
- 1.4.1 - released Apr 8, 2015
- 1.4.2 - released Apr 23, 2015
- 1.4.3 - released Jun 22, 2015
- 1.4.4 - released Aug 31, 2015
- 1.4.5 - released Nov 10, 2015
- 1.4.6 - released Jan 04, 2016
- 1.5 - released May 13, 2016
- 1.5.1 - released May 16, 2016
- 1.5.2 - released Jun 15, 2016
- 1.5.3 - released Aug 22, 2016
- 1.5.4 - released Aug 26, 2016
- 1.5.5 - released Nov 30, 2016
- 1.5.6 - released Jan 4, 2017
- 1.5.7 - released May 4, 2017
- 1.5.8 - released Jan 29, 2018
- 1.5.9 - released Mar 8, 2018
- 1.6.0 - released Oct 26, 2018
- 1.7.0 - released Jun 5, 2019
- 1.8.0 - released Aug 26, 2019
- 1.9.0 - released Mar 2, 2020
- 1.9.1 - released Jul 16, 2020
- 1.10.0 - released Oct 26, 2020
- 1.10.1 - released Jan 11, 2021
- 1.11.0 - released Feb 01, 2021
- 1.12.0 - released Nov 09, 2021
- 1.12.1 - released Mar 25, 2022
git Repository
Documentation
- For current and previous releases: http://www.freedesktop.org/software/libevdev/doc/
- For current development version
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 issue tracker in freedesktop.org gitlab instance