qt5输入的一些细节

原创 2015年07月06日 17:35:43

Input

When no windowing system is present,

the mouse, keyboard and touch input are read directly via evdev or using helper libraries like tslib.

Note that this requires that devices nodes /dev/input/event* are readable by the user.

eglfs and linuxfb has all the evdev input handling code built-in.

直接从evdev读入?

也就是说只要输入符合input规范,qt就能直接收到????也就是说

对于自定义键盘,要在驱动中转换为标准的按键值吗?

Input on eglfs and linuxfb

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 will need to be rotated. This can be enabled by setting QT_QPA_EVDEV_TOUCHSCREEN_PARAMETERS to rotate=180.

Mouse

The mouse cursor will show 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 will 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.

Keyboard

The evdev keyboard handler supports the following extra parameters:

  • /dev/input/... - Specifies the name of the input device. When not given, Qt will look 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 when pressing a key can be confusing due to having the input event processed both by the Qt application and the tty. To overcome this, the following options are available:

  • EGLFS, LinuxFB and KMS attempt to disable the terminal keyboard on application startup by setting the tty's keyboard mode to 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 will not work when the application is launched from a remote console (for example, via ssh) and the terminal keyboard input will remain enabled.
  • An alternative approach is to use the evdev keyboard handler's grab parameter by passing grab=1 in QT_QPA_EVDEV_KEYBOARD_PARAMETERS. This results in trying to get a grab on the input device which, if successful, means that 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.
  • Finally, for many specialized Embedded Linux images it will not make sense to have the standard terminal sessions enabled in the first place. Refer to your build environment's documentation on how to disable them. For example, when generating images using the Yocto Project, unsetting SYSVINIT_ENABLED_GETTYS will result 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 will get 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 that is e.g. understood by the kernel's loadkeys command. This means one can use the following sources to generate qmap files:

  • The Linux Console Tools (LCT) project.
  • Xorg X11 keymaps can be converted to the kmap format with the ckbcomp utility.
  • As 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 will be the generated .qmap file, while all the others will be 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.

Touch

For some resistive, single-touch touch screens it may be necessary to fall back to using tslib instead of relying on the Linux multitouch protocol and the event devices. For modern touch screens this should not be 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.

版权声明:本文为博主原创文章,未经博主允许不得转载。

UBUNTU下QT开发应用程序常见错误及其解决办法

cannot find -lGL
  • sidely
  • sidely
  • 2014年10月21日 17:06
  • 7452

交叉编译Qt5.2.1让其支持触摸屏多点触摸

编译环境和上一篇一样.http://blog.csdn.net/mkndg/article/details/26359055 只是qt的configure不同,文件系统的profile不同....
  • MKNDG
  • MKNDG
  • 2014年05月23日 17:25
  • 4367

Linux开发二十二_Qt移植

Qt是跨平台的应用程序和UI框架,它包括跨平台类库、集成开发工具和跨平台IDE。使用Qt只需一次性开发应用程序,无须重新编写源代码,便可跨不同桌面和嵌入式操作系统部署这些应用程序。...
  • huang20083200056
  • huang20083200056
  • 2017年04月23日 01:40
  • 496

qt5.5.1在Cortex-a8上移植记录

使用Qt5.5.1源码包进行编译:下载地址 http://download.qt.io/official_releases/qt/ 1、进入源码包根目录,配置qtbase/mkspecs/linu...
  • dujiqian
  • dujiqian
  • 2015年11月02日 19:41
  • 1442

基于珠海鼎芯IMX6在eglfs平台下Qt5触摸屏问题

将已经交叉编译后的Qt5和tslib移植到imx6开发板上。 一、运行tslib下bin/ts_calibrate(五点校准) 1)出现:  No raw modules loaded....
  • baidu_16092131
  • baidu_16092131
  • 2016年10月22日 14:21
  • 1011

[Qt配置指南—5]Qt 5.4.2 Configure Options---Qt for Embeded Linux嵌入式Linux

如有错误,欢迎批评指正!!! Qt for Embeded Linux 这里着重讨,http://doc.qt.io/qt-5/embedded-linux.html 由于Qt5版本,不...
  • RomeoLikeJuliet
  • RomeoLikeJuliet
  • 2017年01月03日 13:36
  • 1716

Qt5.7 Qt for Embedded Linux

从Qt5.0开始,Qt不再包含自己的视窗系统了(QWS)。对于单屏幕的情况,使用QtPlatform Abstraction是一个很好的选择。多屏的情况可以通过Wayland实现。          ...
  • chongzi865458
  • chongzi865458
  • 2017年01月13日 11:18
  • 3437

QT5.5.1 嵌入式平台 鼠标键盘不能热插拔问题解决(一)

前言:         由于项目需要,采用qt5.5.1开发界面,要求支持键鼠。经过uboot/kernel/fs的移植之后usb接口的热插拔已经OK,但是QT怎么也不支持热插拔,工作任务和强迫症双...
  • shengzhadon
  • shengzhadon
  • 2016年05月19日 17:04
  • 3690

Qt-5.3.2 在友善Smart210开发板的移植记录

使用FrendlyARM arm-toolchain-4.5.1交叉工具链,在
  • NewThinker_wei
  • NewThinker_wei
  • 2014年09月26日 00:28
  • 30970

libudev使用说明书

libudev使用说明书 1. 初始化 首先调用udev_new,创建一个udev library context。udev library context采用引用记数机制,创建的context默...
  • coroutines
  • coroutines
  • 2014年07月23日 17:28
  • 8149
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:qt5输入的一些细节
举报原因:
原因补充:

(最多只允许输入30个字)