commit 160ebbf
Michael Forney
·
2017-02-06 19:37:41 +0000 UTC
parent 0013242
evdev_device: Use CLOCK_MONOTONIC Otherwise a system clock change could interfere with input event timing.
1 files changed,
+10,
-4
+10,
-4
1@@ -32,13 +32,14 @@
2 #include "seat.h"
3 #include "util.h"
4
5-#include <stdlib.h>
6+#include <errno.h>
7+#include <fcntl.h>
8+#include <libevdev/libevdev.h>
9 #include <stdio.h>
10+#include <stdlib.h>
11 #include <string.h>
12-#include <fcntl.h>
13+#include <time.h>
14 #include <unistd.h>
15-#include <errno.h>
16-#include <libevdev/libevdev.h>
17
18 #define AXIS_STEP_DISTANCE 10
19 #define ARRAY_SIZE(array) (sizeof(array) / sizeof(array[0]))
20@@ -234,6 +235,11 @@ evdev_device_new(const char *path, const struct evdev_device_handler *handler)
21 goto error3;
22 }
23
24+ if (libevdev_set_clock_id(device->dev, CLOCK_MONOTONIC) != 0) {
25+ ERROR("Failed to set libevdev device to monotonic clock\n");
26+ goto error4;
27+ }
28+
29 device->source = wl_event_loop_add_fd(swc.event_loop, device->fd, WL_EVENT_READABLE, handle_data, device);
30
31 if (!device->source) {