Add a flag for forcing a SYN_DROPPED event

uinput doesn't route a SYN_DROPPED, so we neeed to handle fds in
a rather complicated manner. For tests, avoid this and instead force
the library to sync if a specific flag is given.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
Peter Hutterer 2013-06-28 10:18:35 +10:00
parent d844e3eb51
commit bc285acd9a
2 changed files with 11 additions and 1 deletions

View file

@ -530,7 +530,7 @@ int libevdev_next_event(struct libevdev *dev, unsigned int flags, struct input_e
if (dev->fd < 0)
return -ENODEV;
if (!(flags & (LIBEVDEV_READ_NORMAL|LIBEVDEV_READ_SYNC)))
if (!(flags & (LIBEVDEV_READ_NORMAL|LIBEVDEV_READ_SYNC|LIBEVDEV_FORCE_SYNC)))
return -EINVAL;
if (flags & LIBEVDEV_READ_SYNC) {
@ -558,6 +558,13 @@ int libevdev_next_event(struct libevdev *dev, unsigned int flags, struct input_e
if (rc < 0 && rc != -EAGAIN)
goto out;
if (flags & LIBEVDEV_FORCE_SYNC) {
dev->need_sync = 1;
rc = 1;
goto out;
}
if (queue_shift(dev, ev) != 0)
return -EAGAIN;

View file

@ -189,6 +189,9 @@ struct libevdev;
enum EvdevReadFlags {
LIBEVDEV_READ_SYNC = 1, /**< Process data in sync mode */
LIBEVDEV_READ_NORMAL = 2, /**< Process data in normal mode */
LIBEVDEV_FORCE_SYNC = 4, /**< Pretend the next event is a SYN_DROPPED. There is
no reason to ever use this except for
automated tests, so don't. */
};
/**