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