'Not possible to write two /dev/input/eventX at the same time?

I'm working on this Linux system where if you press these combinations of key, a special screen will appear.

event3: Hold "A" button
event4: [a few actions]

I use evtest (https://github.com/freedesktop-unofficial-mirror/evtest/blob/master/evtest.c) to see the values of the input events generated.

When I use evtest with event4, If I hold A button then do those actions, evtest shows none of them. But If I don't hold A button, evtest show details of those actions just fine. It seems that when a key is being pressed in event4, none of the keys of event3 are registered.

I created an app in C to write input events corresponding to the combos above to /dev/input/event3 and /dev/input/event4 but I'm having trouble with the problem that I just mentioned.

struct input_event event;
if ((fd1 = open("/dev/input/event3", O_RDWR)) > 0) {
        // Press "A" button
        // set_event() function sets the appropriate values
        set_event(&event, EV_KEY, KEY_A, 1);
        write(fd1, &event, sizeof(struct input_event));
}

if ((fd2 = open("/dev/input/event4", O_RDWR)) > 0) {
        // Do a few actions
        // set_event() function sets the appropriate values
        set_event(&event, EV_ABS, ABS_HAT0X, 1);
        write(fd2, &event, sizeof(struct input_event));
        // ...
}

I would appreciate any help, thank you!



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source