1 | /****************************************************************************
|
---|
2 | **
|
---|
3 | ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
---|
4 | ** All rights reserved.
|
---|
5 | ** Contact: Nokia Corporation (qt-info@nokia.com)
|
---|
6 | **
|
---|
7 | ** This file is part of the documentation of the Qt Toolkit.
|
---|
8 | **
|
---|
9 | ** $QT_BEGIN_LICENSE:FDL$
|
---|
10 | ** Commercial Usage
|
---|
11 | ** Licensees holding valid Qt Commercial licenses may use this file in
|
---|
12 | ** accordance with the Qt Commercial License Agreement provided with the
|
---|
13 | ** Software or, alternatively, in accordance with the terms contained in a
|
---|
14 | ** written agreement between you and Nokia.
|
---|
15 | **
|
---|
16 | ** GNU Free Documentation License
|
---|
17 | ** Alternatively, this file may be used under the terms of the GNU Free
|
---|
18 | ** Documentation License version 1.3 as published by the Free Software
|
---|
19 | ** Foundation and appearing in the file included in the packaging of this
|
---|
20 | ** file.
|
---|
21 | **
|
---|
22 | ** If you have questions regarding the use of this file, please contact
|
---|
23 | ** Nokia at qt-info@nokia.com.
|
---|
24 | ** $QT_END_LICENSE$
|
---|
25 | **
|
---|
26 | ****************************************************************************/
|
---|
27 |
|
---|
28 | /*!
|
---|
29 | \page qt-embedded-charinput.html
|
---|
30 |
|
---|
31 | \title Qt for Embedded Linux Character Input
|
---|
32 | \ingroup qt-embedded-linux
|
---|
33 |
|
---|
34 | When running a \l {Qt for Embedded Linux} application, it either runs as a
|
---|
35 | server or connects to an existing server. The keyboard driver is
|
---|
36 | loaded by the server application when it starts running, using
|
---|
37 | Qt's \l {How to Create Qt Plugins}{plugin system}.
|
---|
38 |
|
---|
39 | Internally in the client/server protocol, all system generated
|
---|
40 | events, including key events, are passed to the server application
|
---|
41 | which then propagates the event to the appropriate client. Note
|
---|
42 | that key events do not always come from a keyboard device, they
|
---|
43 | can can also be generated by the server process using input
|
---|
44 | widgets.
|
---|
45 |
|
---|
46 | \table
|
---|
47 | \header \o Input Widgets
|
---|
48 | \row
|
---|
49 | \o
|
---|
50 |
|
---|
51 | The server process may call the static QWSServer::sendKeyEvent()
|
---|
52 | function at any time. Typically, this is done by popping up a
|
---|
53 | widget that enables the user specify characters with the pointer
|
---|
54 | device.
|
---|
55 |
|
---|
56 | Note that the key input widget should not take focus since the
|
---|
57 | server would then just send the key events back to the input
|
---|
58 | widget. One way to make sure that the input widget never takes
|
---|
59 | focus is to set the Qt::Tool widget flag in the QWidget
|
---|
60 | constructor.
|
---|
61 |
|
---|
62 | The \l{Qt Extended} environment contains various input widgets such as
|
---|
63 | Handwriting Recognition and Virtual Keyboard.
|
---|
64 |
|
---|
65 | \endtable
|
---|
66 |
|
---|
67 | \tableofcontents
|
---|
68 |
|
---|
69 | \section1 Available Keyboard Drivers
|
---|
70 |
|
---|
71 | \l {Qt for Embedded Linux} provides ready-made drivers for the console
|
---|
72 | (TTY) and the standard Linux Input Subsystem (USB, PS/2, ...). Run the
|
---|
73 | \c configure script to list the available drivers:
|
---|
74 |
|
---|
75 | \snippet doc/src/snippets/code/doc_src_emb-charinput.qdoc 0
|
---|
76 |
|
---|
77 | Note that only the console (TTY) keyboard driver handles console
|
---|
78 | switching (\bold{Ctrl+Alt+F1}, ..., \bold{Ctrl+Alt+F10}) and
|
---|
79 | termination (\bold{Ctrl+Alt+Backspace}).
|
---|
80 |
|
---|
81 | In the default Qt configuration, only the "TTY" driver is
|
---|
82 | enabled. The various drivers can be enabled and disabled using the
|
---|
83 | \c configure script. For example:
|
---|
84 |
|
---|
85 | \snippet doc/src/snippets/code/doc_src_emb-charinput.qdoc 1
|
---|
86 |
|
---|
87 | Custom keyboard drivers can be implemented by subclassing the
|
---|
88 | QWSKeyboardHandler class and creating a keyboard driver plugin
|
---|
89 | (derived from the QKbdDriverPlugin class). The default
|
---|
90 | implementation of the QKbdDriverFactory class will automatically
|
---|
91 | detect the plugin, loading the driver into the server application
|
---|
92 | at run-time.
|
---|
93 |
|
---|
94 | \section1 Keymaps
|
---|
95 |
|
---|
96 | Starting with 4.6, \l {Qt for Embedded Linux} has gained support for
|
---|
97 | user defined keymaps. Keymap handling is supported by the built-in
|
---|
98 | keyboard drivers \c TTY and \c LinuxInput. Custom keyboard drivers can
|
---|
99 | use the existing keymap handling code via
|
---|
100 | QWSKeyboardHandler::processKeycode().
|
---|
101 |
|
---|
102 | By default Qt will use an internal, compiled-in US keymap.
|
---|
103 | See the options below for how to load a different keymap.
|
---|
104 |
|
---|
105 | \section1 Specifying a Keyboard Driver
|
---|
106 |
|
---|
107 | To specify which driver to use, set the QWS_KEYBOARD environment
|
---|
108 | variable. For example (if the current shell is bash, ksh, zsh or
|
---|
109 | sh):
|
---|
110 |
|
---|
111 | \snippet doc/src/snippets/code/doc_src_emb-charinput.qdoc 2
|
---|
112 |
|
---|
113 | The \c <driver> arguments are \c TTY, \c LinuxInput and \l
|
---|
114 | {QKbdDriverPlugin::keys()}{keys} identifying custom drivers, and the
|
---|
115 | driver specific options are typically a device, e.g., \c /dev/tty0.
|
---|
116 |
|
---|
117 | Multiple keyboard drivers can be specified in one go:
|
---|
118 |
|
---|
119 | \snippet doc/src/snippets/code/doc_src_emb-charinput.qdoc 3
|
---|
120 |
|
---|
121 | Input will be read from all specified drivers.
|
---|
122 |
|
---|
123 | Currently the following options are supported by both the \c TTY and \c
|
---|
124 | LinuxInput driver:
|
---|
125 |
|
---|
126 | \table
|
---|
127 | \header \o Option \o Description
|
---|
128 | \row \o \c /dev/xxx \o
|
---|
129 | Open the specified device, instead of the driver's default device.
|
---|
130 | \row \o \c repeat-delay=<d> \o
|
---|
131 | Time (in milliseconds) until auto-repeat kicks in.
|
---|
132 | \row \o \c repeat-rate=<r> \o
|
---|
133 | Time (in milliseconds) specifying the interval between auto-repeats.
|
---|
134 | \row \o \c keymap=xx.qmap \o
|
---|
135 | File name of a keymap file in Qt's \c qmap format. See \l {kmap2qmap}
|
---|
136 | for instructions on how to create thoes files.\br Note that the file
|
---|
137 | name can of course also be the name of a QResource.
|
---|
138 | \row \o \c disable-zap \o
|
---|
139 | Disable the QWS server "Zap" shortcut \bold{Ctrl+Alt+Backspace}
|
---|
140 | \row \o \c enable-compose \o
|
---|
141 | Activate Latin-1 composing features in the built-in US keymap. You can
|
---|
142 | use the right \c AltGr or right \c Alt is used as a dead key modifier,
|
---|
143 | while \c AltGr+. is the compose key. For example:
|
---|
144 | \list
|
---|
145 | \o \c AltGr + \c " + \c u = \uuml (u with diaeresis / umlaut u)
|
---|
146 | \o \c AltGr + \c . + \c / + \c o = \oslash (slashed o)
|
---|
147 | \endlist
|
---|
148 | \endtable
|
---|
149 |
|
---|
150 | */
|
---|