From 9c35cf9caf031d6f67ec0211b8125d76f1983f58 Mon Sep 17 00:00:00 2001 From: Marian Buschsieweke Date: Wed, 23 Mar 2022 17:45:43 +0100 Subject: [PATCH] fix setting timestamp of input event On (some) 32 bit systems `struct input_event` has no member `time`. Instead, the macros `input_event_sec` and `input_event_usec` can be used in a portable fashion to access the timestamp. --- uinput.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/uinput.c b/uinput.c index 41e2cac..fe3a3d5 100644 --- a/uinput.c +++ b/uinput.c @@ -17,12 +17,19 @@ extern int axis_y_direction; extern int motion_interval; +static void _set_input_time(struct input_event *ie) +{ + struct timeval time; + gettimeofday(&time, NULL); + ie->input_event_sec = time.tv_sec; + ie->input_event_usec = time.tv_usec; +} void emit(int fd, int type, int code, int val) { struct input_event ie; memset(&ie, 0, sizeof(ie)); - gettimeofday(&ie.time, NULL); + _set_input_time(&ie); ie.type = type; ie.code = code;