Add tv2us helper function
authorPeter Hutterer <peter.hutterer@who-t.net>
Thu, 25 May 2017 22:56:29 +0000 (08:56 +1000)
committerPeter Hutterer <peter.hutterer@who-t.net>
Fri, 2 Jun 2017 02:21:35 +0000 (12:21 +1000)
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
src/evdev.c
src/libinput-util.h

index 7fac2b2f4ea6b24d32a86d3ddccc064b513bdae2..f0f790675a4388293e973a516cb75922a63bb74f 100644 (file)
@@ -1887,7 +1887,7 @@ static inline void
 evdev_process_event(struct evdev_device *device, struct input_event *e)
 {
        struct evdev_dispatch *dispatch = device->dispatch;
-       uint64_t time = s2us(e->time.tv_sec) + e->time.tv_usec;
+       uint64_t time = tv2us(&e->time);
 
 #if 0
        if (libevdev_event_is_code(e, EV_SYN, SYN_REPORT))
index e34a50020c38b81fbd2698afb0a4a788b873f826..8d8e3d565a385edae36d691324ec8300d323491a 100644 (file)
@@ -440,6 +440,12 @@ us2ms(uint64_t us)
        return (uint32_t)(us / 1000);
 }
 
+static inline uint64_t
+tv2us(const struct timeval *tv)
+{
+       return s2us(tv->tv_sec) + tv->tv_usec;
+}
+
 static inline bool
 safe_atoi(const char *str, int *val)
 {