Brad Bishop | e42b3e3 | 2020-01-15 22:08:42 -0500 | [diff] [blame] | 1 | From 8ab672ccc67b64058cffac2cd19a0d3b75d5aa25 Mon Sep 17 00:00:00 2001 |
| 2 | From: Khem Raj <raj.khem@gmail.com> |
| 3 | Date: Sat, 30 Nov 2019 11:43:32 -0800 |
| 4 | Subject: [PATCH] Fix build on 32bit arches with 64bit time_t |
| 5 | |
| 6 | time element is deprecated on new input_event structure in kernel's |
| 7 | input.h [1] |
| 8 | |
| 9 | [1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit?id=152194fe9c3f |
| 10 | |
| 11 | Upstream-Status: Submitted [https://github.com/LibVNC/x11vnc/pull/117] |
| 12 | Signed-off-by: Khem Raj <raj.khem@gmail.com> |
| 13 | --- |
| 14 | src/uinput.c | 28 ++++++++++++++++++++++++---- |
| 15 | 1 file changed, 24 insertions(+), 4 deletions(-) |
| 16 | |
| 17 | diff --git a/src/uinput.c b/src/uinput.c |
| 18 | index 28fbad3..343b7c5 100644 |
| 19 | --- a/src/uinput.c |
| 20 | +++ b/src/uinput.c |
| 21 | @@ -54,6 +54,11 @@ so, delete this exception statement from your version. |
| 22 | #include <linux/input.h> |
| 23 | #include <linux/uinput.h> |
| 24 | |
| 25 | +#ifndef input_event_sec |
| 26 | +#define input_event_sec time.tv_sec |
| 27 | +#define input_event_usec time.tv_usec |
| 28 | +#endif |
| 29 | + |
| 30 | #if !defined(EV_SYN) || !defined(SYN_REPORT) |
| 31 | #undef UINPUT_OK |
| 32 | #endif |
| 33 | @@ -710,6 +715,7 @@ void parse_uinput_str(char *in) { |
| 34 | static void ptr_move(int dx, int dy) { |
| 35 | #ifdef UINPUT_OK |
| 36 | struct input_event ev; |
| 37 | + struct timeval tval; |
| 38 | int d = direct_rel_fd < 0 ? fd : direct_rel_fd; |
| 39 | |
| 40 | if (injectable && strchr(injectable, 'M') == NULL) { |
| 41 | @@ -720,7 +726,9 @@ static void ptr_move(int dx, int dy) { |
| 42 | |
| 43 | if (db) fprintf(stderr, "ptr_move(%d, %d) fd=%d\n", dx, dy, d); |
| 44 | |
| 45 | - gettimeofday(&ev.time, NULL); |
| 46 | + gettimeofday(&tval, NULL); |
| 47 | + ev.input_event_sec = tval.tv_sec; |
| 48 | + ev.input_event_usec = tval.tv_usec; |
| 49 | ev.type = EV_REL; |
| 50 | ev.code = REL_Y; |
| 51 | ev.value = dy; |
| 52 | @@ -755,6 +763,7 @@ static void apply_tslib(int *x, int *y) { |
| 53 | static void ptr_abs(int x, int y, int p) { |
| 54 | #ifdef UINPUT_OK |
| 55 | struct input_event ev; |
| 56 | + struct timeval tval; |
| 57 | int x0, y0; |
| 58 | int d = direct_abs_fd < 0 ? fd : direct_abs_fd; |
| 59 | |
| 60 | @@ -773,7 +782,9 @@ static void ptr_abs(int x, int y, int p) { |
| 61 | |
| 62 | if (db) fprintf(stderr, "ptr_abs(%d, %d => %d %d, p=%d) fd=%d\n", x0, y0, x, y, p, d); |
| 63 | |
| 64 | - gettimeofday(&ev.time, NULL); |
| 65 | + gettimeofday(&tval, NULL); |
| 66 | + ev.input_event_sec = tval.tv_sec; |
| 67 | + ev.input_event_usec = tval.tv_usec; |
| 68 | ev.type = EV_ABS; |
| 69 | ev.code = ABS_Y; |
| 70 | ev.value = y; |
| 71 | @@ -950,6 +961,7 @@ if (0) {usleep(100*1000) ;} |
| 72 | static void button_click(int down, int btn) { |
| 73 | #ifdef UINPUT_OK |
| 74 | struct input_event ev; |
| 75 | + struct timeval tval; |
| 76 | int d = direct_btn_fd < 0 ? fd : direct_btn_fd; |
| 77 | |
| 78 | if (injectable && strchr(injectable, 'B') == NULL) { |
| 79 | @@ -959,7 +971,12 @@ static void button_click(int down, int btn) { |
| 80 | if (db) fprintf(stderr, "button_click: btn %d %s fd=%d\n", btn, down ? "down" : "up", d); |
| 81 | |
| 82 | memset(&ev, 0, sizeof(ev)); |
| 83 | - gettimeofday(&ev.time, NULL); |
| 84 | + gettimeofday(&tval, NULL); |
| 85 | + gettimeofday(&tval, NULL); |
| 86 | + ev.input_event_sec = tval.tv_sec; |
| 87 | + ev.input_event_usec = tval.tv_usec; |
| 88 | + ev.input_event_sec = tval.tv_sec; |
| 89 | + ev.input_event_usec = tval.tv_usec; |
| 90 | ev.type = EV_KEY; |
| 91 | ev.value = down; |
| 92 | |
| 93 | @@ -1230,6 +1247,7 @@ void uinput_pointer_command(int mask, int x, int y, rfbClientPtr client) { |
| 94 | void uinput_key_command(int down, int keysym, rfbClientPtr client) { |
| 95 | #ifdef UINPUT_OK |
| 96 | struct input_event ev; |
| 97 | + struct timeval tval; |
| 98 | int scancode; |
| 99 | allowed_input_t input; |
| 100 | int d = direct_key_fd < 0 ? fd : direct_key_fd; |
| 101 | @@ -1253,7 +1271,9 @@ void uinput_key_command(int down, int keysym, rfbClientPtr client) { |
| 102 | if (db) fprintf(stderr, "uinput_key_command: %d -> %d %s fd=%d\n", keysym, scancode, down ? "down" : "up", d); |
| 103 | |
| 104 | memset(&ev, 0, sizeof(ev)); |
| 105 | - gettimeofday(&ev.time, NULL); |
| 106 | + gettimeofday(&tval, NULL); |
| 107 | + ev.input_event_sec = tval.tv_sec; |
| 108 | + ev.input_event_usec = tval.tv_usec; |
| 109 | ev.type = EV_KEY; |
| 110 | ev.code = (unsigned char) scancode; |
| 111 | ev.value = down; |