Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Rotary encoder & Qt Events?
Forum Updated to NodeBB v4.3 + New Features

Rotary encoder & Qt Events?

Scheduled Pinned Locked Moved Solved General and Desktop
7 Posts 3 Posters 1.2k 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.
  • D Offline
    D Offline
    deleted544
    wrote on last edited by deleted544
    #1

    Currently i'm having a rotary encoder hooked up to my Linux Platform. Its listed as input under: /dev/input/event0

    Its generating the following output:

    Testing ... (interrupt to exit)
    Event: time 1325378916.979387, type 2 (EV_REL), code 0 (REL_X), value 1
    Event: time 1325378916.979387, -------------- SYN_REPORT ------------
    Event: time 1325378917.328441, type 2 (EV_REL), code 0 (REL_X), value 1
    Event: time 1325378917.328441, -------------- SYN_REPORT ------------
    Event: time 1325378919.692222, type 2 (EV_REL), code 0 (REL_X), value -1
    Event: time 1325378919.692222, -------------- SYN_REPORT ------------
    Event: time 1325378919.760467, type 2 (EV_REL), code 0 (REL_X), value -1
    

    Im trying to get input from the rotary in Qt with the following software in Qml

    Keys.onPressed: (event)=> {
                            print(event.key);       /* Print out key */
                            print(event);              /* Print event */
    

    Its responding to keyboard input and buttons on the Platform. But its not reacting on the rotary encoder.

    Output from buttons on the pcb:

    qml: 48
    qml: QQuickKeyEvent(0xa3550)
    qml: 48
    qml: QQuickKeyEvent(0xa3550)
    qml: 49
    

    What is the right way to achieve communicating with the rotary encoder?

    1 Reply Last reply
    0
    • D Offline
      D Offline
      deleted544
      wrote on last edited by
      #7

      Found the solution.

      Using

      QT_QPA_GENERIC_PLUGINS=evdevmouse:/dev/input/event0
      

      Forced to use event0 as mouse.

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

        Hi and welcome to devnet,

        Is that encoder seen as a proper keyboard ?
        How do you make it known to your application ?

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

        D 1 Reply Last reply
        0
        • SGaistS SGaist

          Hi and welcome to devnet,

          Is that encoder seen as a proper keyboard ?
          How do you make it known to your application ?

          D Offline
          D Offline
          deleted544
          wrote on last edited by
          #3

          @SGaist

          Currently the rotary encoder is installed in the kernel under the device tree.

          	rotary@0 {
          		compatible = "rotary-encoder";
          		gpios = <&gpio 19 1>, <&gpio 20 0>; /* GPIO19 is inverted */
          		linux,axis = <0>; /* REL_X */
          		rotary-encoder,encoding = "gray";
          		rotary-encoder,relative-axis;
          	};
          

          Its working with evtest (as well as the keyboard). But Qt does not seems to react on its event's like it does on buttons on the platform and keyboard.

          1 Reply Last reply
          0
          • D Offline
            D Offline
            deleted544
            wrote on last edited by
            #4

            It seems like that Qml needs to react on mouse events. Is there an handler provided for mouse events in Qml?

            J.HilkJ 1 Reply Last reply
            0
            • D deleted544

              It seems like that Qml needs to react on mouse events. Is there an handler provided for mouse events in Qml?

              J.HilkJ Offline
              J.HilkJ Offline
              J.Hilk
              Moderators
              wrote on last edited by
              #5

              @DrWhoozy
              the 2 ways I know of are:

              • Installing an event filter on your QApplication and forwarding that to your qml instance
              • using a MouseArea Item with hoverEnabled -> mouseX and mouseY

              Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


              Q: What's that?
              A: It's blue light.
              Q: What does it do?
              A: It turns blue.

              D 1 Reply Last reply
              0
              • J.HilkJ J.Hilk

                @DrWhoozy
                the 2 ways I know of are:

                • Installing an event filter on your QApplication and forwarding that to your qml instance
                • using a MouseArea Item with hoverEnabled -> mouseX and mouseY
                D Offline
                D Offline
                deleted544
                wrote on last edited by deleted544
                #6

                @J-Hilk

                Thanks for your response. Currently im experiencing some issues with Qt ignoring my rotary input. I've printed every event that Qt handles and it seems that it listens to USB mouse input and not my rotary. The events from an USB mouse and Rotary are looking the same...

                When using the mouse on "every event" the result fom Qt is

                Event:  QEvent::MouseMove
                Watched:  ""
                Event:  QEvent::HoverMove
                Watched:  ""
                X:  242 Y:  301
                

                But it keeps quiet on the rotary event's.......

                When putting on evtest im retreiving the following input from my mouse:

                Event: time 1325455622.178946, type 2 (EV_REL), code 0 (REL_X), value 1
                Event: time 1325455622.178946, type 2 (EV_REL), code 1 (REL_Y), value -2
                Event: time 1325455622.178946, -------------- SYN_REPORT ------------
                Event: time 1325455622.186938, type 2 (EV_REL), code 0 (REL_X), value 1
                Event: time 1325455622.186938, type 2 (EV_REL), code 1 (REL_Y), value -3
                

                And from the rotary

                Event: time 1325455664.958945, type 2 (EV_REL), code 0 (REL_X), value -1
                Event: time 1325455664.958945, -------------- SYN_REPORT ------------
                Event: time 1325455664.966906, type 2 (EV_REL), code 0 (REL_X), value -1
                Event: time 1325455664.966906, -------------- SYN_REPORT ------------
                Event: time 1325455665.545176, type 2 (EV_REL), code 0 (REL_X), value 1
                Event: time 1325455665.545176, -------------- SYN_REPORT ------------
                Event: time 1325455665.548966, type 2 (EV_REL), code 0 (REL_X), value 1
                Event: time 1325455665.548966, -------------- SYN_REPORT ------------
                

                So we can more likely conclude that the rotary is acting like a mouse device. However Qt thinks different...

                When using strace on the Qt Application it calls the input0

                openat(12, "input0", O_RDONLY|O_LARGEFILE|O_NOFOLLOW|O_CLOEXEC|O_PATH) = 11                                                     
                fstat64(11, {st_mode=S_IFLNK|0777, st_size=0, ...}) = 0                        
                readlinkat(12, "input0", "../../devices/platform/rotary/in"..., 4096) = 42
                

                I tried to force it by setting some environment variables such as:

                QT_LOGGING_RULES="qt.qpa.*=true"         // For Logging
                TSLIB_TSDEVICE="/dev/input/event0"
                

                But somehow the events are not coming through.

                1 Reply Last reply
                0
                • D Offline
                  D Offline
                  deleted544
                  wrote on last edited by
                  #7

                  Found the solution.

                  Using

                  QT_QPA_GENERIC_PLUGINS=evdevmouse:/dev/input/event0
                  

                  Forced to use event0 as mouse.

                  1 Reply Last reply
                  4

                  • Login

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