summaryrefslogtreecommitdiff
path: root/libevdev
diff options
context:
space:
mode:
authorPeter Hutterer <peter.hutterer@who-t.net>2020-02-13 20:39:41 +1000
committerPeter Hutterer <peter.hutterer@who-t.net>2020-02-19 10:37:24 +1000
commit507bd1ee28444efd78940d7875807d95e15fd1ae (patch)
tree3c34676b6105d40fd040270899b722c3c1210864 /libevdev
parente38e3ae7c8e1a1a1d15fa09b4b84efe1486cc8d7 (diff)
downloadlibevdev-507bd1ee28444efd78940d7875807d95e15fd1ae.tar.gz
Push terminating the slots into a helper function
No functional changes. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Diffstat (limited to 'libevdev')
-rw-r--r--libevdev/libevdev.c28
1 files changed, 19 insertions, 9 deletions
diff --git a/libevdev/libevdev.c b/libevdev/libevdev.c
index aa2e964..100c169 100644
--- a/libevdev/libevdev.c
+++ b/libevdev/libevdev.c
@@ -732,13 +732,11 @@ out:
return rc;
}
-static int
-push_mt_sync_events(struct libevdev *dev,
- const struct slot_change_state changes[dev->num_slots])
+static void
+terminate_slots(struct libevdev *dev,
+ const struct slot_change_state changes[dev->num_slots],
+ int *last_reported_slot)
{
- struct input_absinfo abs_info;
- int last_reported_slot = 0;
- int rc;
bool touches_stopped = false;
for (int slot = 0; slot < dev->num_slots; slot++) {
@@ -748,7 +746,7 @@ push_mt_sync_events(struct libevdev *dev,
queue_push_event(dev, EV_ABS, ABS_MT_SLOT, slot);
queue_push_event(dev, EV_ABS, ABS_MT_TRACKING_ID, -1);
- last_reported_slot = slot;
+ *last_reported_slot = slot;
touches_stopped = true;
}
@@ -757,6 +755,15 @@ push_mt_sync_events(struct libevdev *dev,
new touches starting (if any) */
if (touches_stopped)
queue_push_event(dev, EV_SYN, SYN_REPORT, 0);
+}
+
+static int
+push_mt_sync_events(struct libevdev *dev,
+ const struct slot_change_state changes[dev->num_slots],
+ int last_reported_slot)
+{
+ struct input_absinfo abs_info;
+ int rc;
for (int slot = 0; slot < dev->num_slots; slot++) {
if (!bit_is_set(changes[slot].axes, ABS_MT_SLOT))
@@ -873,10 +880,13 @@ sync_state(struct libevdev *dev)
if (rc == 0 && dev->num_slots > -1 &&
libevdev_has_event_code(dev, EV_ABS, ABS_MT_SLOT)) {
struct slot_change_state changes[dev->num_slots];
+ int last_reported_slot = 0;
rc = sync_mt_state(dev, changes);
- if (rc == 0)
- push_mt_sync_events(dev, changes);
+ if (rc == 0) {
+ terminate_slots(dev, changes, &last_reported_slot);
+ push_mt_sync_events(dev, changes, last_reported_slot);
+ }
}
dev->queue_nsync = queue_num_elements(dev);