From: Peter Hutterer <peter.hutterer@who-t.net>
To: input-tools@lists.freedesktop.org
Subject: [ANNOUNCE] libevdev 0.2
Date: Tue, 23 Jul 2013 09:09:08 +1000 [thread overview]
Message-ID: <20130722230908.GA14622@yabbi.redhat.com> (raw)
[Note: bcc'd linux-input, wayland-devel and xorg-devel since those are the
expected interested parties. Apologies if you get this email multiple times,
I won't do this in the future. Future announcements will only go to
input-tools@lists.freedesktop.org]
This is the first release for libevdev, a C library that wraps the
kernel evdev interface. The benefits are
* type-safe interface for checking bits on a device
* various abstractions for ioctls that aren't quite as straightforward (e.g.
EV_REP handling)
* simple abstraction for handling SYN_DROPPED events
This library is now hosted on freedesktop.org:
http://www.freedesktop.org/wiki/Software/libevdev/
API documentation: http://www.freedesktop.org/software/libevdev/doc/latest/
Bugzilla component: https://bugs.freedesktop.org/enter_bug.cgi?product=libevdev
cgit: http://cgit.freedesktop.org/libevdev/
libevdev provides API calls for the various bits, so a simple process can
work this way:
struct libevdev *dev;
fd = open("/dev/input/event0", O_RDONLY);
rc = libevdev_new_from_fd(fd, &dev);
if (libevdev_has_event_code(dev, EV_REL, REL_X))
/* do something */
For event handling, libevdev provides one call that returns the next event
in the queue:
rc = libevdev_next_event(dev, flags, &ev);
which does what you expect and returns 0 on success or -EAGAIN if there are
no events waiting. If a SYN_DROPPED is the next event in the queue, libevdev
syncs the device state and returns 1. The process can then handle the delta
by simply parsing events until the device is fully synced again:
while ((rc = libevdev_next_event(dev, LIBEVEV_READ_SYNC, &ev)) == 1)
/* this is a synced event */
if (rc == -EAGAIN)
/* we are now fully synced */
else
/* error */
To check out an example of how libevdev looks like, have a look at how
evtest would look like with libevdev.
http://cgit.freedesktop.org/libevdev/tree/tools/libevdev-events.c
The goal is that future and current processes that deal with evdev events
will switch to libevdev. An example of changes needed for the X.org
synaptics driver is here:
http://cgit.freedesktop.org/~whot/xf86-input-synaptics/commit/?h=libevdev
Suggestions, comments, etc. are all welcome. Please note that the library is
still in an early stage and may change in the future.
Cheers,
Peter
git tag: libevdev-0.2
http://www.freedesktop.org/software/libevdev/libevdev-0.2.tar.xz
MD5: bce22c2ae9c87b9a7b5c8d055f771084 libevdev-0.2.tar.xz
SHA1: 8efec1ff4f8b45929c3acc2b7e4f9fd37c9f8d37 libevdev-0.2.tar.xz
SHA256: da25b6efba09d7e357e50a31e599d98b97f116eb0f32086335640a06e13e37a6 libevdev-0.2.tar.xz
reply other threads:[~2013-07-22 23:09 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20130722230908.GA14622@yabbi.redhat.com \
--to=peter.hutterer@who-t.net \
--cc=input-tools@lists.freedesktop.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).