|
1 /**************************************************************************** |
|
2 ** |
|
3 ** Copyright (C) 2009 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 ** No Commercial Usage |
|
11 ** This file contains pre-release code and may not be distributed. |
|
12 ** You may use this file in accordance with the terms and conditions |
|
13 ** contained in the Technology Preview License Agreement accompanying |
|
14 ** this package. |
|
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 ** If you have questions regarding the use of this file, please contact |
|
29 ** Nokia at qt-info@nokia.com. |
|
30 ** |
|
31 ** |
|
32 ** |
|
33 ** |
|
34 ** |
|
35 ** |
|
36 ** |
|
37 ** |
|
38 ** $QT_END_LICENSE$ |
|
39 ** |
|
40 ****************************************************************************/ |
|
41 |
|
42 #include "qmousedriverfactory_qws.h" |
|
43 |
|
44 #include "qapplication.h" |
|
45 #include "qmousepc_qws.h" |
|
46 #include "qmouselinuxtp_qws.h" |
|
47 #include "qmouselinuxinput_qws.h" |
|
48 #include "qmousevfb_qws.h" |
|
49 #include "qmousetslib_qws.h" |
|
50 #include "qmouseqnx_qws.h" |
|
51 #include <stdlib.h> |
|
52 #include "private/qfactoryloader_p.h" |
|
53 #include "qmousedriverplugin_qws.h" |
|
54 #include "qdebug.h" |
|
55 |
|
56 QT_BEGIN_NAMESPACE |
|
57 |
|
58 #if !defined(Q_OS_WIN32) || defined(QT_MAKEDLL) |
|
59 #ifndef QT_NO_LIBRARY |
|
60 |
|
61 Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, loader, |
|
62 (QWSMouseHandlerFactoryInterface_iid, |
|
63 QLatin1String("/mousedrivers"), Qt::CaseInsensitive)) |
|
64 |
|
65 #endif //QT_NO_LIBRARY |
|
66 #endif //QT_MAKEDLL |
|
67 |
|
68 /*! |
|
69 \class QMouseDriverFactory |
|
70 \ingroup qws |
|
71 |
|
72 \brief The QMouseDriverFactory class creates mouse drivers in |
|
73 Qt for Embedded Linux. |
|
74 |
|
75 Note that this class is only available in \l{Qt for Embedded Linux}. |
|
76 |
|
77 QMouseDriverFactory is used to detect and instantiate the |
|
78 available mouse drivers, allowing \l{Qt for Embedded Linux} to load the |
|
79 preferred driver into the server application at runtime. The |
|
80 create() function returns a QWSMouseHandler object representing |
|
81 the mouse driver identified by a given key. The valid keys |
|
82 (i.e. the supported drivers) can be retrieved using the keys() |
|
83 function. |
|
84 |
|
85 \l{Qt for Embedded Linux} provides several built-in mouse drivers. In |
|
86 addition, custom mouse drivers can be added using Qt's plugin |
|
87 mechanism, i.e. by subclassing the QWSMouseHandler class and |
|
88 creating a mouse driver plugin (QMouseDriverPlugin). See the |
|
89 \l{Qt for Embedded Linux Pointer Handling}{pointer handling} |
|
90 documentation for details. |
|
91 |
|
92 \sa QWSMouseHandler, QMouseDriverPlugin |
|
93 */ |
|
94 |
|
95 /*! |
|
96 Creates the mouse driver specified by the given \a key, using the |
|
97 display specified by the given \a device. |
|
98 |
|
99 Note that the keys are case-insensitive. |
|
100 |
|
101 \sa keys() |
|
102 */ |
|
103 QWSMouseHandler *QMouseDriverFactory::create(const QString& key, const QString &device) |
|
104 { |
|
105 QString driver = key.toLower(); |
|
106 #if defined(Q_OS_QNX) && !defined(QT_NO_QWS_MOUSE_QNX) |
|
107 if (driver == QLatin1String("qnx") || driver.isEmpty()) |
|
108 return new QQnxMouseHandler(key, device); |
|
109 #endif |
|
110 #ifndef QT_NO_QWS_MOUSE_LINUXTP |
|
111 if (driver == QLatin1String("linuxtp") || driver.isEmpty()) |
|
112 return new QWSLinuxTPMouseHandler(key, device); |
|
113 #endif |
|
114 #ifndef QT_NO_QWS_MOUSE_PC |
|
115 if (driver == QLatin1String("auto") |
|
116 || driver == QLatin1String("intellimouse") |
|
117 || driver == QLatin1String("microsoft") |
|
118 || driver == QLatin1String("mousesystems") |
|
119 || driver == QLatin1String("mouseman") |
|
120 || driver.isEmpty()) { |
|
121 return new QWSPcMouseHandler(key, device); |
|
122 } |
|
123 #endif |
|
124 #ifndef QT_NO_QWS_MOUSE_TSLIB |
|
125 if (driver == QLatin1String("tslib") || driver.isEmpty()) |
|
126 return new QWSTslibMouseHandler(key, device); |
|
127 #endif |
|
128 # ifndef QT_NO_QWS_MOUSE_LINUXINPUT |
|
129 if (driver == QLatin1String("linuxinput") || \ |
|
130 driver == QLatin1String("usb") || \ |
|
131 driver == QLatin1String("linuxis")) |
|
132 return new QWSLinuxInputMouseHandler(device); |
|
133 # endif |
|
134 #ifndef QT_NO_QWS_MOUSE_QVFB |
|
135 if (driver == QLatin1String("qvfbmouse") || driver == QLatin1String("qvfb")) |
|
136 return new QVFbMouseHandler(key, device); |
|
137 #endif |
|
138 |
|
139 #if !defined(Q_OS_WIN32) || defined(QT_MAKEDLL) |
|
140 #ifndef QT_NO_LIBRARY |
|
141 if (QWSMouseHandlerFactoryInterface *factory = qobject_cast<QWSMouseHandlerFactoryInterface*>(loader()->instance(driver))) |
|
142 return factory->create(driver, device); |
|
143 #endif |
|
144 #endif |
|
145 return 0; |
|
146 } |
|
147 |
|
148 /*! |
|
149 Returns the list of valid keys, i.e. the available mouse drivers. |
|
150 |
|
151 \sa create() |
|
152 */ |
|
153 QStringList QMouseDriverFactory::keys() |
|
154 { |
|
155 QStringList list; |
|
156 |
|
157 #if defined(Q_OS_QNX) && !defined(QT_NO_QWS_MOUSE_QNX) |
|
158 list << QLatin1String("QNX"); |
|
159 #endif |
|
160 #ifndef QT_NO_QWS_MOUSE_LINUXTP |
|
161 list << QLatin1String("LinuxTP"); |
|
162 #endif |
|
163 #ifndef QT_NO_QWS_MOUSE_PC |
|
164 list << QLatin1String("Auto") |
|
165 << QLatin1String("IntelliMouse") |
|
166 << QLatin1String("Microsoft") |
|
167 << QLatin1String("MouseSystems") |
|
168 << QLatin1String("MouseMan"); |
|
169 #endif |
|
170 #ifndef QT_NO_QWS_MOUSE_TSLIB |
|
171 list << QLatin1String("Tslib"); |
|
172 #endif |
|
173 #ifndef QT_NO_QWS_MOUSE_LINUXINPUT |
|
174 list << QLatin1String("LinuxInput"); |
|
175 #endif |
|
176 |
|
177 #if !defined(Q_OS_WIN32) || defined(QT_MAKEDLL) |
|
178 #ifndef QT_NO_LIBRARY |
|
179 QStringList plugins = loader()->keys(); |
|
180 for (int i = 0; i < plugins.size(); ++i) { |
|
181 if (!list.contains(plugins.at(i))) |
|
182 list += plugins.at(i); |
|
183 } |
|
184 #endif //QT_NO_LIBRARY |
|
185 #endif //QT_MAKEDLL |
|
186 return list; |
|
187 } |
|
188 |
|
189 QT_END_NAMESPACE |