diff options
| author | Peter Hutterer <peter.hutterer@who-t.net> | 2013-07-24 13:37:53 +1000 |
|---|---|---|
| committer | Peter Hutterer <peter.hutterer@who-t.net> | 2013-08-01 13:53:04 +1000 |
| commit | a28473cb62de5b207a87492cdbf7c61ec3ed9bc5 (patch) | |
| tree | e76b9a5b0c1482fa01cf95a232d3fadc50f3bd0f /libevdev/libevdev.h | |
| parent | bc73a98ca62ff971c0d7471a1812769e78ad95bc (diff) | |
| download | libevdev-a28473cb62de5b207a87492cdbf7c61ec3ed9bc5.tar.gz | |
Add libevdev_has_event_pending()
Returns non-zero if there are events avialable to be read.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
Reviewed-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
Diffstat (limited to 'libevdev/libevdev.h')
| -rw-r--r-- | libevdev/libevdev.h | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/libevdev/libevdev.h b/libevdev/libevdev.h index 606501b..d637c29 100644 --- a/libevdev/libevdev.h +++ b/libevdev/libevdev.h @@ -483,6 +483,30 @@ int libevdev_get_fd(const struct libevdev* dev); int libevdev_next_event(struct libevdev *dev, unsigned int flags, struct input_event *ev); /** + * @ingroup events + * + * Check if there are events waiting for us. This does not read an event off + * the fd and may not access the fd at all. If there are events queued + * internally this function will return non-zero. If the internal queue is empty, + * this function will poll the file descriptor for data. + * + * This is a convenience function for simple processes, most complex programs + * are expected to use select(2) or poll(2) on the file descriptor. The kernel + * guarantees that if data is available, it is a multiple of sizeof(struct + * input_event), and thus calling libevdev_next_event() when select(2) or + * poll(2) return is safe. You do not need libevdev_has_event_pending() if + * you're using select(2) or poll(2). + * + * @param dev The evdev device, already initialized with libevdev_set_fd() + * @return On failure, a negative errno is returned. + * @retval 0 No event is currently available + * @retval 1 One or more events are available on the fd + * + * @note This function is signal-safe. + */ +int libevdev_has_event_pending(struct libevdev *dev); + +/** * @ingroup bits * * @param dev The evdev device, already initialized with libevdev_set_fd() |
