官网上有介绍到
The mouse cursor shows up whenever QT_QPA_EGLFS_HIDECURSOR
(for eglfs) orQT_QPA_FB_HIDECURSOR
(for linuxfb) is not set and Qt's libudev-based device discovery reports that at least one mouse is available. Whenlibudev
support is not present, the mouse cursor always show up unless explicitly disabled via the environment variable.
Hot plugging is supported, but only if Qt was configured withlibudev
support (that is, if thelibudev development headers are present in the sysroot at configure time). This allows connecting or disconnecting an input device while the application is running.
说是说的比较清楚了,在libudev被支持的情况下热插拔是支持的。同时也说了,在QT配置时,需要在sysroot下有libudev的头文件。
刚看完时没有看清楚这几句话,就在configure --help下去找libudev、udev,都没找到选项。然后就直接到QTSRCROOT下的configure里找,也没有。
找错了,就到QTSRCROOT/qtbase下的configure下找,还真有。
libudev)
if [ "$VAL" = "yes" ] || [ "$VAL" = "no" ]; then
CFG_LIBUDEV="$VAL"
else
UNKNOWN_OPT=yes
fi
;;
if [ "$CFG_LIBUDEV" != "no" ]; then
if [ -n "$PKG_CONFIG" ] && $PKG_CONFIG --exists libudev 2>/dev/null; then
QMAKE_INCDIR_LIBUDEV=`$PKG_CONFIG --cflags-only-I libudev 2>/dev/null | sed -e 's,^-I,,g' -e 's, -I, ,g'`
QMAKE_LIBS_LIBUDEV=`$PKG_CONFIG --libs libudev 2>/dev/null`
QMAKE_CFLAGS_LIBUDEV=`$PKG_CONFIG --cflags libudev 2>/dev/null`
QMakeVar set QMAKE_INCDIR_LIBUDEV "$QMAKE_INCDIR_LIBUDEV"
QMakeVar set QMAKE_LIBS_LIBUDEV "$QMAKE_LIBS_LIBUDEV"
fi
if compileTest unix/libudev "libudev" $QMAKE_CFLAGS_LIBUDEV $QMAKE_LIBS_LIBUDEV; then
CFG_LIBUDEV=yes
QT_CONFIG="$QT_CONFIG libudev"
elif [ "$CFG_LIBUDEV" = "yes" ]; then
echo "The libudev functionality test failed!"
[ -z "$PKG_CONFIG" ] && echo " Use of pkg-config is not enabled, maybe you want to pass -pkg-config?"
exit 1
else
CFG_LIBUDEV=no
fi
fi
......
没有配置项,就是直接自动检测的。于是查看配置输出libudev auto-detection... ()
arm-linux-g++ -c -pipe -O2 -Wall -W -fPIC -I/home/ubuntu/app/qt-5.6.0/qtbase/config.tests/unix/libudev -I. -I/home/ubuntu/app/tslib/include -I/home/ubuntu/app/qt-5.6.0/qtbase/mkspecs/linux-arm-gnueabi-g++ -o libudev.o /home/app/qt-5.6.0/qtbase/config.tests/unix/libudev/libudev.cpp
/home/ubuntu/app/qt-5.6.0/qtbase/config.tests/unix/libudev/libudev.cpp:34:21: error: libudev.h: No such file or directory
/home/ubuntu/app/qt-5.6.0/qtbase/config.tests/unix/libudev/libudev.cpp: In function ‘int main()’:
/home/ubuntu/app/qt-5.6.0/qtbase/config.tests/unix/libudev/libudev.cpp:38: error: ‘udev’ was not declared in this scope
/home/ubuntu/app/qt-5.6.0/qtbase/config.tests/unix/libudev/libudev.cpp:38: error: ‘u’ was not declared in this scope
/home/ubuntu/app/qt-5.6.0/qtbase/config.tests/unix/libudev/libudev.cpp:38: error: ‘udev_new’ was not declared in this scope
/home/ubuntu/app/qt-5.6.0/qtbase/config.tests/unix/libudev/libudev.cpp:39: error: ‘udev_unref’ was not declared in this scope
make: *** [libudev.o] Error 1
libudev disabled.
需要libudev.h头文件。得移植udev。然后重新配置 使出现libudev enabled,libudev测试通过。
但是拿到开发板上,还是不支持热插拔啊。
还得好好理解官网上的话
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.
libinput is a library to handle input devices. It offers an alternative to the Qt's own evdev
input support. To enable using libinput
, make sure the development files for libudev
and libinput
are available when configuring and building Qt. xkbcommon
is also necessary if keyboard support is desired. With eglfs
and linuxfb
no further actions are necessary as these plugins use libinput
by default. 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.
Parameters like the device node name can be set in the environment variables QT_QPA_EVDEV_MOUSE_PARAMETERS
, QT_QPA_EVDEV_KEYBOARD_PARAMETERS
and QT_QPA_EVDEV_TOUCHSCREEN_PARAMETERS
. Additionally, the built-in input handlers can be disabled by setting QT_QPA_EGLFS_DISABLE_INPUT
or QT_QPA_FB_DISABLE_INPUT
to 1
. On some touch screens the coordinates must be rotated, which is done by setting QT_QPA_EVDEV_TOUCHSCREEN_PARAMETERS
to rotate=180
.
The mouse cursor shows up whenever QT_QPA_EGLFS_HIDECURSOR
(for eglfs) or QT_QPA_FB_HIDECURSOR
(for linuxfb) is not set and Qt's libudev-based device discovery reports that at least one mouse is available. When libudev
support is not present, the mouse cursor always show up unless explicitly disabled via the environment variable.
Hot plugging is supported, but only if Qt was configured with libudev
support (that is, if the libudev development headers are present in the sysroot at configure time). This allows connecting or disconnecting an input device while the application is running.
The evdev keyboard handler supports the following extra parameters:
/dev/input/...
- Specifies the name of the input device. When not given, Qt looks for a suitable device either via libudev or by walking through the available nodes.grab
- Enables grabbing the input device.keymap
- Specifies the name of a custom keyboard map file.enable-compose
- Enables compositing.repeat-delay
- Sets a custom key repeat delay.repeat-rate
- Sets a custom key repeat rate.On Embedded Linux systems that do not have their terminal sessions disabled, the behavior on a key press can be confusing as input event is processed by the Qt application and the tty. To overcome this, the following options are available:
K_OFF
. This prevents keystrokes from going to the terminal. If the standard behavior needs to be restored for some reason, set the environment variable QT_QPA_ENABLE_TERMINAL_KEYBOARD
to 1
. Note that this works only when the application is launched from a remote console (for example, via ssh
) and the terminal keyboard input remains enabled.grab
parameter by passing grab=1 in QT_QPA_EVDEV_KEYBOARD_PARAMETERS
. This results in trying to get a grab on the input device. If the grab
is successful, no other components in the system receive events from it as long as the Qt application is running. This approach is more suitable for applications started remotely as it does not need access to the tty device.SYSVINIT_ENABLED_GETTYS
results in having no getty
process running, and thus no input, on any of the virtual terminals.If the default built-in keymap is not sufficient, a different one can be specified either via the keymap
parameter or by using the eglfs-specific loadKeymap() function. The latter allows switching the keymap at runtime. Note however that this requires using eglfs' built-in keyboard handler; it is not supported when the keyboard handler is loaded via the -plugin
command-line parameter.
Note: Special system key combinations, such as console switching (Ctrl+Alt+Fx) or zap (Ctrl+Alt+Backspace) are not currently supported and are ignored.
To generate a custom keymap, the kmap2qmap utility can be used. This can be found in the qttools module. The source files have to be in standard Linux kmap
format, which is understood by the kernel's loadkeys
command. This means one can use the following sources to generate qmap
files:
kmap
format with the ckbcomp
utility.kmap
files are plain-text files, they can also be hand crafted.kmap2qmap
is a command line program, that needs at least 2 files as parameters. The last one is the generated .qmap
file, while all the others are parsed as input .kmap
files. For example:
kmap2qmap i386/qwertz/de-latin1-nodeadkeys.kmap include/compose.latin1.inc de-latin1-nodeadkeys.qmap
Note: kmap2qmap
does not support all the (pseudo) symbols that the Linux kernel supports. When converting a standard keymap, a number of warnings will be shown regarding Show_Registers
, Hex_A
, and so on; these messages can safely be ignored.
For some resistive, single-touch touch screens it may be necessary to fall back to using tslib
instead of relying on the Linux multi-touch protocol and the event devices. For modern touch screens this is not necessary. tslib
support can be enabled by setting the environment variable QT_QPA_EGLFS_TSLIB
or QT_QPA_FB_TSLIB
to 1. To change the device, set the environment variable TSLIB_TSDEVICE
or pass the device name on the command-line. Note that the tslib
input handler generates mouse events and supports single touch only, as opposed to evdevtouch
which generates true multi-touch QTouchEvent events too.
The evdevtablet
plugin provides basic support for Wacom and similar, pen-based tablets. It generates QTabletEvent events only. To enable it, pass QT_QPA_GENERIC_PLUGINS=evdevtablet
in the environment or, alternatively, pass -plugin evdevtablet
argument on the command-line. The plugin can take a device node parameter, for example QT_QPA_GENERIC_PLUGINS=evdevtablet:/dev/event1
, in case the Qt's automatic device discovery (based either on libudev or a walkthrough of /dev/input/event*
) is not functional or misbehaving.
It is possible to print some information to the debug output by enabling the qt.qpa.input
logging rule, for example by setting the QT_LOGGING_RULES
environment variable to qt.qpa.input=true
. This is useful for detecting which device is being used, or to troubleshoot device discovery issues.
eglfs
comes with its own set of 32x32 sized mouse cursor images. If these are not sufficient, a custom cursor atlas can be provided by setting the QT_QPA_EGLFS_CURSOR
environment variable to the name of a JSON file. The file can also be embedded into the application via Qt's resource system.
For example, an embedded cursor atlas with 8 cursor images per row can be specified like the following:
{
"image": ":/cursor-atlas.png",
"cursorsPerRow": 8,
"hotSpots": [
[7, 2],
[12, 3],
[12, 12],
...
]
}
Note that the images are expected to be tightly packed in the atlas: the width and height of the cursors are decided based on the total image size and the cursorsPerRow
setting. Atlases have to provide an image for all the supported cursors.
到底要怎么做呢