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 QtGui module of the Qt Toolkit.
|
---|
8 | **
|
---|
9 | ** $QT_BEGIN_LICENSE:LGPL$
|
---|
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
|
---|
14 | ** a written agreement between you and Nokia.
|
---|
15 | **
|
---|
16 | ** GNU Lesser General Public License Usage
|
---|
17 | ** Alternatively, this file may be used under the terms of the GNU Lesser
|
---|
18 | ** General Public License version 2.1 as published by the Free Software
|
---|
19 | ** Foundation and appearing in the file LICENSE.LGPL included in the
|
---|
20 | ** packaging of this file. Please review the following information to
|
---|
21 | ** ensure the GNU Lesser General Public License version 2.1 requirements
|
---|
22 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
---|
23 | **
|
---|
24 | ** In addition, as a special exception, Nokia gives you certain additional
|
---|
25 | ** rights. These rights are described in the Nokia Qt LGPL Exception
|
---|
26 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
---|
27 | **
|
---|
28 | ** GNU General Public License Usage
|
---|
29 | ** Alternatively, this file may be used under the terms of the GNU
|
---|
30 | ** General Public License version 3.0 as published by the Free Software
|
---|
31 | ** Foundation and appearing in the file LICENSE.GPL included in the
|
---|
32 | ** packaging of this file. Please review the following information to
|
---|
33 | ** ensure the GNU General Public License version 3.0 requirements will be
|
---|
34 | ** met: http://www.gnu.org/copyleft/gpl.html.
|
---|
35 | **
|
---|
36 | ** If you have questions regarding the use of this file, please contact
|
---|
37 | ** Nokia at qt-info@nokia.com.
|
---|
38 | ** $QT_END_LICENSE$
|
---|
39 | **
|
---|
40 | ****************************************************************************/
|
---|
41 |
|
---|
42 | #include "qkbddriverfactory_qws.h"
|
---|
43 |
|
---|
44 | #ifndef QT_NO_QWS_KEYBOARD
|
---|
45 |
|
---|
46 | #include "qapplication.h"
|
---|
47 | #include "qkbdtty_qws.h"
|
---|
48 | #include "qkbdlinuxinput_qws.h"
|
---|
49 | #include "qkbdum_qws.h"
|
---|
50 | #include "qkbdvfb_qws.h"
|
---|
51 | #include "qkbdqnx_qws.h"
|
---|
52 | #include <stdlib.h>
|
---|
53 | #include "private/qfactoryloader_p.h"
|
---|
54 | #include "qkbddriverplugin_qws.h"
|
---|
55 |
|
---|
56 | QT_BEGIN_NAMESPACE
|
---|
57 |
|
---|
58 | #if !defined(Q_OS_WIN32) || defined(QT_MAKEDLL)
|
---|
59 | #ifndef QT_NO_LIBRARY
|
---|
60 | Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, loader,
|
---|
61 | (QWSKeyboardHandlerFactoryInterface_iid,
|
---|
62 | QLatin1String("/kbddrivers"), Qt::CaseInsensitive))
|
---|
63 |
|
---|
64 | #endif //QT_NO_LIBRARY
|
---|
65 | #endif //QT_MAKEDLL
|
---|
66 |
|
---|
67 | /*!
|
---|
68 | \class QKbdDriverFactory
|
---|
69 | \ingroup qws
|
---|
70 |
|
---|
71 | \brief The QKbdDriverFactory class creates keyboard drivers in
|
---|
72 | Qt for Embedded Linux.
|
---|
73 |
|
---|
74 | Note that this class is only available in \l{Qt for Embedded Linux}.
|
---|
75 |
|
---|
76 | QKbdDriverFactory is used to detect and instantiate the available
|
---|
77 | keyboard drivers, allowing \l{Qt for Embedded Linux} to load the preferred
|
---|
78 | driver into the server application at runtime. The create()
|
---|
79 | function returns a QWSKeyboardHandler object representing the
|
---|
80 | keyboard driver identified by a given key. The valid keys
|
---|
81 | (i.e. the supported drivers) can be retrieved using the keys()
|
---|
82 | function.
|
---|
83 |
|
---|
84 | \l{Qt for Embedded Linux} provides several built-in keyboard drivers. In
|
---|
85 | addition, custom keyboard drivers can be added using Qt's plugin
|
---|
86 | mechanism, i.e. by subclassing the QWSKeyboardHandler class and
|
---|
87 | creating a keyboard driver plugin (QKbdDriverPlugin). See the
|
---|
88 | \l{Qt for Embedded Linux Character Input}{character input} documentation
|
---|
89 | for details.
|
---|
90 |
|
---|
91 | \sa QWSKeyboardHandler, QKbdDriverPlugin
|
---|
92 | */
|
---|
93 |
|
---|
94 | /*!
|
---|
95 | Creates the keyboard driver specified by the given \a key, using
|
---|
96 | the display specified by the given \a device.
|
---|
97 |
|
---|
98 | Note that the keys are case-insensitive.
|
---|
99 |
|
---|
100 | \sa keys()
|
---|
101 | */
|
---|
102 | QWSKeyboardHandler *QKbdDriverFactory::create(const QString& key, const QString& device)
|
---|
103 | {
|
---|
104 | QString driver = key.toLower();
|
---|
105 | #if defined(Q_OS_QNX) && !defined(QT_NO_QWS_KBD_QNX)
|
---|
106 | if (driver == QLatin1String("qnx") || driver.isEmpty())
|
---|
107 | return new QWSQnxKeyboardHandler(device);
|
---|
108 | #endif
|
---|
109 | #ifndef QT_NO_QWS_KEYBOARD
|
---|
110 | # ifndef QT_NO_QWS_KBD_TTY
|
---|
111 | if (driver == QLatin1String("tty") || driver.isEmpty())
|
---|
112 | return new QWSTtyKeyboardHandler(device);
|
---|
113 | # endif
|
---|
114 | # ifndef QT_NO_QWS_KBD_LINUXINPUT
|
---|
115 | if (driver == QLatin1String("linuxinput") || \
|
---|
116 | driver == QLatin1String("usb") || \
|
---|
117 | driver == QLatin1String("linuxis"))
|
---|
118 | return new QWSLinuxInputKeyboardHandler(device);
|
---|
119 | # endif
|
---|
120 | # ifndef QT_NO_QWS_KBD_UM
|
---|
121 | if (driver == QLatin1String("um") || driver == QLatin1String("qvfbkeyboard"))
|
---|
122 | return new QWSUmKeyboardHandler(device);
|
---|
123 | # endif
|
---|
124 | # ifndef QT_NO_QWS_KBD_QVFB
|
---|
125 | if (driver == QLatin1String("qvfbkbd")
|
---|
126 | || driver == QLatin1String("qvfbkeyboard")
|
---|
127 | || driver == QLatin1String("qvfb"))
|
---|
128 | return new QVFbKeyboardHandler(device);
|
---|
129 | # endif
|
---|
130 | #endif
|
---|
131 |
|
---|
132 | #if !defined(Q_OS_WIN32) || defined(QT_MAKEDLL)
|
---|
133 | #ifndef QT_NO_LIBRARY
|
---|
134 | if (QWSKeyboardHandlerFactoryInterface *factory = qobject_cast<QWSKeyboardHandlerFactoryInterface*>(loader()->instance(driver)))
|
---|
135 | return factory->create(driver, device);
|
---|
136 | #endif
|
---|
137 | #endif
|
---|
138 | return 0;
|
---|
139 | }
|
---|
140 |
|
---|
141 | /*!
|
---|
142 | Returns the list of valid keys, i.e. the available keyboard
|
---|
143 | drivers.
|
---|
144 |
|
---|
145 | \sa create()
|
---|
146 | */
|
---|
147 | QStringList QKbdDriverFactory::keys()
|
---|
148 | {
|
---|
149 | QStringList list;
|
---|
150 |
|
---|
151 | #if defined(Q_OS_QNX) && !defined(QT_NO_QWS_KBD_QNX)
|
---|
152 | list << QLatin1String("QNX");
|
---|
153 | #endif
|
---|
154 | #ifndef QT_NO_QWS_KBD_TTY
|
---|
155 | list << QLatin1String("TTY");
|
---|
156 | #endif
|
---|
157 | #ifndef QT_NO_QWS_KBD_LINUXINPUT
|
---|
158 | list << QLatin1String("LinuxInput");
|
---|
159 | #endif
|
---|
160 | #ifndef QT_NO_QWS_KBD_UM
|
---|
161 | list << QLatin1String("UM");
|
---|
162 | #endif
|
---|
163 |
|
---|
164 | #if !defined(Q_OS_WIN32) || defined(QT_MAKEDLL)
|
---|
165 | #ifndef QT_NO_LIBRARY
|
---|
166 | QStringList plugins = loader()->keys();
|
---|
167 | for (int i = 0; i < plugins.size(); ++i) {
|
---|
168 | if (!list.contains(plugins.at(i)))
|
---|
169 | list += plugins.at(i);
|
---|
170 | }
|
---|
171 | #endif //QT_NO_LIBRARY
|
---|
172 | #endif //QT_MAKEDLL
|
---|
173 |
|
---|
174 | return list;
|
---|
175 | }
|
---|
176 |
|
---|
177 | QT_END_NAMESPACE
|
---|
178 |
|
---|
179 | #endif // QT_NO_QWS_KEYBOARD
|
---|