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.

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

qt5.3.2 everywhere evdev keyboard&mouse

看到没有?!最关键的参数:-mtdev   -evdev ,因为运行的时候需要输入: ./zsy.bin -platform linuxfb -plugin evdevkeyboard=/dev/in...

Qt libqevdevtouchplugin.so插件的改写

前段项目中用到了触摸屏,驱动已经做好,需要做一个触摸屏插件供ui调用,在网上查到了很多资料都是关于tslib的移植,由于之前键盘插件的开发是在qt官方提供的插件源码上修改的,这次也尝试着去改官方插件(...
  • zzwdkxx
  • zzwdkxx
  • 2015年07月24日 15:32
  • 1715

Qt5.7 Qt for Embedded Linux

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

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

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

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

使用FrendlyARM arm-toolchain-4.5.1交叉工具链,在

[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版本,不...

QT5的软键盘输入法

软键盘

Qt5软键盘实现中文拼音输入法

基于Qt实现的虚拟键盘实现输入法在网上所有资料看来,几乎都是基于生成的中文汉字数据库实现的方法,不够灵活,不够智能。 拼音输入法的库我们采用的安卓底层的谷歌拼音输入法,在Qt5.7之后,Qt官方也出了...
  • onlyshi
  • onlyshi
  • 2017年10月31日 20:59
  • 202

Delphi7高级应用开发随书源码

  • 2003年04月30日 00:00
  • 676KB
  • 下载

Linux开发二十二_Qt移植

Qt是跨平台的应用程序和UI框架,它包括跨平台类库、集成开发工具和跨平台IDE。使用Qt只需一次性开发应用程序,无须重新编写源代码,便可跨不同桌面和嵌入式操作系统部署这些应用程序。...
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:qt5输入的一些细节
举报原因:
原因补充:

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