Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Qt Academy Launch in California!

    HID Device Detection

    General and Desktop
    2
    6
    1832
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • S
      stevedorries last edited by

      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?

      1 Reply Last reply Reply Quote 0
      • SGaist
        SGaist Lifetime Qt Champion last edited by

        Hi,

        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

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply Reply Quote 0
        • S
          stevedorries last edited by

          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.

          1 Reply Last reply Reply Quote 0
          • SGaist
            SGaist Lifetime Qt Champion last edited by

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

            Interested in AI ? www.idiap.ch
            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

            1 Reply Last reply Reply Quote 0
            • S
              stevedorries last edited by

              Can multiple different devices be assigned the same friendly name?

              1 Reply Last reply Reply Quote 0
              • SGaist
                SGaist Lifetime Qt Champion last edited by

                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.

                Interested in AI ? www.idiap.ch
                Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                1 Reply Last reply Reply Quote 0
                • First post
                  Last post