Fix 32bit event mapping
This commit is contained in:
parent
166f5384c0
commit
ab2d25343a
1 changed files with 25 additions and 8 deletions
33
src/main.c
33
src/main.c
|
@ -8,8 +8,17 @@
|
|||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
struct input_event32 {
|
||||
__u32 __sec;
|
||||
__u32 __usec;
|
||||
__u16 type;
|
||||
__u16 code;
|
||||
__s32 value;
|
||||
};
|
||||
|
||||
int read_input_event(struct input_event *ie) {
|
||||
if (fread(ie, sizeof(struct input_event), 1, stdin) != 1) {
|
||||
struct input_event32 ie32 = {0};
|
||||
if (fread(&ie32, sizeof(struct input_event32), 1, stdin) != 1) {
|
||||
if (feof(stdin)) {
|
||||
return EOF;
|
||||
} else {
|
||||
|
@ -19,6 +28,11 @@ int read_input_event(struct input_event *ie) {
|
|||
return 1;
|
||||
}
|
||||
}
|
||||
ie->input_event_sec = ie32.__sec;
|
||||
ie->input_event_usec = ie32.__usec;
|
||||
ie->code = ie32.code;
|
||||
ie->type = ie32.type;
|
||||
ie->value = ie32.value;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -134,18 +148,21 @@ int process_events(FILE *dev) {
|
|||
while (true) {
|
||||
int res;
|
||||
struct input_event ie;
|
||||
while ((!(res = read_input_event(&ie))) &&
|
||||
(ie.type != EV_ABS && (ie.code != ABS_MT_TOOL_TYPE) &&
|
||||
(ie.value != MT_TOOL_PEN))) {
|
||||
while ((!(res = read_input_event(&ie)))) {
|
||||
if (ie.type == EV_ABS && ie.code == ABS_MT_TOOL_TYPE &&
|
||||
(ie.value == MT_TOOL_PEN))
|
||||
break;
|
||||
}
|
||||
if (res == EOF)
|
||||
return EXIT_SUCCESS;
|
||||
if (res != 0)
|
||||
return EXIT_FAILURE;
|
||||
|
||||
while (!(res = read_input_event(&ie) && (ie.type == EV_ABS) &&
|
||||
(ie.code == ABS_MT_TOOL_TYPE) &&
|
||||
(ie.value != MT_TOOL_PEN))) {
|
||||
while (!(res = read_input_event(&ie))) {
|
||||
if (ie.type == EV_ABS && (ie.code == ABS_MT_TOOL_TYPE) &&
|
||||
(ie.value != MT_TOOL_PEN)) {
|
||||
break;
|
||||
}
|
||||
if (rewrite_pen_event(&ie))
|
||||
forward_event(dev, &ie);
|
||||
};
|
||||
|
@ -162,5 +179,5 @@ int main(void) {
|
|||
}
|
||||
res = process_events(dev);
|
||||
cleanup(dev);
|
||||
return EXIT_SUCCESS;
|
||||
return res;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue