Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. How to restrict the widget to only process events from a specific hardware input device?
Forum Updated to NodeBB v4.3 + New Features

How to restrict the widget to only process events from a specific hardware input device?

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
10 Posts 2 Posters 1.9k Views 2 Watching
  • 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.
  • M Offline
    M Offline
    MatthewLai
    wrote on last edited by
    #1

    I'm new to Qt so pardon me for asking dumb questions here. I have an embedded application here with two physical dials (the usb-powered PowerMate knobs) and in the GUI there are two corresponding dial widgets. The user interface usecase is such that the events (dial rotate clockwise/counter-clockwise, dial pressed/released) generated by physical dial 1 should be processed by dial widget1 only, and the events generated by physical dial 2 should be processed by dial widget 2 only. Is there a way to support this input-source-specific event processing in Qt?

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi and welcome to devnet,

      How are these devices handled by your system ?
      Are they input like keyboard and mouse ? Do they provide SDKs to talk with them ?

      What OS are you on ?
      What version of Qt are you using ?

      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
      1
      • M Offline
        M Offline
        MatthewLai
        wrote on last edited by
        #3

        How are these devices handled by your system ?

        I'm "thinking" of using device plug-in as described in this article: https://doc.qt.io/archives/qtextended4.4/tut-deviceexample.html

        Are they input like keyboard and mouse ? Do they provide SDKs to talk with them ?

        The powermate knob behaves like a mouse. When I plug it in the Linux kernel module "powermate" is loaded and I could see it in /dev/input/event5. Doing the "cat /dev/input/event5 | hexdump" and I can see the event data (timestamp, type, code, value).

        What OS are you on ?
        Ubuntu 16.04 VM for the cross compiling Qt
        Wandboard for running the embedded application

        What version of Qt are you using ?
        Qt5.8

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Ok, does your system already reacts to these 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
          0
          • M Offline
            M Offline
            MatthewLai
            wrote on last edited by MatthewLai
            #5

            No. I have yet to implement the plug-in yet. And I could not see in the plug-in examples how to implement the "handle-this-event-if-it-is-from-that-physical-input-device" feature?

            My system (the Wandboard) does react to the powermate knob i.e. I connect the knob to the wandboard through the usb, and verify the /dev/input/event5 appears, and when I rotate the physical knob or press/release it I could see the event data with "cat /dev/input/event5 | hexdump".

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              Qt 5 uses a different architecture that Qt 4.

              But I think you might have misunderstood my question. Are these device already handled by your desktop environment ? e.g. like a mouse.

              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
              1
              • M Offline
                M Offline
                MatthewLai
                wrote on last edited by
                #7

                If by "handled" you mean the corresponding Linux kernel module automatically loaded when I connect the powermate knob to the Wandboard then yes, the device is "handled" that way.

                However if by "handled" you mean I can move the "cursor" around on the desktop then no, it is not "handled" by the desktop environment.

                1 Reply Last reply
                0
                • SGaistS Offline
                  SGaistS Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on last edited by
                  #8

                  Good, then I'd recommend taking a look at this article about a custom QPlatformInputContext and this excellent KDAB post about the same subject.

                  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
                  1
                  • M Offline
                    M Offline
                    MatthewLai
                    wrote on last edited by
                    #9

                    Thanks for the articles!

                    Just a quick follow up question: suppose I re-phrase my original question to a more generic context like "I have 2 mice in my system, and I have widgets in my Qt such that half of the widgets should handle mouse 1 events while the other half of the widgets should handle mouse 2 events." Is there a quick way to support this usecase?

                    1 Reply Last reply
                    0
                    • SGaistS Offline
                      SGaistS Offline
                      SGaist
                      Lifetime Qt Champion
                      wrote on last edited by
                      #10

                      Two mice would not be the same situation you have with PowerMate knobs so you should rather open a new thread.

                      However, I don't know whether Qt receives enough information from the system to allow distinction about which cursor triggered the event.

                      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
                      0

                      • Login

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • Users
                      • Groups
                      • Search
                      • Get Qt Extensions
                      • Unsolved