QWSKeyboardHandler Class

The QWSKeyboardHandler class is a base class for keyboard drivers in Qt for Embedded Linux. 更多...

头: #include <QWSKeyboardHandler>

公共类型

enum KeycodeAction { None, CapsLockOn, CapsLockOff, NumLockOn, ..., Reboot }

公共函数

QWSKeyboardHandler (const QString & device )
QWSKeyboardHandler ()
virtual ~QWSKeyboardHandler ()
virtual void processKeyEvent (int unicode , int keycode , Qt::KeyboardModifiers modifiers , bool isPress , bool autoRepeat )
KeycodeAction processKeycode (quint16 keycode , bool isPress , bool autoRepeat )

保护函数

void beginAutoRepeat (int unicode , int keycode , Qt::KeyboardModifiers modifier )
void endAutoRepeat ()
int transformDirKey (int keycode )

详细描述

The QWSKeyboardHandler class is a base class for keyboard drivers in Qt for Embedded Linux.

注意,此类只可用于 Qt for Embedded Linux .

Qt for Embedded Linux provides ready-made drivers for several keyboard protocols, see the character input documentation for details. Custom keyboard drivers can be implemented by subclassing the QWSKeyboardHandler class and creating a keyboard driver plugin (derived from QKbdDriverPlugin ). The default implementation of the QKbdDriverFactory class will automatically detect the plugin, and load the driver into the server application at run-time using Qt's plugin system .

The keyboard driver receives keyboard events from the system device and encapsulates each event with an instance of the QWSEvent class which it then passes to the server application (the server is responsible for propagating the event to the appropriate client). To receive keyboard events, a QWSKeyboardHandler object will usually create a QSocketNotifier object for the given device. The QSocketNotifier class provides support for monitoring activity on a file descriptor. When the socket notifier receives data, it will call the keyboard driver's processKeyEvent () function to send the event to the Qt for Embedded Linux server application for relaying to clients.

QWSKeyboardHandler also provides functions to control auto-repetion of key sequences, beginAutoRepeat () 和 endAutoRepeat (), and the transformDirKey () function enabling transformation of arrow keys according to the display orientation.

另请参阅 QKbdDriverPlugin , QKbdDriverFactory ,和 Qt for Embedded Linux Character Input .

成员类型文档编制

enum QWSKeyboardHandler:: KeycodeAction

This enum describes the various special actions that actual QWSKeyboardHandler implementations have to take care of.

常量 描述
QWSKeyboardHandler::None 0 No further action required.
QWSKeyboardHandler::CapsLockOn 0x01000001 Set the state of the Caps lock LED to on.
QWSKeyboardHandler::CapsLockOff 0x01000000 Set the state of the Caps lock LED to off.
QWSKeyboardHandler::NumLockOn 0x02000001 Set the state of the Num lock LED to on.
QWSKeyboardHandler::NumLockOff 0x02000000 Set the state of the Num lock LED to off.
QWSKeyboardHandler::ScrollLockOn 0x03000001 Set the state of the Scroll lock LED to on.
QWSKeyboardHandler::ScrollLockOff 0x03000000 Set the state of the Scroll lock LED to off.
QWSKeyboardHandler::PreviousConsole 0x05000000 Switch to the previous virtual console (by default Ctrl+Alt+Left on Linux).
QWSKeyboardHandler::NextConsole 0x05000001 Switch to the next virtual console (by default Ctrl+Alt+Right on Linux).
QWSKeyboardHandler::SwitchConsoleFirst 0x06000000 Switch to the first virtual console (0).
QWSKeyboardHandler::SwitchConsoleLast 0x0600007f Switch to the last virtual console (255).
QWSKeyboardHandler::SwitchConsoleMask 0x0000007f If the KeyAction value is between SwitchConsoleFirst and SwitchConsoleLast, you can use this mask to get the specific virtual console number to switch to.
QWSKeyboardHandler::Reboot 0x04000000 Reboot the machine - this is ignored in both the TTY and LinuxInput handlers though (by default Ctrl+Alt+Del on Linux).

另请参阅 processKeycode ().

成员函数文档编制

QWSKeyboardHandler:: QWSKeyboardHandler (const QString & device )

Constructs a keyboard driver. The device argument is passed by the QWS_KEYBOARD 环境变量。

调用 QWSServer::setKeyboardHandler () function to make the newly created keyboard driver, the primary driver. Note that the primary driver is controlled by the system, i.e., the system will delete it upon exit.

QWSKeyboardHandler:: QWSKeyboardHandler ()

这是重载函数。

[虚拟] QWSKeyboardHandler:: ~QWSKeyboardHandler ()

Destroys this keyboard driver.

Do not call this function if this driver is the primary keyboard handler, i.e., if QWSServer::setKeyboardHandler () function has been called passing this driver as argument. The primary keyboard driver is deleted by the system.

[protected] void QWSKeyboardHandler:: beginAutoRepeat ( int unicode , int keycode , Qt::KeyboardModifiers modifier )

Begins auto-repeating the specified key press; after a short delay the key press is sent periodically until the endAutoRepeat () 函数被调用。

The key press is specified by its unicode , keycode and modifier 状态。

另请参阅 endAutoRepeat () 和 processKeyEvent ().

[protected] void QWSKeyboardHandler:: endAutoRepeat ()

Stops auto-repeating a key press.

另请参阅 beginAutoRepeat () 和 processKeyEvent ().

[虚拟] void QWSKeyboardHandler:: processKeyEvent ( int unicode , int keycode , Qt::KeyboardModifiers modifiers , bool isPress , bool autoRepeat )

Sends a key event to the Qt for Embedded Linux server application.

The key event is identified by its unicode value and the keycode , modifiers , isPress and autoRepeat 参数。

The keycode parameter is the Qt keycode value as defined by the Qt::Key enum. The modifiers is an OR combination of Qt::KeyboardModifier values, indicating whether Shift/Alt/Ctrl keys are pressed. The isPress parameter is true if the event is a key press event and autoRepeat is true if the event is caused by an auto-repeat mechanism and not an actual key press.

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

另请参阅 processKeycode (), beginAutoRepeat (), endAutoRepeat (),和 transformDirKey ().

KeycodeAction QWSKeyboardHandler:: processKeycode ( quint16 keycode , bool isPress , bool autoRepeat )

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

请参阅 Qt for Embedded Linux Character Input kmap2qmap documentations for a description on how to create and use keymap files.

The key event is identified by its keycode value and the isPress and autoRepeat 参数。

The keycode parameter is NOT the Qt keycode value as defined by the Qt::Key enum. This functions expects a standard Linux 16 bit kernel keycode as it is used in the Linux Input Event sub-system. This keycode is transformed to a Qt::Key code by using either a compiled-in US keyboard layout or by dynamically loading a keymap at startup which can be specified via the QWS_KEYBOARD 环境变量。

The isPress parameter is true if the event is a key press event and autoRepeat is true if the event is caused by an auto-repeat mechanism and not an actual key press.

The return value indicates if the actual QWSKeyboardHandler implementation needs to take care of a special action, like console switching or LED handling.

If standard Linux console keymaps are used, keycode must be one of the standardized values defined in /usr/include/linux/input.h

该函数在 Qt 4.6 引入。

另请参阅 processKeyEvent () 和 KeycodeAction .

[protected] int QWSKeyboardHandler:: transformDirKey ( int keycode )

Transforms the arrow key specified by the given keycode , to the orientation of the display and returns the transformed keycode.

The keycode Qt::Key value. The values identifying arrow keys are:

另请参阅 processKeyEvent ().