Qt 4.8
|
The QWSKeyboardHandler class is a base class for keyboard drivers in Qt for Embedded Linux. More...
#include <qkbd_qws.h>
Public Types | |
enum | KeycodeAction { None = 0, CapsLockOff = 0x01000000, CapsLockOn = 0x01000001, NumLockOff = 0x02000000, NumLockOn = 0x02000001, ScrollLockOff = 0x03000000, ScrollLockOn = 0x03000001, Reboot = 0x04000000, PreviousConsole = 0x05000000, NextConsole = 0x05000001, SwitchConsoleFirst = 0x06000000, SwitchConsoleLast = 0x0600007f, SwitchConsoleMask = 0x0000007f } |
This enum describes the various special actions that actual QWSKeyboardHandler implementations have to take care of. More... | |
Public Functions | |
KeycodeAction | processKeycode (quint16 keycode, bool pressed, bool autorepeat) |
Maps keycode according to a keymap and sends that key event to the Qt for Embedded Linux server application. More... | |
virtual void | processKeyEvent (int unicode, int keycode, Qt::KeyboardModifiers modifiers, bool isPress, bool autoRepeat) |
Sends a key event to the Qt for Embedded Linux server application. More... | |
QWSKeyboardHandler () | |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More... | |
QWSKeyboardHandler (const QString &device) | |
Constructs a keyboard driver. More... | |
virtual | ~QWSKeyboardHandler () |
Destroys this keyboard driver. More... | |
Protected Functions | |
void | beginAutoRepeat (int uni, int code, Qt::KeyboardModifiers mod) |
Begins auto-repeating the specified key press; after a short delay the key press is sent periodically until the endAutoRepeat() function is called. More... | |
void | endAutoRepeat () |
Stops auto-repeating a key press. More... | |
int | transformDirKey (int key) |
Transforms the arrow key specified by the given keycode, to the orientation of the display and returns the transformed keycode. More... | |
Properties | |
QWSKbPrivate * | d |
The QWSKeyboardHandler class is a base class for keyboard drivers in Qt for Embedded Linux.
Note that this class is only available in Qt for Embedded Linux.
Qt for Embedded Linux provides ready-made drivers for several keyboard protocols, see the Qt for Embedded Linux Character Input{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 How to Create Qt Plugins{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() and endAutoRepeat(), and the transformDirKey() function enabling transformation of arrow keys according to the display orientation.
Definition at line 57 of file qkbd_qws.h.
This enum describes the various special actions that actual QWSKeyboardHandler implementations have to take care of.
Enumerator | |
---|---|
None | |
CapsLockOff | |
CapsLockOn | |
NumLockOff | |
NumLockOn | |
ScrollLockOff | |
ScrollLockOn | |
Reboot | |
PreviousConsole | |
NextConsole | |
SwitchConsoleFirst | |
SwitchConsoleLast | |
SwitchConsoleMask |
Definition at line 67 of file qkbd_qws.h.
QWSKeyboardHandler::QWSKeyboardHandler | ( | ) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Definition at line 323 of file qkbd_qws.cpp.
QWSKeyboardHandler::QWSKeyboardHandler | ( | const QString & | device | ) |
Constructs a keyboard driver.
The device argument is passed by the QWS_KEYBOARD environment variable.
Call the 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.
Definition at line 315 of file qkbd_qws.cpp.
|
virtual |
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.
Definition at line 338 of file qkbd_qws.cpp.
|
protected |
Begins auto-repeating the specified key press; after a short delay the key press is sent periodically until the endAutoRepeat() function is called.
The key press is specified by its unicode, keycode and modifier state.
Definition at line 433 of file qkbd_qws.cpp.
|
protected |
Stops auto-repeating a key press.
Definition at line 443 of file qkbd_qws.cpp.
QWSKeyboardHandler::KeycodeAction QWSKeyboardHandler::processKeycode | ( | quint16 | keycode, |
bool | isPress, | ||
bool | autoRepeat | ||
) |
Maps keycode according to a keymap and sends that key event to the Qt for Embedded Linux server application.
Please see the Qt for Embedded Linux Character Input and the 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 parameters.
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 environment variable.
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
Definition at line 521 of file qkbd_qws.cpp.
Referenced by QWSLinuxInputKbPrivate::readKeycode(), QWSTtyKbPrivate::readKeycode(), and QLinuxInputKeyboardHandler::readKeycode().
|
virtual |
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 parameters.
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.
Definition at line 363 of file qkbd_qws.cpp.
Referenced by QWSKbPrivate::autoRepeat(), processKeycode(), QDirectFBKeyboardHandlerPrivate::readKeyboardData(), and QWSQnxKeyboardHandler::socketActivated().
|
protected |
Transforms the arrow key specified by the given keycode, to the orientation of the display and returns the transformed keycode.
The keycode is a Qt::Key value. The values identifying arrow keys are:
Definition at line 398 of file qkbd_qws.cpp.
|
private |
Definition at line 94 of file qkbd_qws.h.