⚠️ Forum Maintenance: Feb 6th, 8am - 14pm (UTC+2)

HID Device Detection

  • I have a need to detect if data is coming from a real keyboard or a barcode reader that reports itself as a keyboard and sends keystrokes and react differently to that input versus the real keyboard or a virtual keyboard.

    From my googling I've reached the understanding that this will have to be accomplished in a different manner on different platforms, my first concern is Linux, and I haven't been able to find anything that would point me in the right direction to accomplish my goal.

    How do I tell my application to listen to the keyboards differently?

  • Lifetime Qt Champion


    Since we are talking about linux and without diving too deep in Qt's internals you could create an object that reads directly from the correct input device in /dev. Your widget would have to ignore all key events and get feed from that special keyboard reader.

    Hope it helps

  • https://github.com/bimetek/QUSB

    I followed your advice to read the device directly from /dev/foo, to figure out what subdirectory I need to be reading from I found the linked wrapper for libUSB. I'm almost positive there is a way to use that wrapper to do the actual reading so I don't have to open a device file, but I'm not sure how yet. I just thought it may be of some interest to other developers using Qt that there is a prettier way than directly calling libUSB functions.

  • Lifetime Qt Champion

    You can also setup your system to give a specific name to that device so you don't have to search with special means

  • Can multiple different devices be assigned the same friendly name?

  • Lifetime Qt Champion

    If they are not connected at the same time it should be possible. It depends on what you are using on your target distribution to handle devices.

Log in to reply