eglfs: keyboard not grabbed

2.3k views Asked by At

Raspbian running on RPi3B+, Qt5.9.2 cross-compiled, QWidget application. The keyboard input goes to the shell behind instead to my application. Following this document I set the following env vars:

LD_LIBRARY_PATH=/home/pi/bin
QT_QPA_EVDEV_KEYBOARD_PARAMETERS=/dev/input/event1;grab=1
QT_QPA_ENABLE_TERMINAL_KEYBOARD=1
QT_QPA_GENERIC_PLUGINS=evdevmouse,evdevkeyboard
QT_QPA_EGLFS_FORCE888=1
QT_QPA_PLATFORM=eglfs
QT_QPA_EGLFS_DEBUG=1

and tried to run the application either locally (i.e. sitting in front of the target) or via SSH. The behavior is the same.

Instead, the mouse works fine.

Is there something I didn't understand in that document?

1

There are 1 answers

0
Francisco Ramírez On

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 response:

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!