Skip to content
This repository was archived by the owner on Apr 28, 2021. It is now read-only.

Commit e2b637f

Browse files
committed
add compatibilty with kernel with dates on 32 bits
Signed-off-by: Michel-FK <[email protected]>
1 parent cd41252 commit e2b637f

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

uinput.c

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,19 @@
5656
return(EXIT_FAILURE); \
5757
} while(0)
5858

59+
// For compatibility with kernels having dates on 32 bits
60+
struct timeval_compat
61+
{
62+
unsigned int tv_sec;
63+
long int tv_usec;
64+
};
65+
66+
struct input_event_compat {
67+
struct timeval_compat time;
68+
unsigned short type;
69+
unsigned short code;
70+
unsigned int value;
71+
};
5972

6073
/****************************************************************
6174
* Static functions declaration
@@ -185,7 +198,7 @@ int close_uinput(void)
185198

186199
int sendKey(int key, int value)
187200
{
188-
struct input_event ie;
201+
struct input_event_compat ie;
189202
//memset(&uidev_ev, 0, sizeof(struct input_event));
190203
//gettimeofday(&uidev_ev.time, NULL);
191204
ie.type = EV_KEY;
@@ -194,7 +207,7 @@ int sendKey(int key, int value)
194207
ie.time.tv_sec = 0;
195208
ie.time.tv_usec = 0;
196209
UINPUT_PRINTF("sendKey: %d = %d\n", key, value);
197-
if(write(uidev_fd, &ie, sizeof(struct input_event)) < 0)
210+
if(write(uidev_fd, &ie, sizeof(struct input_event_compat)) < 0)
198211
die("error: write");
199212

200213
sendSync();

0 commit comments

Comments
 (0)