免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 717 | 回复: 0
打印 上一主题 下一主题

Character input in Qt/Embedded (keyboard driver ) [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2008-05-06 21:18 |只看该作者 |倒序浏览

Internally in the client/server protocol, each key press and key release is sent as a QWSKeyEvent. A QWSKeyEvent contains the following fields:
unicode
Unicode value
keycode
Qt keycode value as defined in
qnamespace.h

modifier
A bitfield consisting of some of
Qt::ShiftButton
,
Qt::ControlButton
, and
Qt::AltButton
.
is_press
TRUE if this is a key press, FALSE if it is a key release.
is_auto_repeat
TRUE if this event is caused by auto repeat.
When the server receives a key event it is sent to each client process which is responsible for processing the key event and sending it to the right window, if any. Key events may come from several different sources.
Keyboard drivers
A keyboard driver reads data from a device and gives key events to the server.
Keyboard drivers can be compiled into the library or loaded as plugins. Running ./configure -help lists the available keyboard drivers. The "tty" driver is enabled in the default configuration.
The keyboard drivers all follow the same pattern. They read keyboard data from a device, find out which keys were pressed, and then call the static function QWSServer::processKeyEvent() with the key information.
At present, the console keyboard driver also handles console switching (Ctrl+Alt-F1...Ctrl+Alt+F10) and termination (Ctrl+Alt+Backspace).
To add a keyboard driver for a new device, subclasses of
QWSKeyboardHandler
and
QKbdDriverPlugin
can be written and installed as plugins.
Key event filters (input methods)
When the server receives a key event from a keyboard driver, it first passes it through a filter.
This can be used to implement input methods, providing input of characters that are not on the keyboard.
To make an input method, subclass QWSServer::KeyboardFilter (in src/kernel/qwindowsystem_qws.h) and implement the virtual function filter(). If filter() returns FALSE, the event will be sent to the clients (using
QWSServer::sendKeyEvent
()). If filter() returns TRUE, the event will be stopped. To generate new key events, use QWSServer::sendKeyEvent(). (Do not use processKeyEvent(), since this will lead to infinite recursion.)
To install a keyboard event filter, use
QWSServer::setKeyboardFilter
(). Currently, only one filter can be installed at a time.
Filtering must be done in the server process.
The launcher example contains an example of a simple input method, SimpleIM which reads a substitution table from a file.
原文地址
http://doc.trolltech.com/3.2/emb-charinput.html


本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u2/67519/showart_678203.html
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP