[PATCH libinput 10/11] Add tv2us helper function

Peter Hutterer peter.hutterer at who-t.net
Sun May 28 22:48:03 UTC 2017


Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
 src/evdev.c         | 2 +-
 src/libinput-util.h | 6 ++++++
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/src/evdev.c b/src/evdev.c
index f7a019c6..83b8db07 100644
--- a/src/evdev.c
+++ b/src/evdev.c
@@ -1857,7 +1857,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))
diff --git a/src/libinput-util.h b/src/libinput-util.h
index e34a5002..8d8e3d56 100644
--- a/src/libinput-util.h
+++ b/src/libinput-util.h
@@ -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)
 {
-- 
2.13.0



More information about the wayland-devel mailing list