qt 键盘驱动分析

论坛 期权论坛 脚本     
已经匿名di用户   2022-5-29 19:15   2932   0

http://www.cuteqt.com/blog/?p=322

qkbdlinuxinput.cpp

QWSKeyboardHandler::KeycodeAction ka;
ka = m_handler->processKeycode(code, value != 0, value == 2);

qkbd_qws.cpp

// simple builtin US keymap

//包含了默认的s_keymap_default和s_keycompose_default
#include "qkbd_defaultmap_qws_p.h"

// the unloadKeymap() function needs to be AFTER the defaultmap include,
// since the sizeof(s_keymap_default) wouldn't work otherwise.

void QWSKbPrivate::unloadKeymap()
{
if (m_keymap && m_keymap != s_keymap_default)
delete [] m_keymap;
if (m_keycompose && m_keycompose != s_keycompose_default)
delete [] m_keycompose;

m_keymap = s_keymap_default;
m_keymap_size = sizeof(s_keymap_default) / sizeof(s_keymap_default[0]);
m_keycompose = s_keycompose_default;
m_keycompose_size = sizeof(s_keycompose_default) / sizeof(s_keycompose_default[0]);

// reset state, so we could switch keymaps at runtime
m_modifiers = 0;
memset(m_locks, 0, sizeof(m_locks));
m_composing = 0;
m_dead_unicode = 0xffff;
}

Maps keycode according to a keymap and sends that key event to the Qt for Embedded Linux server application.

QWSKeyboardHandler::KeycodeAction QWSKeyboardHandler::processKeycode(quint16 keycode, bool pressed, bool autorepeat)

{

……

// send the result to the QWS server
processKeyEvent(unicode, qtcode & ~modmask, Qt::KeyboardModifiers(qtcode & modmask), pressed, autorepeat);

}

Note that this function does not handle key mapping. Please use processKeycode() if you need that functionality.

void QWSKeyboardHandler::processKeyEvent(int unicode, int keycode, Qt::KeyboardModifiers modifiers,
bool isPress, bool autoRepeat)
{
qwsServer->processKeyEvent(unicode, keycode, modifiers, isPress, autoRepeat);
}

分享到 :
0 人收藏
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

积分:81
帖子:4969
精华:0
期权论坛 期权论坛
发布
内容

下载期权论坛手机APP