Search code examples
linuxeventsusbtty

"disconnecting" /dev/input/event14 from the tty


I bought a USB foot switch. It has usb id 0c45:7403. Linux works perfectly fine with it, that is: if you press it, it emulates a keyboard-press. Now I can simly open /dev/input/event14 and read events from it, but it seems there are still "key presses" being send to the tty! How can I prevent that?

Thanks.


Solution

  • If you spend only 4 minutes longer Googleing, you would've found the answer yourself! First, open /dev/input/eventX - where X is 14 in your case. Then run:

    int grab = 1;
    int rc = ioctl(fd, EVIOCGRAB, &grab);
    if (rc == -1)
            // failure
    

    From then, until your program stops, you own the device and no events end up at the tty.