Stopping input from a specific keyboard from propagating to UI
Hi, I'm new to Linux, this is my first time posting here. If I posted in the wrong subforum please let me know, I'll try to rectify this.
I'm trying to set up a kiosk machine. This is a PC with a touchscreen and no physical mouse or keyboard attached during normal operation.
Currently I'm working with Debian 12, but I plan to look around for a potentially more suitable distro. This is not set in stone yet.
The kiosk has two USB peripherals - an NFC card scanner and a QR code/bar code/MRZ scanner. As far as the OS is concerned, these behave like USB keyboards. When something is scanned, they send the keystrokes and the data gets written into whatever text box/editor window/console window has focus.
I was able to read the input from these devices programmatically by reading the following files:
/dev/input/by-id/usb-HOUSESMart_PROTOCOL-if01-event-kbd
/dev/input/by-id/usb-Newtologic_NT7730_XXXXXX-event-kbd
however this does not prevent the key strokes from also reaching the UI and getting typed in if a text box is focused. This isn't a huge problem for us, because our kiosk app doesn't have a text input on most screens. But on some screens it does. And if a user is typing into a text input field, and he scans something (say he has his phone in his other hand, and he accidentally moves it close to the NFC scanner and it gets scanned) the data will be written into the text box. I need to prevent this.
I need a way to prevent the events from those two "keyboards" from reaching the UI, but not disable them completely, so that I still get the data by reading those input files. Is there a way to do this?
The solution can be some code that is run every time our app starts, (Ideally something I can do in C#) or a system setting that is performed once during the machine setup. Either one is fine.
I also need to make sure I only limit those two keyboards. I don't want to limit all keyboards across the board, as there are situations where a keyboard will be used, whether virual or physical. The device id's don't seem to change no matter how many times I plug in and unplug them, so those can be relied on to identify the devices.
For completeness, our kiosk app is a .NET8 Blazor webapp, most likely to be accessed from a browser like Chrome. Or it may be hosted in a .NET MAUI container, if that's already supported on Linux. Point is it will be one specific app, and I have control over which one it will be, so if there is a way to say "Hey, don't send key strokes from this keyboard to this app", I can go that way too.
|