Viadeo Twitter Google Bookmarks ! Facebook Digg del.icio.us MySpace Yahoo MyWeb Blinklist Netvouz Reddit Simpy StumbleUpon Bookmarks Windows Live Favorites 
Logo Documentation Qt ·  Page d'accueil  ·  Toutes les classes  ·  Toutes les fonctions  ·  Vues d'ensemble  · 

QWSKeyboardHandler Class Reference
[QtGui module]

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

 #include <QWSKeyboardHandler>

Public Types

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

Public Functions

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 )

Protected Functions

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

Detailed Description

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 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() and endAutoRepeat(), and the transformDirKey() function enabling transformation of arrow keys according to the display orientation.

See also QKbdDriverPlugin, QKbdDriverFactory, and Qt for Embedded Linux Character Input.


Member Type Documentation

enum QWSKeyboardHandler::KeycodeAction

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

ConstantValueDescription
QWSKeyboardHandler::None0No further action required.
QWSKeyboardHandler::CapsLockOn0x01000001Set the state of the Caps lock LED to on.
QWSKeyboardHandler::CapsLockOff0x01000000Set the state of the Caps lock LED to off.
QWSKeyboardHandler::NumLockOn0x02000001Set the state of the Num lock LED to on.
QWSKeyboardHandler::NumLockOff0x02000000Set the state of the Num lock LED to off.
QWSKeyboardHandler::ScrollLockOn0x03000001Set the state of the Scroll lock LED to on.
QWSKeyboardHandler::ScrollLockOff0x03000000Set the state of the Scroll lock LED to off.
QWSKeyboardHandler::PreviousConsole0x05000000Switch to the previous virtual console (by default Ctrl+Alt+Left on Linux).
QWSKeyboardHandler::NextConsole0x05000001Switch to the next virtual console (by default Ctrl+Alt+Right on Linux).
QWSKeyboardHandler::SwitchConsoleFirst0x06000000Switch to the first virtual console (0).
QWSKeyboardHandler::SwitchConsoleLast0x0600007fSwitch to the last virtual console (255).
QWSKeyboardHandler::SwitchConsoleMask0x0000007fIf the KeyAction value is between SwitchConsoleFirst and SwitchConsoleLast, you can use this mask to get the specific virtual console number to switch to.
QWSKeyboardHandler::Reboot0x04000000Reboot the machine - this is ignored in both the TTY and LinuxInput handlers though (by default Ctrl+Alt+Del on Linux).

See also processKeycode().


Member Function Documentation

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.

QWSKeyboardHandler::QWSKeyboardHandler ()

This is an overloaded function.

QWSKeyboardHandler::~QWSKeyboardHandler ()   [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.

void QWSKeyboardHandler::beginAutoRepeat ( int unicode, int keycode, Qt::KeyboardModifiers modifier )   [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.

See also endAutoRepeat() and processKeyEvent().

void QWSKeyboardHandler::endAutoRepeat ()   [protected]

Stops auto-repeating a key press.

See also beginAutoRepeat() and processKeyEvent().

void QWSKeyboardHandler::processKeyEvent ( int unicode, int keycode, Qt::KeyboardModifiers modifiers, bool isPress, bool autoRepeat )   [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.

See also processKeycode(), beginAutoRepeat(), endAutoRepeat(), and transformDirKey().

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

See also processKeyEvent() and KeycodeAction.

int QWSKeyboardHandler::transformDirKey ( int keycode )   [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:

See also processKeyEvent().

Publicité

Best Of

Actualités les plus lues

Semaine
Mois
Année
  1. « Quelque chose ne va vraiment pas avec les développeurs "modernes" », un développeur à "l'ancienne" critique la multiplication des bibliothèques 64
  2. Apercevoir la troisième dimension ou l'utilisation multithreadée d'OpenGL dans Qt, un article des Qt Quarterly traduit par Guillaume Belz 0
  3. Les développeurs ignorent-ils trop les failles découvertes dans leur code ? Prenez-vous en compte les remarques des autres ? 17
  4. BlackBerry 10 : premières images du prochain OS de RIM qui devrait intégrer des widgets et des tuiles inspirées de Windows Phone 0
  5. Quelles nouveautés de C++11 Visual C++ doit-il rapidement intégrer ? Donnez-nous votre avis 10
  6. Adieu qmake, bienvenue qbs : Qt Building Suite, un outil déclaratif et extensible pour la compilation de projets Qt 17
  7. La rubrique Qt a besoin de vous ! 1
Page suivante

Le Qt Quarterly au hasard

Logo

Implémenter un mutex en lecture et en écriture

Qt Quarterly est la revue trimestrielle proposée par Nokia et à destination des développeurs Qt. Ces articles d'une grande qualité technique sont rédigés par des experts Qt. Lire l'article.

Communauté

Ressources

Liens utiles

Contact

  • Vous souhaitez rejoindre la rédaction ou proposer un tutoriel, une traduction, une question... ? Postez dans le forum Contribuez ou contactez-nous par MP ou par email (voir en bas de page).

Qt dans le magazine

Cette page est une traduction d'une page de la documentation de Qt, écrite par Nokia Corporation and/or its subsidiary(-ies). Les éventuels problèmes résultant d'une mauvaise traduction ne sont pas imputables à Nokia. Qt 4.6
Copyright © 2012 Developpez LLC. Tous droits réservés Developpez LLC. Aucune reproduction, même partielle, ne peut être faite de ce site et de l'ensemble de son contenu : textes, documents et images sans l'autorisation expresse de Developpez LLC. Sinon, vous encourez selon la loi jusqu'à 3 ans de prison et jusqu'à 300 000 E de dommages et intérêts. Cette page est déposée à la SACD.
Vous avez déniché une erreur ? Un bug ? Une redirection cassée ? Ou tout autre problème, quel qu'il soit ? Ou bien vous désirez participer à ce projet de traduction ? N'hésitez pas à nous contacter ou par MP !
 
 
 
 
Partenaires

Hébergement Web