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. Block send of keyboard input to terminal on embedded app (Raspberry Pi 3)
Forum Update on Monday, May 27th 2025

Block send of keyboard input to terminal on embedded app (Raspberry Pi 3)

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
9 Posts 4 Posters 2.3k Views
  • 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.
  • E Offline
    E Offline
    Emerson Siega
    wrote on 26 Jan 2018, 11:12 last edited by Emerson Siega
    #1

    Hello

    I have an embedded app (Qt 5.7) running on Raspbian Lite, with parameter -platform linuxfb. All keyboard input is send to terminal and allow an expert user to close the application and get access to the terminal, for instance. I need to block this behavior.

    With the environment variables bellow, I can do what I want, but, only works if the app is running with root user, and I do not want this. There is a specific user, with the right privileges to run the application.

    /etc/bash.bashrc:

    QT_QPA_ENABLE_TERMINAL_KEYBOARD=0
    QT_QPA_EVDEV_KEYBOARD_PARAMETERS=grab=1
    

    If someone knows how to fix this, I will be very thankful.

    J 1 Reply Last reply 26 Jan 2018, 11:51
    0
    • E Emerson Siega
      26 Jan 2018, 11:12

      Hello

      I have an embedded app (Qt 5.7) running on Raspbian Lite, with parameter -platform linuxfb. All keyboard input is send to terminal and allow an expert user to close the application and get access to the terminal, for instance. I need to block this behavior.

      With the environment variables bellow, I can do what I want, but, only works if the app is running with root user, and I do not want this. There is a specific user, with the right privileges to run the application.

      /etc/bash.bashrc:

      QT_QPA_ENABLE_TERMINAL_KEYBOARD=0
      QT_QPA_EVDEV_KEYBOARD_PARAMETERS=grab=1
      

      If someone knows how to fix this, I will be very thankful.

      J Offline
      J Offline
      jsulm
      Lifetime Qt Champion
      wrote on 26 Jan 2018, 11:51 last edited by
      #2

      @Emerson-Siega Can't you put this in bash.bashrc of that user?

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      E 1 Reply Last reply 26 Jan 2018, 11:59
      0
      • J jsulm
        26 Jan 2018, 11:51

        @Emerson-Siega Can't you put this in bash.bashrc of that user?

        E Offline
        E Offline
        Emerson Siega
        wrote on 26 Jan 2018, 11:59 last edited by
        #3

        @jsulm Thank's for your answer!

        Yes, I already tried this, but doesn't work.
        I tried to put this on command line when run the app, but failed too.

        1 Reply Last reply
        0
        • S Offline
          S Offline
          SGaist
          Lifetime Qt Champion
          wrote on 26 Jan 2018, 21:55 last edited by
          #4

          Hi,

          Do you have any use of the keyboard for 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

          E 1 Reply Last reply 29 Jan 2018, 10:27
          0
          • S SGaist
            26 Jan 2018, 21:55

            Hi,

            Do you have any use of the keyboard for your application ?

            E Offline
            E Offline
            Emerson Siega
            wrote on 29 Jan 2018, 10:27 last edited by
            #5

            @SGaist Hello,

            Yes, basically all interaction come from keyboard input.
            Disable this input to terminal it's a security issue...

            1 Reply Last reply
            0
            • S Offline
              S Offline
              SGaist
              Lifetime Qt Champion
              wrote on 29 Jan 2018, 23:02 last edited by
              #6

              IIRC, in /etc/init/, you can find the tty related configuration. If you disable them, you shouldn't be able to access the tty.

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

              E 1 Reply Last reply 1 Feb 2018, 11:47
              0
              • S SGaist
                29 Jan 2018, 23:02

                IIRC, in /etc/init/, you can find the tty related configuration. If you disable them, you shouldn't be able to access the tty.

                E Offline
                E Offline
                Emerson Siega
                wrote on 1 Feb 2018, 11:47 last edited by
                #7

                @SGaist Thanks for your help.
                I'll take a look at that and then I will post the result here.

                1 Reply Last reply
                0
                • F Offline
                  F Offline
                  Francisco01
                  wrote on 21 Jan 2019, 16:50 last edited by Francisco01
                  #8

                  Hi, it works for me with:

                  export QT_QPA_EVDEV_KEYBOARD_PARAMETERS=grab=1 
                  export QT_QPA_EVDEV_MOUSE_PARAMETERS=grab=1
                  

                  and running with:

                  sudo -E ./myapp -platform eglfs
                  

                  I think sudo is needed because of what documentation says about /dev/input/event* permissions. Also -E option is needed so that sudo preserves the exported variables.

                  I hope this help.

                  Qt for Embedded Linux

                  Input
                  When no windowing system is present, the mouse, keyboard, and touch input are read directly via evdev or using helper libraries such as libinput or tslib. Note that this requires that device nodes /dev/input/event* are readable by the user. eglfs and linuxfb have all the input handling code compiled-in.


                  --------

                  I want to share additional information about my previous post:

                  This is the list of exports with which I prevent that the mouse and keyboard events were passed to the terminal and the X11 system from my app:

                  export QT_QPA_EGLFS_PHYSICAL_WIDTH=155
                  export QT_QPA_EGLFS_PHYSICAL_HEIGHT=86
                  export QT_QPA_EGLFS_WIDTH=1024
                  export QT_QPA_EGLFS_HEIGHT=614
                  export QT_QPA_EVDEV_KEYBOARD_PARAMETERS=grab=1
                  export QT_QPA_EVDEV_MOUSE_PARAMETERS=grab=1
                  export QT_QPA_EGLFS_NO_LIBINPUT=1
                  

                  Note that export QT_QPA_EGLFS_NO_LIBINPUT=1 is necessary so Qt's own evdev handlers come in to play and consequently QT_QPA_EVDEV* options take into account. That is what I could verify.

                  Qt for Embedded Linux

                  Using libinput
                  ... If libinput support is not available or the environment variable QT_QPA_EGLFS_NO_LIBINPUT is set, Qt's own evdev handlers come in to play.

                  Also, as a comment, I tried this configuration, first with a mouse and keyboard controlled with a same USB (Logitech) and like that: the keyboard worked correctly but not the mouse. So I decided to try with independent mouse and keyboard, and now both (mouse & keyboard) work correctly.

                  Nor do I have to run my application with SUDO or SUDO -E, since the directory /dev/input/event* has read/write permissions for the 'input' group and my user is part of that group.

                  Regards!

                  F 1 Reply Last reply 22 Jan 2019, 10:49
                  2
                  • F Francisco01
                    21 Jan 2019, 16:50

                    Hi, it works for me with:

                    export QT_QPA_EVDEV_KEYBOARD_PARAMETERS=grab=1 
                    export QT_QPA_EVDEV_MOUSE_PARAMETERS=grab=1
                    

                    and running with:

                    sudo -E ./myapp -platform eglfs
                    

                    I think sudo is needed because of what documentation says about /dev/input/event* permissions. Also -E option is needed so that sudo preserves the exported variables.

                    I hope this help.

                    Qt for Embedded Linux

                    Input
                    When no windowing system is present, the mouse, keyboard, and touch input are read directly via evdev or using helper libraries such as libinput or tslib. Note that this requires that device nodes /dev/input/event* are readable by the user. eglfs and linuxfb have all the input handling code compiled-in.


                    --------

                    I want to share additional information about my previous post:

                    This is the list of exports with which I prevent that the mouse and keyboard events were passed to the terminal and the X11 system from my app:

                    export QT_QPA_EGLFS_PHYSICAL_WIDTH=155
                    export QT_QPA_EGLFS_PHYSICAL_HEIGHT=86
                    export QT_QPA_EGLFS_WIDTH=1024
                    export QT_QPA_EGLFS_HEIGHT=614
                    export QT_QPA_EVDEV_KEYBOARD_PARAMETERS=grab=1
                    export QT_QPA_EVDEV_MOUSE_PARAMETERS=grab=1
                    export QT_QPA_EGLFS_NO_LIBINPUT=1
                    

                    Note that export QT_QPA_EGLFS_NO_LIBINPUT=1 is necessary so Qt's own evdev handlers come in to play and consequently QT_QPA_EVDEV* options take into account. That is what I could verify.

                    Qt for Embedded Linux

                    Using libinput
                    ... If libinput support is not available or the environment variable QT_QPA_EGLFS_NO_LIBINPUT is set, Qt's own evdev handlers come in to play.

                    Also, as a comment, I tried this configuration, first with a mouse and keyboard controlled with a same USB (Logitech) and like that: the keyboard worked correctly but not the mouse. So I decided to try with independent mouse and keyboard, and now both (mouse & keyboard) work correctly.

                    Nor do I have to run my application with SUDO or SUDO -E, since the directory /dev/input/event* has read/write permissions for the 'input' group and my user is part of that group.

                    Regards!

                    F Offline
                    F Offline
                    Francisco01
                    wrote on 22 Jan 2019, 10:49 last edited by
                    #9
                    This post is deleted!
                    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