summaryrefslogtreecommitdiff
path: root/libevdev/libevdev-int.h
diff options
context:
space:
mode:
authorPeter Hutterer <peter.hutterer@who-t.net>2013-07-02 10:50:37 +1000
committerPeter Hutterer <peter.hutterer@who-t.net>2013-07-02 14:02:55 +1000
commitc661e80ba0f20ea8b71fcc0aa02840c52314710a (patch)
tree9a90416818ec37d21fcc44c505b105c5c1fc5a48 /libevdev/libevdev-int.h
parentf3a6b0c6854a59f4433217f279f76383687d0c3b (diff)
downloadlibevdev-c661e80ba0f20ea8b71fcc0aa02840c52314710a.tar.gz
Switch to a state machine to handle incomplete syncs
A caller may start syncing but switch back to normal half-way through the sync. In that case, we need to drop all sync events and continue with regular events only. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Diffstat (limited to 'libevdev/libevdev-int.h')
-rw-r--r--libevdev/libevdev-int.h19
1 files changed, 18 insertions, 1 deletions
diff --git a/libevdev/libevdev-int.h b/libevdev/libevdev-int.h
index 1a4f224..34f8e05 100644
--- a/libevdev/libevdev-int.h
+++ b/libevdev/libevdev-int.h
@@ -51,6 +51,23 @@
_a > _b ? _a : _b; \
})
+/**
+ * Sync state machine:
+ * default state: SYNC_NONE
+ *
+ * SYNC_NONE → SYN_DROPPED or forced sync → SYNC_NEEDED
+ * SYNC_NEEDED → libevdev_next_event(LIBEVDEV_READ_SYNC) → SYNC_IN_PROGRESS
+ * SYNC_NEEDED → libevdev_next_event(LIBEVDEV_READ_SYNC_NONE) → SYNC_NONE
+ * SYNC_IN_PROGRESS → libevdev_next_event(LIBEVDEV_READ_SYNC_NONE) → SYNC_NONE
+ * SYNC_IN_PROGRESS → no sync events left → SYNC_NONE
+ *
+ */
+enum SyncState {
+ SYNC_NONE,
+ SYNC_NEEDED,
+ SYNC_IN_PROGRESS,
+};
+
struct libevdev {
int fd;
libevdev_log_func_t log;
@@ -78,7 +95,7 @@ struct libevdev {
int current_slot;
int rep_values[2];
- int need_sync;
+ enum SyncState sync_state;
int grabbed;
struct input_event *queue;