1From 60987a1df8eb8c9196222375574dcd7bc0ad2daa Mon Sep 17 00:00:00 2001
2From: Khem Raj <raj.khem@gmail.com>
3Date: Sat, 30 Nov 2019 20:23:27 -0800
4Subject: [PATCH] Fix build on 32bit arches with 64bit time_t
5
6time element is deprecated on new input_event structure in kernel's
7input.h [1]
8
9[1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit?id=152194fe9c3f
10
11Upstream-Status: Pending
12Signed-off-by: Khem Raj <raj.khem@gmail.com>
13---
14 src/evemu-impl.h |  5 +++++
15 src/evemu.c      | 20 ++++++++++++--------
16 2 files changed, 17 insertions(+), 8 deletions(-)
17
18diff --git a/src/evemu-impl.h b/src/evemu-impl.h
19index acf2976..c08d861 100644
20--- a/src/evemu-impl.h
21+++ b/src/evemu-impl.h
22@@ -21,6 +21,11 @@
23 #include <evemu.h>
24 #include <linux/uinput.h>
25
26+#ifndef input_event_sec
27+#define input_event_sec time.tv_sec
28+#define input_event_usec time.tv_usec
29+#endif
30+
31 #define EVPLAY_NBITS	KEY_CNT
32 #define EVPLAY_NBYTES	((EVPLAY_NBITS + 7) / 8)
33
34diff --git a/src/evemu.c b/src/evemu.c
35index 21187af..7489449 100644
36--- a/src/evemu.c
37+++ b/src/evemu.c
38@@ -363,7 +363,7 @@ int evemu_read(struct evemu_device *dev, FILE *fp)
39 int evemu_write_event(FILE *fp, const struct input_event *ev)
40 {
41 	return fprintf(fp, "E: %lu.%06u %04x %04x %d\n",
42-		       ev->time.tv_sec, (unsigned)ev->time.tv_usec,
43+		       ev->input_event_sec, (unsigned)ev->input_event_usec,
44 		       ev->type, ev->code, ev->value);
45 }
46
47@@ -391,8 +391,8 @@ int evemu_read_event(FILE *fp, struct input_event *ev)
48 	int value;
49 	int ret = fscanf(fp, "E: %lu.%06u %04x %04x %d\n",
50 			 &sec, &usec, &type, &code, &value);
51-	ev->time.tv_sec = sec;
52-	ev->time.tv_usec = usec;
53+	ev->input_event_sec = sec;
54+	ev->input_event_usec = usec;
55 	ev->type = type;
56 	ev->code = code;
57 	ev->value = value;
58@@ -410,13 +411,16 @@ int evemu_read_event_realtime(FILE *fp, struct input_event *ev,
59 		return ret;
60
61 	if (evtime) {
62-		if (!evtime->tv_sec)
63-			*evtime = ev->time;
64-		usec = 1000000L * (ev->time.tv_sec - evtime->tv_sec);
65-		usec += ev->time.tv_usec - evtime->tv_usec;
66+		if (!evtime->tv_sec) {
67+			evtime->tv_sec = ev->input_event_sec;
68+			evtime->tv_usec = ev->input_event_usec;
69+		}
70+		usec = (ev->input_event_sec - evtime->tv_sec) * 1000000L;
71+		usec += ev->input_event_usec - evtime->tv_usec;
72 		if (usec > 500) {
73 			usleep(usec);
74-			*evtime = ev->time;
75+			evtime->tv_sec = ev->input_event_sec;
76+			evtime->tv_usec = ev->input_event_usec;
77 		}
78 	}
79
80