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:
1 parent
d844e3eb51
commit
bc285acd9a
2 files changed
+11
-1
No files matched your search
+8
-1
@@ -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;
|
||||
|
||||
|
||||
@@ -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. */
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
Reference in new issue
Block a user