Merge lp:~mzanetti/unity8/inputinfo-plugin into lp:unity8
- inputinfo-plugin
- Merge into trunk
Status: | Superseded |
---|---|
Proposed branch: | lp:~mzanetti/unity8/inputinfo-plugin |
Merge into: | lp:unity8 |
Prerequisite: | lp:~unity-team/unity8/shellRotation |
Diff against target: |
1072 lines (+984/-0) 13 files modified
debian/changelog (+6/-0) debian/control (+2/-0) plugins/Unity/CMakeLists.txt (+1/-0) plugins/Unity/InputInfo/CMakeLists.txt (+39/-0) plugins/Unity/InputInfo/linux/qinputdeviceinfo_linux.cpp (+249/-0) plugins/Unity/InputInfo/linux/qinputdeviceinfo_linux_p.h (+91/-0) plugins/Unity/InputInfo/plugin.cpp (+32/-0) plugins/Unity/InputInfo/plugin.h (+30/-0) plugins/Unity/InputInfo/qdeclarativeinputdeviceinfo.cpp (+143/-0) plugins/Unity/InputInfo/qdeclarativeinputdeviceinfo_p.h (+86/-0) plugins/Unity/InputInfo/qinputinfo.cpp (+159/-0) plugins/Unity/InputInfo/qinputinfo.h (+143/-0) plugins/Unity/InputInfo/qmldir (+3/-0) |
To merge this branch: | bzr merge lp:~mzanetti/unity8/inputinfo-plugin |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
PS Jenkins bot (community) | continuous-integration | Needs Fixing | |
Albert Astals Cid (community) | Needs Fixing | ||
Review via email:
|
This proposal supersedes a proposal from 2015-05-05.
This proposal has been superseded by a proposal from 2015-06-23.
Commit message
Added a snapshot of the WIP Qt InputInfo API
Description of the change
WIP: Just trying to get it through Jenkins once.
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal | # |
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal | # |
FAILED: Continuous integration, rev:1746
http://
Executed test runs:
UNSTABLE: http://
FAILURE: http://
SUCCESS: http://
SUCCESS: http://
UNSTABLE: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal | # |
FAILED: Continuous integration, rev:1746
http://
Executed test runs:
UNSTABLE: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
UNSTABLE: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal | # |
FAILED: Continuous integration, rev:1747
http://
Executed test runs:
UNSTABLE: http://
SUCCESS: http://
SUCCESS: http://
UNSTABLE: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal | # |
FAILED: Continuous integration, rev:1748
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:1748
No commit message was specified in the merge proposal. Click on the following link and set the commit message (if you want a jenkins rebuild you need to trigger it yourself):
https:/
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Albert Astals Cid (aacid) wrote : | # |
Text conflict in qml/Stages/
Text conflict in qml/Stages/
2 conflicts encountered.
- 1749. By Michael Zanetti
-
merge trunk
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:1749
No commit message was specified in the merge proposal. Click on the following link and set the commit message (if you want a jenkins rebuild you need to trigger it yourself):
https:/
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:1749
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Albert Astals Cid (aacid) wrote : | # |
You have bad tags
- 1750. By Michael Zanetti
-
drop debug print
- 1751. By Michael Zanetti
-
merge trunk
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:1751
http://
Executed test runs:
UNSTABLE: http://
SUCCESS: http://
SUCCESS: http://
UNSTABLE: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Unmerged revisions
Preview Diff
1 | === modified file 'debian/changelog' | |||
2 | --- debian/changelog 2015-06-16 15:12:59 +0000 | |||
3 | +++ debian/changelog 2015-06-22 12:17:35 +0000 | |||
4 | @@ -66,6 +66,12 @@ | |||
5 | 66 | 66 | ||
6 | 67 | -- CI Train Bot <ci-train-bot@canonical.com> Fri, 12 Jun 2015 16:07:47 +0000 | 67 | -- CI Train Bot <ci-train-bot@canonical.com> Fri, 12 Jun 2015 16:07:47 +0000 |
7 | 68 | 68 | ||
8 | 69 | unity8 (8.10-0ubuntu1) UNRELEASED; urgency=medium | ||
9 | 70 | |||
10 | 71 | * Implement full-shell rotation (LP: #1210199) | ||
11 | 72 | |||
12 | 73 | -- Michał Sawicz <michal.sawicz@canonical.com> Wed, 15 Apr 2015 14:47:17 +0200 | ||
13 | 74 | |||
14 | 69 | unity8 (8.02+15.10.20150603.1-0ubuntu1) wily; urgency=medium | 75 | unity8 (8.02+15.10.20150603.1-0ubuntu1) wily; urgency=medium |
15 | 70 | 76 | ||
16 | 71 | [ CI Train Bot ] | 77 | [ CI Train Bot ] |
17 | 72 | 78 | ||
18 | === modified file 'debian/control' | |||
19 | --- debian/control 2015-06-16 15:12:46 +0000 | |||
20 | +++ debian/control 2015-06-22 12:17:35 +0000 | |||
21 | @@ -16,6 +16,7 @@ | |||
22 | 16 | graphviz, | 16 | graphviz, |
23 | 17 | gsettings-ubuntu-schemas (>= 0.0.2+14.10.20140815), | 17 | gsettings-ubuntu-schemas (>= 0.0.2+14.10.20140815), |
24 | 18 | libconnectivity-qt1-dev, | 18 | libconnectivity-qt1-dev, |
25 | 19 | libevdev-dev, | ||
26 | 19 | libgl1-mesa-dev[!armhf] | libgl-dev[!armhf], | 20 | libgl1-mesa-dev[!armhf] | libgl-dev[!armhf], |
27 | 20 | libgl1-mesa-dri, | 21 | libgl1-mesa-dri, |
28 | 21 | libgles2-mesa-dev[armhf], | 22 | libgles2-mesa-dev[armhf], |
29 | @@ -28,6 +29,7 @@ | |||
30 | 28 | libqmenumodel-dev (>= 0.2.9), | 29 | libqmenumodel-dev (>= 0.2.9), |
31 | 29 | libqt5xmlpatterns5-dev, | 30 | libqt5xmlpatterns5-dev, |
32 | 30 | libsystemsettings-dev, | 31 | libsystemsettings-dev, |
33 | 32 | libudev-dev, | ||
34 | 31 | libunity-api-dev (>= 7.97), | 33 | libunity-api-dev (>= 7.97), |
35 | 32 | libusermetricsoutput1-dev, | 34 | libusermetricsoutput1-dev, |
36 | 33 | libxcb1-dev, | 35 | libxcb1-dev, |
37 | 34 | 36 | ||
38 | === modified file 'plugins/Unity/CMakeLists.txt' | |||
39 | --- plugins/Unity/CMakeLists.txt 2014-08-25 10:05:13 +0000 | |||
40 | +++ plugins/Unity/CMakeLists.txt 2015-06-22 12:17:35 +0000 | |||
41 | @@ -3,3 +3,4 @@ | |||
42 | 3 | add_subdirectory(Launcher) | 3 | add_subdirectory(Launcher) |
43 | 4 | add_subdirectory(Session) | 4 | add_subdirectory(Session) |
44 | 5 | add_subdirectory(DashCommunicator) | 5 | add_subdirectory(DashCommunicator) |
45 | 6 | add_subdirectory(InputInfo) | ||
46 | 6 | 7 | ||
47 | === added directory 'plugins/Unity/InputInfo' | |||
48 | === added file 'plugins/Unity/InputInfo/CMakeLists.txt' | |||
49 | --- plugins/Unity/InputInfo/CMakeLists.txt 1970-01-01 00:00:00 +0000 | |||
50 | +++ plugins/Unity/InputInfo/CMakeLists.txt 2015-06-22 12:17:35 +0000 | |||
51 | @@ -0,0 +1,39 @@ | |||
52 | 1 | # This is a temporary snapshot of the WIP QInputInfo API as we | ||
53 | 2 | # require this in unity now but upstream isn't finished yet. | ||
54 | 3 | # Eventually this should be dropped in favor of the upstream | ||
55 | 4 | # QInputInfo API. | ||
56 | 5 | |||
57 | 6 | project(InputInfo) | ||
58 | 7 | |||
59 | 8 | find_package(Qt5Core REQUIRED) | ||
60 | 9 | find_package(Qt5Quick REQUIRED) | ||
61 | 10 | |||
62 | 11 | pkg_check_modules(LIBUDEV REQUIRED libudev) | ||
63 | 12 | pkg_check_modules(LIBEVDEV REQUIRED libevdev) | ||
64 | 13 | |||
65 | 14 | include_directories( | ||
66 | 15 | ${CMAKE_CURRENT_SOURCE_DIR} | ||
67 | 16 | ${CMAKE_CURRENT_BINARY_DIR} | ||
68 | 17 | ${LIBUDEV_INCLUDE_DIRS} | ||
69 | 18 | ${LIBEVDEV_INCLUDE_DIRS} | ||
70 | 19 | ) | ||
71 | 20 | |||
72 | 21 | set(InputInfo_SOURCES | ||
73 | 22 | plugin.cpp | ||
74 | 23 | qinputinfo.cpp | ||
75 | 24 | qdeclarativeinputdeviceinfo.cpp | ||
76 | 25 | linux/qinputdeviceinfo_linux.cpp | ||
77 | 26 | ) | ||
78 | 27 | |||
79 | 28 | add_library(InputInfo SHARED | ||
80 | 29 | ${InputInfo_SOURCES} | ||
81 | 30 | ) | ||
82 | 31 | |||
83 | 32 | target_link_libraries(InputInfo | ||
84 | 33 | ${LIBUDEV_LDFLAGS} | ||
85 | 34 | ${LIBEVDEV_LDFLAGS} | ||
86 | 35 | ) | ||
87 | 36 | |||
88 | 37 | qt5_use_modules(InputInfo Core Qml Quick) | ||
89 | 38 | |||
90 | 39 | add_unity8_plugin(Unity.InputInfo 0.1 Unity/InputInfo TARGETS InputInfo) | ||
91 | 0 | 40 | ||
92 | === added directory 'plugins/Unity/InputInfo/linux' | |||
93 | === added file 'plugins/Unity/InputInfo/linux/qinputdeviceinfo_linux.cpp' | |||
94 | --- plugins/Unity/InputInfo/linux/qinputdeviceinfo_linux.cpp 1970-01-01 00:00:00 +0000 | |||
95 | +++ plugins/Unity/InputInfo/linux/qinputdeviceinfo_linux.cpp 2015-06-22 12:17:35 +0000 | |||
96 | @@ -0,0 +1,249 @@ | |||
97 | 1 | /**************************************************************************** | ||
98 | 2 | ** | ||
99 | 3 | ** Copyright (C) 2014 Canonical, Ltd. and/or its subsidiary(-ies). | ||
100 | 4 | ** Contact: http://www.qt-project.org/legal | ||
101 | 5 | ** | ||
102 | 6 | ** This file is part of the QtSystems module of the Qt Toolkit. | ||
103 | 7 | ** | ||
104 | 8 | ** $QT_BEGIN_LICENSE:LGPL$ | ||
105 | 9 | ** Commercial License Usage | ||
106 | 10 | ** Licensees holding valid commercial Qt licenses may use this file in | ||
107 | 11 | ** accordance with the commercial license agreement provided with the | ||
108 | 12 | ** Software or, alternatively, in accordance with the terms contained in | ||
109 | 13 | ** a written agreement between you and Digia. For licensing terms and | ||
110 | 14 | ** conditions see http://qt.digia.com/licensing. For further information | ||
111 | 15 | ** use the contact form at http://qt.digia.com/contact-us. | ||
112 | 16 | ** | ||
113 | 17 | ** GNU Lesser General Public License Usage | ||
114 | 18 | ** Alternatively, this file may be used under the terms of the GNU Lesser | ||
115 | 19 | ** General Public License version 2.1 as published by the Free Software | ||
116 | 20 | ** Foundation and appearing in the file LICENSE.LGPL included in the | ||
117 | 21 | ** packaging of this file. Please review the following information to | ||
118 | 22 | ** ensure the GNU Lesser General Public License version 2.1 requirements | ||
119 | 23 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. | ||
120 | 24 | ** | ||
121 | 25 | ** In addition, as a special exception, Digia gives you certain additional | ||
122 | 26 | ** rights. These rights are described in the Digia Qt LGPL Exception | ||
123 | 27 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. | ||
124 | 28 | ** | ||
125 | 29 | ** GNU General Public License Usage | ||
126 | 30 | ** Alternatively, this file may be used under the terms of the GNU | ||
127 | 31 | ** General Public License version 3.0 as published by the Free Software | ||
128 | 32 | ** Foundation and appearing in the file LICENSE.GPL included in the | ||
129 | 33 | ** packaging of this file. Please review the following information to | ||
130 | 34 | ** ensure the GNU General Public License version 3.0 requirements will be | ||
131 | 35 | ** met: http://www.gnu.org/copyleft/gpl.html. | ||
132 | 36 | ** | ||
133 | 37 | ** | ||
134 | 38 | ** $QT_END_LICENSE$ | ||
135 | 39 | ** | ||
136 | 40 | ****************************************************************************/ | ||
137 | 41 | |||
138 | 42 | #include "qinputdeviceinfo_linux_p.h" | ||
139 | 43 | |||
140 | 44 | #include <libudev.h> | ||
141 | 45 | #include <libevdev/libevdev.h> | ||
142 | 46 | #include <fcntl.h> | ||
143 | 47 | #include <QDebug> | ||
144 | 48 | #include <QSocketNotifier> | ||
145 | 49 | #include <QTimer> | ||
146 | 50 | |||
147 | 51 | QInputDeviceInfoPrivate::QInputDeviceInfoPrivate(QObject *parent) : | ||
148 | 52 | QObject(parent) | ||
149 | 53 | , udev(0) | ||
150 | 54 | { | ||
151 | 55 | QTimer::singleShot(250,this,SLOT(init())); | ||
152 | 56 | } | ||
153 | 57 | |||
154 | 58 | void QInputDeviceInfoPrivate::init() | ||
155 | 59 | { | ||
156 | 60 | if (!udev) | ||
157 | 61 | udev = udev_new(); | ||
158 | 62 | |||
159 | 63 | struct udev_list_entry *devices, *dev_list_entry; | ||
160 | 64 | struct udev_device *dev; | ||
161 | 65 | |||
162 | 66 | QString subsystem = QStringLiteral("input"); | ||
163 | 67 | struct udev_enumerate *enumerate = 0; | ||
164 | 68 | |||
165 | 69 | if (udev) { | ||
166 | 70 | |||
167 | 71 | udevMonitor = udev_monitor_new_from_netlink(udev, "udev"); | ||
168 | 72 | udev_monitor_filter_add_match_subsystem_devtype(udevMonitor, subsystem.toLatin1(), NULL); | ||
169 | 73 | enumerate = udev_enumerate_new(udev); | ||
170 | 74 | udev_enumerate_add_match_subsystem(enumerate, subsystem.toLatin1()); | ||
171 | 75 | |||
172 | 76 | |||
173 | 77 | udev_monitor_enable_receiving(udevMonitor); | ||
174 | 78 | notifierFd = udev_monitor_get_fd(udevMonitor); | ||
175 | 79 | |||
176 | 80 | notifier = new QSocketNotifier(notifierFd, QSocketNotifier::Read, this); | ||
177 | 81 | connect(notifier, SIGNAL(activated(int)), this, SLOT(onUDevChanges())); | ||
178 | 82 | |||
179 | 83 | |||
180 | 84 | udev_enumerate_scan_devices(enumerate); | ||
181 | 85 | devices = udev_enumerate_get_list_entry(enumerate); | ||
182 | 86 | |||
183 | 87 | udev_list_entry_foreach(dev_list_entry, devices) { | ||
184 | 88 | const char *path; | ||
185 | 89 | path = udev_list_entry_get_name(dev_list_entry); | ||
186 | 90 | |||
187 | 91 | dev = udev_device_new_from_syspath(udev, path); | ||
188 | 92 | |||
189 | 93 | QString eventPath = QString::fromLatin1(udev_device_get_sysname(dev)); | ||
190 | 94 | |||
191 | 95 | if (qstrcmp(udev_device_get_subsystem(dev), "input") == 0 ) { | ||
192 | 96 | |||
193 | 97 | if (eventPath.contains(QStringLiteral("event"))) { | ||
194 | 98 | eventPath.prepend(QStringLiteral("/dev/input/")); | ||
195 | 99 | |||
196 | 100 | QInputDevice *iDevice = addDevice(eventPath); | ||
197 | 101 | if (!iDevice) | ||
198 | 102 | continue; | ||
199 | 103 | |||
200 | 104 | qDebug() << "*** ADDING DEVICE" << eventPath; | ||
201 | 105 | |||
202 | 106 | iDevice->setTypes(getInputTypes(dev)); | ||
203 | 107 | |||
204 | 108 | if (iDevice->switches().count() > 0 && iDevice->buttons().count() == 0) | ||
205 | 109 | iDevice->setTypes(iDevice->types() | QInputDeviceInfo::Switch); | ||
206 | 110 | |||
207 | 111 | if (iDevice->buttons().count() > 0 && iDevice->types() == QInputDeviceInfo::Unknown) | ||
208 | 112 | iDevice->setTypes(iDevice->types() | QInputDeviceInfo::Button); | ||
209 | 113 | |||
210 | 114 | deviceList.append(iDevice); | ||
211 | 115 | deviceMap.insert(eventPath,iDevice); | ||
212 | 116 | Q_EMIT newDevice(eventPath); | ||
213 | 117 | |||
214 | 118 | } | ||
215 | 119 | } | ||
216 | 120 | } | ||
217 | 121 | udev_enumerate_unref(enumerate); | ||
218 | 122 | } | ||
219 | 123 | Q_EMIT ready(); | ||
220 | 124 | } | ||
221 | 125 | |||
222 | 126 | QInputDeviceInfo::InputTypes QInputDeviceInfoPrivate::getInputTypes( struct udev_device *dev) | ||
223 | 127 | { | ||
224 | 128 | qDebug() << "******* have input type Keyboard" << udev_device_get_property_value(dev, "ID_INPUT_KEYBOARD"); | ||
225 | 129 | qDebug() << "******* have input type Mouse" << udev_device_get_property_value(dev, "ID_INPUT_MOUSE"); | ||
226 | 130 | qDebug() << "******* have input type Touchpad" << udev_device_get_property_value(dev, "ID_INPUT_TOUCHPAD"); | ||
227 | 131 | qDebug() << "******* have input type Touchscreen" << udev_device_get_property_value(dev, "ID_INPUT_TOUCHSCREEN"); | ||
228 | 132 | qDebug() << "******* have input type Tablet" << udev_device_get_property_value(dev, "ID_INPUT_TABLET"); | ||
229 | 133 | qDebug() << "******* have input type joystick" << udev_device_get_property_value(dev, "ID_INPUT_JOYSTICK"); | ||
230 | 134 | QInputDeviceInfo::InputTypes types = QInputDeviceInfo::Unknown; | ||
231 | 135 | if (qstrcmp(udev_device_get_property_value(dev, "ID_INPUT_KEYBOARD"), "1") == 0 ) | ||
232 | 136 | types |= QInputDeviceInfo::Keyboard; | ||
233 | 137 | |||
234 | 138 | if (qstrcmp(udev_device_get_property_value(dev, "ID_INPUT_MOUSE"), "1") == 0) | ||
235 | 139 | types |= QInputDeviceInfo::Mouse; | ||
236 | 140 | |||
237 | 141 | if (qstrcmp(udev_device_get_property_value(dev, "ID_INPUT_TOUCHPAD"), "1") == 0) | ||
238 | 142 | types |= QInputDeviceInfo::TouchPad; | ||
239 | 143 | |||
240 | 144 | if (qstrcmp(udev_device_get_property_value(dev, "ID_INPUT_TOUCHSCREEN"), "1") == 0 | ||
241 | 145 | || qstrcmp(udev_device_get_property_value(dev, "ID_INPUT_TABLET"), "1") == 0) | ||
242 | 146 | types |= QInputDeviceInfo::TouchScreen; | ||
243 | 147 | |||
244 | 148 | return types; | ||
245 | 149 | } | ||
246 | 150 | |||
247 | 151 | QInputDevice *QInputDeviceInfoPrivate::addDevice(const QString &path) | ||
248 | 152 | { | ||
249 | 153 | QInputDevice *inputDevice = new QInputDevice(this); | ||
250 | 154 | |||
251 | 155 | struct libevdev *dev = NULL; | ||
252 | 156 | int fd; | ||
253 | 157 | int rc = 1; | ||
254 | 158 | fd = open(path.toLatin1(), O_RDONLY|O_NONBLOCK); | ||
255 | 159 | |||
256 | 160 | if (fd == -1) { | ||
257 | 161 | qDebug() << "Failed to open"; | ||
258 | 162 | return inputDevice; | ||
259 | 163 | } | ||
260 | 164 | rc = libevdev_new_from_fd(fd, &dev); | ||
261 | 165 | if (rc < 0) { | ||
262 | 166 | qDebug() << "Failed to init libevdev ("<< strerror(-rc) << ")"; | ||
263 | 167 | return inputDevice; | ||
264 | 168 | } | ||
265 | 169 | |||
266 | 170 | inputDevice->setName(QString::fromLatin1(libevdev_get_name(dev))); | ||
267 | 171 | inputDevice->setDevicePath(path); | ||
268 | 172 | for (int i = 0; i < EV_MAX; i++) { | ||
269 | 173 | if (i == EV_KEY || i == EV_SW || i == EV_REL | ||
270 | 174 | || i == EV_REL || i == EV_ABS) { | ||
271 | 175 | for (int j = 0; j < libevdev_event_type_get_max(i); j++) { | ||
272 | 176 | if (libevdev_has_event_code(dev, i, j)) { | ||
273 | 177 | switch (i) { | ||
274 | 178 | case EV_KEY: | ||
275 | 179 | inputDevice->addButton(j); | ||
276 | 180 | break; | ||
277 | 181 | case EV_SW: | ||
278 | 182 | inputDevice->addSwitch(j); | ||
279 | 183 | break; | ||
280 | 184 | case EV_REL: | ||
281 | 185 | inputDevice->addRelativeAxis(j); | ||
282 | 186 | break; | ||
283 | 187 | case EV_ABS: | ||
284 | 188 | inputDevice->addAbsoluteAxis(j); | ||
285 | 189 | break; | ||
286 | 190 | }; | ||
287 | 191 | } | ||
288 | 192 | } | ||
289 | 193 | } | ||
290 | 194 | } | ||
291 | 195 | return inputDevice; | ||
292 | 196 | } | ||
293 | 197 | |||
294 | 198 | void QInputDeviceInfoPrivate::removeDevice(const QString &path) | ||
295 | 199 | { | ||
296 | 200 | for (int i = 0; i < deviceList.size(); ++i) { | ||
297 | 201 | if (deviceList.at(i)->devicePath() == path) { | ||
298 | 202 | delete deviceList.takeAt(i); | ||
299 | 203 | deviceMap.remove(path); | ||
300 | 204 | Q_EMIT deviceRemoved(path); | ||
301 | 205 | } | ||
302 | 206 | } | ||
303 | 207 | } | ||
304 | 208 | |||
305 | 209 | void QInputDeviceInfoPrivate::onUDevChanges() | ||
306 | 210 | { | ||
307 | 211 | struct udev_device *dev = udev_monitor_receive_device(udevMonitor); | ||
308 | 212 | if (dev) { | ||
309 | 213 | if (qstrcmp(udev_device_get_subsystem(dev), "input") == 0 ) { | ||
310 | 214 | QString eventPath = QString::fromLatin1(udev_device_get_sysname(dev)); | ||
311 | 215 | |||
312 | 216 | if (eventPath.contains(QStringLiteral("input"))) | ||
313 | 217 | return; | ||
314 | 218 | |||
315 | 219 | QString action = QString::fromStdString(udev_device_get_action(dev)); | ||
316 | 220 | |||
317 | 221 | if (!eventPath.contains(QStringLiteral("/dev/input/"))) | ||
318 | 222 | eventPath.prepend(QStringLiteral("/dev/input/")); | ||
319 | 223 | |||
320 | 224 | if (action == QStringLiteral("add")) { | ||
321 | 225 | |||
322 | 226 | QInputDevice *iDevice = addDevice(eventPath); | ||
323 | 227 | if (!iDevice) | ||
324 | 228 | return; | ||
325 | 229 | |||
326 | 230 | iDevice->setTypes(getInputTypes(dev)); | ||
327 | 231 | udev_device_unref(dev); | ||
328 | 232 | |||
329 | 233 | if (iDevice->switches().count() > 0 && iDevice->buttons().count() == 0) | ||
330 | 234 | iDevice->setTypes(iDevice->types() | QInputDeviceInfo::Switch); | ||
331 | 235 | |||
332 | 236 | if (iDevice->buttons().count() > 0 && iDevice->types() == QInputDeviceInfo::Unknown) | ||
333 | 237 | iDevice->setTypes(iDevice->types() | QInputDeviceInfo::Button); | ||
334 | 238 | |||
335 | 239 | deviceList.append(iDevice); | ||
336 | 240 | deviceMap.insert(eventPath,iDevice); | ||
337 | 241 | |||
338 | 242 | Q_EMIT newDevice(eventPath); | ||
339 | 243 | |||
340 | 244 | } else if (action == QStringLiteral("remove")) { | ||
341 | 245 | removeDevice(eventPath); | ||
342 | 246 | } | ||
343 | 247 | } | ||
344 | 248 | } | ||
345 | 249 | } | ||
346 | 0 | 250 | ||
347 | === added file 'plugins/Unity/InputInfo/linux/qinputdeviceinfo_linux_p.h' | |||
348 | --- plugins/Unity/InputInfo/linux/qinputdeviceinfo_linux_p.h 1970-01-01 00:00:00 +0000 | |||
349 | +++ plugins/Unity/InputInfo/linux/qinputdeviceinfo_linux_p.h 2015-06-22 12:17:35 +0000 | |||
350 | @@ -0,0 +1,91 @@ | |||
351 | 1 | /**************************************************************************** | ||
352 | 2 | ** | ||
353 | 3 | ** Copyright (C) 2014 Canonical, Ltd. and/or its subsidiary(-ies). | ||
354 | 4 | ** Contact: http://www.qt-project.org/legal | ||
355 | 5 | ** | ||
356 | 6 | ** This file is part of the QtSystems module of the Qt Toolkit. | ||
357 | 7 | ** | ||
358 | 8 | ** $QT_BEGIN_LICENSE:LGPL$ | ||
359 | 9 | ** Commercial License Usage | ||
360 | 10 | ** Licensees holding valid commercial Qt licenses may use this file in | ||
361 | 11 | ** accordance with the commercial license agreement provided with the | ||
362 | 12 | ** Software or, alternatively, in accordance with the terms contained in | ||
363 | 13 | ** a written agreement between you and Digia. For licensing terms and | ||
364 | 14 | ** conditions see http://qt.digia.com/licensing. For further information | ||
365 | 15 | ** use the contact form at http://qt.digia.com/contact-us. | ||
366 | 16 | ** | ||
367 | 17 | ** GNU Lesser General Public License Usage | ||
368 | 18 | ** Alternatively, this file may be used under the terms of the GNU Lesser | ||
369 | 19 | ** General Public License version 2.1 as published by the Free Software | ||
370 | 20 | ** Foundation and appearing in the file LICENSE.LGPL included in the | ||
371 | 21 | ** packaging of this file. Please review the following information to | ||
372 | 22 | ** ensure the GNU Lesser General Public License version 2.1 requirements | ||
373 | 23 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. | ||
374 | 24 | ** | ||
375 | 25 | ** In addition, as a special exception, Digia gives you certain additional | ||
376 | 26 | ** rights. These rights are described in the Digia Qt LGPL Exception | ||
377 | 27 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. | ||
378 | 28 | ** | ||
379 | 29 | ** GNU General Public License Usage | ||
380 | 30 | ** Alternatively, this file may be used under the terms of the GNU | ||
381 | 31 | ** General Public License version 3.0 as published by the Free Software | ||
382 | 32 | ** Foundation and appearing in the file LICENSE.GPL included in the | ||
383 | 33 | ** packaging of this file. Please review the following information to | ||
384 | 34 | ** ensure the GNU General Public License version 3.0 requirements will be | ||
385 | 35 | ** met: http://www.gnu.org/copyleft/gpl.html. | ||
386 | 36 | ** | ||
387 | 37 | ** | ||
388 | 38 | ** $QT_END_LICENSE$ | ||
389 | 39 | ** | ||
390 | 40 | ****************************************************************************/ | ||
391 | 41 | |||
392 | 42 | #ifndef QINPUTDEVICEINFO_LINUX_P_H | ||
393 | 43 | #define QINPUTDEVICEINFO_LINUX_P_H | ||
394 | 44 | |||
395 | 45 | #include <QObject> | ||
396 | 46 | #include "qinputinfo.h" | ||
397 | 47 | #include <libudev.h> | ||
398 | 48 | |||
399 | 49 | class QInputDevicePrivate : public QObject | ||
400 | 50 | { | ||
401 | 51 | Q_OBJECT | ||
402 | 52 | public: | ||
403 | 53 | explicit QInputDevicePrivate(QObject *parent = 0); | ||
404 | 54 | |||
405 | 55 | QString name; | ||
406 | 56 | QString devicePath; | ||
407 | 57 | QList <int> buttons; //keys | ||
408 | 58 | QList <int> switches; | ||
409 | 59 | QList <int> relativeAxis; | ||
410 | 60 | QList <int> absoluteAxis; | ||
411 | 61 | QInputDeviceInfo::InputTypes types; | ||
412 | 62 | }; | ||
413 | 63 | |||
414 | 64 | class QInputDeviceInfoPrivate : public QObject | ||
415 | 65 | { | ||
416 | 66 | Q_OBJECT | ||
417 | 67 | public: | ||
418 | 68 | explicit QInputDeviceInfoPrivate(QObject *parent = 0); | ||
419 | 69 | QVector <QInputDevice *> deviceList; | ||
420 | 70 | QMap <QString, QInputDevice *> deviceMap; | ||
421 | 71 | |||
422 | 72 | Q_SIGNALS: | ||
423 | 73 | void newDevice(const QString &); | ||
424 | 74 | void deviceRemoved(const QString &); | ||
425 | 75 | void ready(); | ||
426 | 76 | |||
427 | 77 | private: | ||
428 | 78 | struct udev *udev; | ||
429 | 79 | QInputDevice *addDevice(const QString &path); | ||
430 | 80 | void removeDevice(const QString &path); | ||
431 | 81 | QSocketNotifier *notifier; | ||
432 | 82 | int notifierFd; | ||
433 | 83 | struct udev_monitor *udevMonitor; | ||
434 | 84 | QInputDeviceInfo::InputTypes getInputTypes( struct udev_device *); | ||
435 | 85 | |||
436 | 86 | private Q_SLOTS: | ||
437 | 87 | void onUDevChanges(); | ||
438 | 88 | void init(); | ||
439 | 89 | }; | ||
440 | 90 | |||
441 | 91 | #endif // QINPUTDEVICEINFO_LINUX_P_H | ||
442 | 0 | 92 | ||
443 | === added file 'plugins/Unity/InputInfo/plugin.cpp' | |||
444 | --- plugins/Unity/InputInfo/plugin.cpp 1970-01-01 00:00:00 +0000 | |||
445 | +++ plugins/Unity/InputInfo/plugin.cpp 2015-06-22 12:17:35 +0000 | |||
446 | @@ -0,0 +1,32 @@ | |||
447 | 1 | /* | ||
448 | 2 | * Copyright 2015 Canonical Ltd. | ||
449 | 3 | * | ||
450 | 4 | * This program is free software; you can redistribute it and/or modify | ||
451 | 5 | * it under the terms of the GNU Lesser General Public License as published by | ||
452 | 6 | * the Free Software Foundation; version 3. | ||
453 | 7 | * | ||
454 | 8 | * This program is distributed in the hope that it will be useful, | ||
455 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
456 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
457 | 11 | * GNU Lesser General Public License for more details. | ||
458 | 12 | * | ||
459 | 13 | * You should have received a copy of the GNU Lesser General Public License | ||
460 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
461 | 15 | */ | ||
462 | 16 | |||
463 | 17 | // Qt | ||
464 | 18 | #include <QtQml/qqml.h> | ||
465 | 19 | |||
466 | 20 | // self | ||
467 | 21 | #include "plugin.h" | ||
468 | 22 | |||
469 | 23 | // local | ||
470 | 24 | #include "qdeclarativeinputdeviceinfo_p.h" | ||
471 | 25 | |||
472 | 26 | void InputInfoPlugin::registerTypes(const char *uri) | ||
473 | 27 | { | ||
474 | 28 | int major = 0; | ||
475 | 29 | int minor = 1; | ||
476 | 30 | qmlRegisterType<QDeclarativeInputDeviceInfo>(uri, major, minor, "InputDeviceInfo"); | ||
477 | 31 | qmlRegisterType<QInputDevice>(uri, major, minor, "InputInfo"); | ||
478 | 32 | } | ||
479 | 0 | 33 | ||
480 | === added file 'plugins/Unity/InputInfo/plugin.h' | |||
481 | --- plugins/Unity/InputInfo/plugin.h 1970-01-01 00:00:00 +0000 | |||
482 | +++ plugins/Unity/InputInfo/plugin.h 2015-06-22 12:17:35 +0000 | |||
483 | @@ -0,0 +1,30 @@ | |||
484 | 1 | /* | ||
485 | 2 | * Copyright 2015 Canonical Ltd. | ||
486 | 3 | * | ||
487 | 4 | * This program is free software; you can redistribute it and/or modify | ||
488 | 5 | * it under the terms of the GNU Lesser General Public License as published by | ||
489 | 6 | * the Free Software Foundation; version 3. | ||
490 | 7 | * | ||
491 | 8 | * This program is distributed in the hope that it will be useful, | ||
492 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
493 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
494 | 11 | * GNU Lesser General Public License for more details. | ||
495 | 12 | * | ||
496 | 13 | * You should have received a copy of the GNU Lesser General Public License | ||
497 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
498 | 15 | */ | ||
499 | 16 | |||
500 | 17 | #ifndef INPUTINFO_PLUGIN_H | ||
501 | 18 | #define INPUTINFO_PLUGIN_H | ||
502 | 19 | |||
503 | 20 | #include <QtQml/QQmlExtensionPlugin> | ||
504 | 21 | |||
505 | 22 | class InputInfoPlugin : public QQmlExtensionPlugin | ||
506 | 23 | { | ||
507 | 24 | Q_OBJECT | ||
508 | 25 | Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface") | ||
509 | 26 | public: | ||
510 | 27 | void registerTypes(const char *uri); | ||
511 | 28 | }; | ||
512 | 29 | |||
513 | 30 | #endif // INPUTINFO_PLUGIN_H | ||
514 | 0 | 31 | ||
515 | === added file 'plugins/Unity/InputInfo/qdeclarativeinputdeviceinfo.cpp' | |||
516 | --- plugins/Unity/InputInfo/qdeclarativeinputdeviceinfo.cpp 1970-01-01 00:00:00 +0000 | |||
517 | +++ plugins/Unity/InputInfo/qdeclarativeinputdeviceinfo.cpp 2015-06-22 12:17:35 +0000 | |||
518 | @@ -0,0 +1,143 @@ | |||
519 | 1 | /**************************************************************************** | ||
520 | 2 | ** | ||
521 | 3 | ** Copyright (C) 2015 Jolla. | ||
522 | 4 | ** Contact: http://www.qt-project.org/legal | ||
523 | 5 | ** | ||
524 | 6 | ** This file is part of the QtSystems module of the Qt Toolkit. | ||
525 | 7 | ** | ||
526 | 8 | ** $QT_BEGIN_LICENSE:LGPL$ | ||
527 | 9 | ** Commercial License Usage | ||
528 | 10 | ** Licensees holding valid commercial Qt licenses may use this file in | ||
529 | 11 | ** accordance with the commercial license agreement provided with the | ||
530 | 12 | ** Software or, alternatively, in accordance with the terms contained in | ||
531 | 13 | ** a written agreement between you and Digia. For licensing terms and | ||
532 | 14 | ** conditions see http://qt.digia.com/licensing. For further information | ||
533 | 15 | ** use the contact form at http://qt.digia.com/contact-us. | ||
534 | 16 | ** | ||
535 | 17 | ** GNU Lesser General Public License Usage | ||
536 | 18 | ** Alternatively, this file may be used under the terms of the GNU Lesser | ||
537 | 19 | ** General Public License version 2.1 as published by the Free Software | ||
538 | 20 | ** Foundation and appearing in the file LICENSE.LGPL included in the | ||
539 | 21 | ** packaging of this file. Please review the following information to | ||
540 | 22 | ** ensure the GNU Lesser General Public License version 2.1 requirements | ||
541 | 23 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. | ||
542 | 24 | ** | ||
543 | 25 | ** In addition, as a special exception, Digia gives you certain additional | ||
544 | 26 | ** rights. These rights are described in the Digia Qt LGPL Exception | ||
545 | 27 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. | ||
546 | 28 | ** | ||
547 | 29 | ** GNU General Public License Usage | ||
548 | 30 | ** Alternatively, this file may be used under the terms of the GNU | ||
549 | 31 | ** General Public License version 3.0 as published by the Free Software | ||
550 | 32 | ** Foundation and appearing in the file LICENSE.GPL included in the | ||
551 | 33 | ** packaging of this file. Please review the following information to | ||
552 | 34 | ** ensure the GNU General Public License version 3.0 requirements will be | ||
553 | 35 | ** met: http://www.gnu.org/copyleft/gpl.html. | ||
554 | 36 | ** | ||
555 | 37 | ** | ||
556 | 38 | ** $QT_END_LICENSE$ | ||
557 | 39 | ** | ||
558 | 40 | ****************************************************************************/ | ||
559 | 41 | #include "qdeclarativeinputdeviceinfo_p.h" | ||
560 | 42 | |||
561 | 43 | QDeclarativeInputDeviceInfo::QDeclarativeInputDeviceInfo(QObject *parent) : | ||
562 | 44 | QAbstractListModel(parent), | ||
563 | 45 | deviceInfo(new QInputDeviceInfo) | ||
564 | 46 | { | ||
565 | 47 | connect(deviceInfo,SIGNAL(ready()),this,SLOT(updateDeviceList())); | ||
566 | 48 | connect(deviceInfo, &QInputDeviceInfo::deviceAdded,this,&QDeclarativeInputDeviceInfo::addedDevice); | ||
567 | 49 | connect(deviceInfo, &QInputDeviceInfo::deviceRemoved,this,&QDeclarativeInputDeviceInfo::removedDevice); | ||
568 | 50 | } | ||
569 | 51 | |||
570 | 52 | QDeclarativeInputDeviceInfo::~QDeclarativeInputDeviceInfo() | ||
571 | 53 | { | ||
572 | 54 | delete deviceInfo; | ||
573 | 55 | } | ||
574 | 56 | |||
575 | 57 | QVariant QDeclarativeInputDeviceInfo::data(const QModelIndex &index, int role) const | ||
576 | 58 | { | ||
577 | 59 | switch (role) { | ||
578 | 60 | case ServiceRole: | ||
579 | 61 | return QVariant::fromValue(static_cast<QObject *>(inputDevices.value(index.row()))); | ||
580 | 62 | } | ||
581 | 63 | |||
582 | 64 | return QVariant(); | ||
583 | 65 | } | ||
584 | 66 | |||
585 | 67 | int QDeclarativeInputDeviceInfo::rowCount(const QModelIndex &parent) const | ||
586 | 68 | { | ||
587 | 69 | Q_UNUSED(parent); | ||
588 | 70 | |||
589 | 71 | return inputDevices.count(); | ||
590 | 72 | } | ||
591 | 73 | |||
592 | 74 | int QDeclarativeInputDeviceInfo::indexOf(const QString &devicePath) const | ||
593 | 75 | { | ||
594 | 76 | int idx(-1); | ||
595 | 77 | Q_FOREACH (QInputDevice *device, inputDevices) { | ||
596 | 78 | idx++; | ||
597 | 79 | if (device->devicePath() == devicePath) return idx; | ||
598 | 80 | } | ||
599 | 81 | |||
600 | 82 | return -1; | ||
601 | 83 | } | ||
602 | 84 | |||
603 | 85 | QInputDevice *QDeclarativeInputDeviceInfo::get(int index) const | ||
604 | 86 | { | ||
605 | 87 | if (index < 0 || index > inputDevices.count()) | ||
606 | 88 | return 0; | ||
607 | 89 | return inputDevices.value(index); | ||
608 | 90 | } | ||
609 | 91 | |||
610 | 92 | void QDeclarativeInputDeviceInfo::updateDeviceList() | ||
611 | 93 | { | ||
612 | 94 | QVector <QInputDevice *> newDevices = deviceInfo->deviceList(); | ||
613 | 95 | |||
614 | 96 | int numNew = newDevices.count(); | ||
615 | 97 | |||
616 | 98 | for (int i = 0; i < numNew; i++) { | ||
617 | 99 | int j = inputDevices.indexOf(newDevices.value(i)); | ||
618 | 100 | if (j == -1) { | ||
619 | 101 | // not found -> remove from list | ||
620 | 102 | beginInsertRows(QModelIndex(), i, i); | ||
621 | 103 | inputDevices.insert(i, newDevices.value(i)); | ||
622 | 104 | endInsertRows(); | ||
623 | 105 | } else if (i != j) { | ||
624 | 106 | // changed its position -> move it | ||
625 | 107 | QInputDevice* device = inputDevices.value(j); | ||
626 | 108 | beginMoveRows(QModelIndex(), j, j, QModelIndex(), i); | ||
627 | 109 | inputDevices.remove(j); | ||
628 | 110 | inputDevices.insert(i, device); | ||
629 | 111 | endMoveRows(); | ||
630 | 112 | } else { | ||
631 | 113 | QModelIndex changedIndex(this->index(j, 0, QModelIndex())); | ||
632 | 114 | Q_EMIT dataChanged(changedIndex, changedIndex); | ||
633 | 115 | } | ||
634 | 116 | } | ||
635 | 117 | |||
636 | 118 | int numOld = inputDevices.count(); | ||
637 | 119 | if (numOld > numNew) { | ||
638 | 120 | beginRemoveRows(QModelIndex(), numNew, numOld - 1); | ||
639 | 121 | inputDevices.remove(numNew, numOld - numNew); | ||
640 | 122 | endRemoveRows(); | ||
641 | 123 | } | ||
642 | 124 | } | ||
643 | 125 | |||
644 | 126 | void QDeclarativeInputDeviceInfo::addedDevice(const QString &devicePath) | ||
645 | 127 | { | ||
646 | 128 | updateDeviceList(); | ||
647 | 129 | Q_EMIT newDevice(devicePath); | ||
648 | 130 | } | ||
649 | 131 | |||
650 | 132 | void QDeclarativeInputDeviceInfo::removedDevice(const QString &devicePath) | ||
651 | 133 | { | ||
652 | 134 | updateDeviceList(); | ||
653 | 135 | Q_EMIT deviceRemoved(devicePath); | ||
654 | 136 | } | ||
655 | 137 | |||
656 | 138 | QHash<int, QByteArray> QDeclarativeInputDeviceInfo::roleNames() const | ||
657 | 139 | { | ||
658 | 140 | QHash<int, QByteArray> roles; | ||
659 | 141 | roles.insert(ServiceRole, "service"); | ||
660 | 142 | return roles; | ||
661 | 143 | } | ||
662 | 0 | 144 | ||
663 | === added file 'plugins/Unity/InputInfo/qdeclarativeinputdeviceinfo_p.h' | |||
664 | --- plugins/Unity/InputInfo/qdeclarativeinputdeviceinfo_p.h 1970-01-01 00:00:00 +0000 | |||
665 | +++ plugins/Unity/InputInfo/qdeclarativeinputdeviceinfo_p.h 2015-06-22 12:17:35 +0000 | |||
666 | @@ -0,0 +1,86 @@ | |||
667 | 1 | /**************************************************************************** | ||
668 | 2 | ** | ||
669 | 3 | ** Copyright (C) 2015 Jolla. | ||
670 | 4 | ** Contact: http://www.qt-project.org/legal | ||
671 | 5 | ** | ||
672 | 6 | ** This file is part of the QtSystems module of the Qt Toolkit. | ||
673 | 7 | ** | ||
674 | 8 | ** $QT_BEGIN_LICENSE:LGPL$ | ||
675 | 9 | ** Commercial License Usage | ||
676 | 10 | ** Licensees holding valid commercial Qt licenses may use this file in | ||
677 | 11 | ** accordance with the commercial license agreement provided with the | ||
678 | 12 | ** Software or, alternatively, in accordance with the terms contained in | ||
679 | 13 | ** a written agreement between you and Digia. For licensing terms and | ||
680 | 14 | ** conditions see http://qt.digia.com/licensing. For further information | ||
681 | 15 | ** use the contact form at http://qt.digia.com/contact-us. | ||
682 | 16 | ** | ||
683 | 17 | ** GNU Lesser General Public License Usage | ||
684 | 18 | ** Alternatively, this file may be used under the terms of the GNU Lesser | ||
685 | 19 | ** General Public License version 2.1 as published by the Free Software | ||
686 | 20 | ** Foundation and appearing in the file LICENSE.LGPL included in the | ||
687 | 21 | ** packaging of this file. Please review the following information to | ||
688 | 22 | ** ensure the GNU Lesser General Public License version 2.1 requirements | ||
689 | 23 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. | ||
690 | 24 | ** | ||
691 | 25 | ** In addition, as a special exception, Digia gives you certain additional | ||
692 | 26 | ** rights. These rights are described in the Digia Qt LGPL Exception | ||
693 | 27 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. | ||
694 | 28 | ** | ||
695 | 29 | ** GNU General Public License Usage | ||
696 | 30 | ** Alternatively, this file may be used under the terms of the GNU | ||
697 | 31 | ** General Public License version 3.0 as published by the Free Software | ||
698 | 32 | ** Foundation and appearing in the file LICENSE.GPL included in the | ||
699 | 33 | ** packaging of this file. Please review the following information to | ||
700 | 34 | ** ensure the GNU General Public License version 3.0 requirements will be | ||
701 | 35 | ** met: http://www.gnu.org/copyleft/gpl.html. | ||
702 | 36 | ** | ||
703 | 37 | ** | ||
704 | 38 | ** $QT_END_LICENSE$ | ||
705 | 39 | ** | ||
706 | 40 | ****************************************************************************/ | ||
707 | 41 | |||
708 | 42 | #ifndef QDECLARATIVEINPUTDEVICEINFO_H | ||
709 | 43 | #define QDECLARATIVEINPUTDEVICEINFO_H | ||
710 | 44 | |||
711 | 45 | #include <QObject> | ||
712 | 46 | #include <QAbstractListModel> | ||
713 | 47 | #include "qinputinfo.h" | ||
714 | 48 | |||
715 | 49 | class QDeclarativeInputDeviceInfo : public QAbstractListModel | ||
716 | 50 | { | ||
717 | 51 | Q_OBJECT | ||
718 | 52 | Q_DISABLE_COPY(QDeclarativeInputDeviceInfo) | ||
719 | 53 | |||
720 | 54 | public: | ||
721 | 55 | enum ItemRoles { | ||
722 | 56 | ServiceRole = Qt::UserRole + 1 | ||
723 | 57 | }; | ||
724 | 58 | |||
725 | 59 | explicit QDeclarativeInputDeviceInfo(QObject *parent = 0); | ||
726 | 60 | virtual ~QDeclarativeInputDeviceInfo(); | ||
727 | 61 | |||
728 | 62 | QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const; | ||
729 | 63 | int rowCount(const QModelIndex &parent = QModelIndex()) const; | ||
730 | 64 | |||
731 | 65 | QHash<int, QByteArray> roleNames() const; | ||
732 | 66 | |||
733 | 67 | Q_INVOKABLE int indexOf(const QString &devicePath) const; | ||
734 | 68 | |||
735 | 69 | Q_INVOKABLE QInputDevice *get(int index) const; | ||
736 | 70 | |||
737 | 71 | Q_SIGNALS: | ||
738 | 72 | void newDevice(const QString &devicePath); | ||
739 | 73 | void deviceRemoved(const QString &devicePath); | ||
740 | 74 | |||
741 | 75 | public Q_SLOTS: | ||
742 | 76 | void updateDeviceList(); | ||
743 | 77 | private: | ||
744 | 78 | QInputDeviceInfo *deviceInfo; | ||
745 | 79 | QVector<QInputDevice *> inputDevices; | ||
746 | 80 | private Q_SLOTS: | ||
747 | 81 | void addedDevice(const QString &); | ||
748 | 82 | void removedDevice(const QString &path); | ||
749 | 83 | |||
750 | 84 | }; | ||
751 | 85 | |||
752 | 86 | #endif // QDECLARATIVEINPUTDEVICEINFO_H | ||
753 | 0 | 87 | ||
754 | === added file 'plugins/Unity/InputInfo/qinputinfo.cpp' | |||
755 | --- plugins/Unity/InputInfo/qinputinfo.cpp 1970-01-01 00:00:00 +0000 | |||
756 | +++ plugins/Unity/InputInfo/qinputinfo.cpp 2015-06-22 12:17:35 +0000 | |||
757 | @@ -0,0 +1,159 @@ | |||
758 | 1 | /**************************************************************************** | ||
759 | 2 | ** | ||
760 | 3 | ** Copyright (C) 2014 Canonical, Ltd. and/or its subsidiary(-ies). | ||
761 | 4 | ** Contact: http://www.qt-project.org/legal | ||
762 | 5 | ** | ||
763 | 6 | ** This file is part of the QtSystems module of the Qt Toolkit. | ||
764 | 7 | ** | ||
765 | 8 | ** $QT_BEGIN_LICENSE:LGPL$ | ||
766 | 9 | ** Commercial License Usage | ||
767 | 10 | ** Licensees holding valid commercial Qt licenses may use this file in | ||
768 | 11 | ** accordance with the commercial license agreement provided with the | ||
769 | 12 | ** Software or, alternatively, in accordance with the terms contained in | ||
770 | 13 | ** a written agreement between you and Digia. For licensing terms and | ||
771 | 14 | ** conditions see http://qt.digia.com/licensing. For further information | ||
772 | 15 | ** use the contact form at http://qt.digia.com/contact-us. | ||
773 | 16 | ** | ||
774 | 17 | ** GNU Lesser General Public License Usage | ||
775 | 18 | ** Alternatively, this file may be used under the terms of the GNU Lesser | ||
776 | 19 | ** General Public License version 2.1 as published by the Free Software | ||
777 | 20 | ** Foundation and appearing in the file LICENSE.LGPL included in the | ||
778 | 21 | ** packaging of this file. Please review the following information to | ||
779 | 22 | ** ensure the GNU Lesser General Public License version 2.1 requirements | ||
780 | 23 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. | ||
781 | 24 | ** | ||
782 | 25 | ** In addition, as a special exception, Digia gives you certain additional | ||
783 | 26 | ** rights. These rights are described in the Digia Qt LGPL Exception | ||
784 | 27 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. | ||
785 | 28 | ** | ||
786 | 29 | ** GNU General Public License Usage | ||
787 | 30 | ** Alternatively, this file may be used under the terms of the GNU | ||
788 | 31 | ** General Public License version 3.0 as published by the Free Software | ||
789 | 32 | ** Foundation and appearing in the file LICENSE.GPL included in the | ||
790 | 33 | ** packaging of this file. Please review the following information to | ||
791 | 34 | ** ensure the GNU General Public License version 3.0 requirements will be | ||
792 | 35 | ** met: http://www.gnu.org/copyleft/gpl.html. | ||
793 | 36 | ** | ||
794 | 37 | ** | ||
795 | 38 | ** $QT_END_LICENSE$ | ||
796 | 39 | ** | ||
797 | 40 | ****************************************************************************/ | ||
798 | 41 | |||
799 | 42 | #include "qinputinfo.h" | ||
800 | 43 | |||
801 | 44 | #if defined(Q_OS_LINUX) | ||
802 | 45 | #include "linux/qinputdeviceinfo_linux_p.h" | ||
803 | 46 | #endif | ||
804 | 47 | |||
805 | 48 | QT_BEGIN_NAMESPACE | ||
806 | 49 | |||
807 | 50 | |||
808 | 51 | QInputDevicePrivate::QInputDevicePrivate(QObject *parent) : | ||
809 | 52 | QObject(parent), | ||
810 | 53 | types(QInputDeviceInfo::Unknown) | ||
811 | 54 | { | ||
812 | 55 | } | ||
813 | 56 | |||
814 | 57 | QInputDevice::QInputDevice(QObject *parent) : | ||
815 | 58 | QObject(parent), | ||
816 | 59 | d_ptr(new QInputDevicePrivate(this)) | ||
817 | 60 | { | ||
818 | 61 | } | ||
819 | 62 | |||
820 | 63 | QString QInputDevice::name() const | ||
821 | 64 | { | ||
822 | 65 | return d_ptr->name; | ||
823 | 66 | } | ||
824 | 67 | |||
825 | 68 | void QInputDevice::setName(const QString &name) | ||
826 | 69 | { | ||
827 | 70 | d_ptr->name = name; | ||
828 | 71 | } | ||
829 | 72 | |||
830 | 73 | QString QInputDevice::devicePath() const | ||
831 | 74 | { | ||
832 | 75 | return d_ptr->devicePath; | ||
833 | 76 | } | ||
834 | 77 | |||
835 | 78 | void QInputDevice::setDevicePath(const QString &path) | ||
836 | 79 | { | ||
837 | 80 | d_ptr->devicePath = path; | ||
838 | 81 | } | ||
839 | 82 | |||
840 | 83 | QList <int> QInputDevice::buttons() const | ||
841 | 84 | { | ||
842 | 85 | return d_ptr->buttons; | ||
843 | 86 | } | ||
844 | 87 | |||
845 | 88 | void QInputDevice::addButton(int buttonCode) | ||
846 | 89 | { | ||
847 | 90 | d_ptr->buttons.append(buttonCode); | ||
848 | 91 | } | ||
849 | 92 | |||
850 | 93 | QList <int> QInputDevice::switches() const | ||
851 | 94 | { | ||
852 | 95 | return d_ptr->switches; | ||
853 | 96 | } | ||
854 | 97 | |||
855 | 98 | void QInputDevice::addSwitch(int switchCode) | ||
856 | 99 | { | ||
857 | 100 | d_ptr->switches.append(switchCode); | ||
858 | 101 | } | ||
859 | 102 | |||
860 | 103 | QList <int> QInputDevice::relativeAxis() const | ||
861 | 104 | { | ||
862 | 105 | return d_ptr->relativeAxis; | ||
863 | 106 | } | ||
864 | 107 | |||
865 | 108 | void QInputDevice::addRelativeAxis(int axisCode) | ||
866 | 109 | { | ||
867 | 110 | d_ptr->relativeAxis.append(axisCode); | ||
868 | 111 | } | ||
869 | 112 | |||
870 | 113 | QList <int> QInputDevice::absoluteAxis() const | ||
871 | 114 | { | ||
872 | 115 | return d_ptr->absoluteAxis; | ||
873 | 116 | } | ||
874 | 117 | |||
875 | 118 | void QInputDevice::addAbsoluteAxis(int axisCode) | ||
876 | 119 | { | ||
877 | 120 | d_ptr->absoluteAxis.append(axisCode); | ||
878 | 121 | } | ||
879 | 122 | |||
880 | 123 | QInputDeviceInfo::InputTypes QInputDevice::types() | ||
881 | 124 | { | ||
882 | 125 | return d_ptr->types; | ||
883 | 126 | } | ||
884 | 127 | |||
885 | 128 | void QInputDevice::setTypes(QInputDeviceInfo::InputTypes types) | ||
886 | 129 | { | ||
887 | 130 | d_ptr->types = types; | ||
888 | 131 | } | ||
889 | 132 | |||
890 | 133 | |||
891 | 134 | QInputDeviceInfo::QInputDeviceInfo(QObject *parent) : | ||
892 | 135 | QObject(parent), | ||
893 | 136 | d_ptr(new QInputDeviceInfoPrivate(this)) | ||
894 | 137 | { | ||
895 | 138 | connect(d_ptr, &QInputDeviceInfoPrivate::newDevice,this,&QInputDeviceInfo::addedDevice); | ||
896 | 139 | connect(d_ptr, &QInputDeviceInfoPrivate::deviceRemoved,this,&QInputDeviceInfo::deviceRemoved); | ||
897 | 140 | |||
898 | 141 | connect(d_ptr,SIGNAL(ready()),this,SIGNAL(ready())); | ||
899 | 142 | } | ||
900 | 143 | |||
901 | 144 | QVector <QInputDevice *> QInputDeviceInfo::deviceList() | ||
902 | 145 | { | ||
903 | 146 | return d_ptr->deviceList; | ||
904 | 147 | } | ||
905 | 148 | |||
906 | 149 | QMap <QString, QInputDevice *> QInputDeviceInfo::deviceMap() | ||
907 | 150 | { | ||
908 | 151 | return d_ptr->deviceMap; | ||
909 | 152 | } | ||
910 | 153 | |||
911 | 154 | void QInputDeviceInfo::addedDevice(const QString & devicePath) | ||
912 | 155 | { | ||
913 | 156 | Q_EMIT deviceAdded(devicePath); | ||
914 | 157 | } | ||
915 | 158 | |||
916 | 159 | QT_END_NAMESPACE | ||
917 | 0 | 160 | ||
918 | === added file 'plugins/Unity/InputInfo/qinputinfo.h' | |||
919 | --- plugins/Unity/InputInfo/qinputinfo.h 1970-01-01 00:00:00 +0000 | |||
920 | +++ plugins/Unity/InputInfo/qinputinfo.h 2015-06-22 12:17:35 +0000 | |||
921 | @@ -0,0 +1,143 @@ | |||
922 | 1 | /**************************************************************************** | ||
923 | 2 | ** | ||
924 | 3 | ** Copyright (C) 2014 Canonical, Ltd. and/or its subsidiary(-ies). | ||
925 | 4 | ** Contact: http://www.qt-project.org/legal | ||
926 | 5 | ** | ||
927 | 6 | ** This file is part of the QtSystems module of the Qt Toolkit. | ||
928 | 7 | ** | ||
929 | 8 | ** $QT_BEGIN_LICENSE:LGPL$ | ||
930 | 9 | ** Commercial License Usage | ||
931 | 10 | ** Licensees holding valid commercial Qt licenses may use this file in | ||
932 | 11 | ** accordance with the commercial license agreement provided with the | ||
933 | 12 | ** Software or, alternatively, in accordance with the terms contained in | ||
934 | 13 | ** a written agreement between you and Digia. For licensing terms and | ||
935 | 14 | ** conditions see http://qt.digia.com/licensing. For further information | ||
936 | 15 | ** use the contact form at http://qt.digia.com/contact-us. | ||
937 | 16 | ** | ||
938 | 17 | ** GNU Lesser General Public License Usage | ||
939 | 18 | ** Alternatively, this file may be used under the terms of the GNU Lesser | ||
940 | 19 | ** General Public License version 2.1 as published by the Free Software | ||
941 | 20 | ** Foundation and appearing in the file LICENSE.LGPL included in the | ||
942 | 21 | ** packaging of this file. Please review the following information to | ||
943 | 22 | ** ensure the GNU Lesser General Public License version 2.1 requirements | ||
944 | 23 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. | ||
945 | 24 | ** | ||
946 | 25 | ** In addition, as a special exception, Digia gives you certain additional | ||
947 | 26 | ** rights. These rights are described in the Digia Qt LGPL Exception | ||
948 | 27 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. | ||
949 | 28 | ** | ||
950 | 29 | ** GNU General Public License Usage | ||
951 | 30 | ** Alternatively, this file may be used under the terms of the GNU | ||
952 | 31 | ** General Public License version 3.0 as published by the Free Software | ||
953 | 32 | ** Foundation and appearing in the file LICENSE.GPL included in the | ||
954 | 33 | ** packaging of this file. Please review the following information to | ||
955 | 34 | ** ensure the GNU General Public License version 3.0 requirements will be | ||
956 | 35 | ** met: http://www.gnu.org/copyleft/gpl.html. | ||
957 | 36 | ** | ||
958 | 37 | ** | ||
959 | 38 | ** $QT_END_LICENSE$ | ||
960 | 39 | ** | ||
961 | 40 | ****************************************************************************/ | ||
962 | 41 | |||
963 | 42 | #ifndef QINPUTINFO_H | ||
964 | 43 | #define QINPUTINFO_H | ||
965 | 44 | |||
966 | 45 | #include <QObject> | ||
967 | 46 | #include <QVector> | ||
968 | 47 | #include <QMap> | ||
969 | 48 | #include <QSocketNotifier> | ||
970 | 49 | #include <QDebug> | ||
971 | 50 | |||
972 | 51 | class QInputDeviceInfoPrivate; | ||
973 | 52 | class QInputDevicePrivate; | ||
974 | 53 | class QInputDevice; | ||
975 | 54 | |||
976 | 55 | class QInputDeviceInfoPrivate; | ||
977 | 56 | class QInputDeviceInfo : public QObject | ||
978 | 57 | { | ||
979 | 58 | Q_OBJECT | ||
980 | 59 | Q_PROPERTY(int deviceCount READ deviceCount) | ||
981 | 60 | public: | ||
982 | 61 | |||
983 | 62 | enum InputType { | ||
984 | 63 | Unknown = 0, | ||
985 | 64 | Button = 1, | ||
986 | 65 | Mouse = 2, | ||
987 | 66 | TouchPad = 4, | ||
988 | 67 | TouchScreen = 8, | ||
989 | 68 | Keyboard = 16, | ||
990 | 69 | Switch = 32 | ||
991 | 70 | }; | ||
992 | 71 | Q_ENUMS(InputType) | ||
993 | 72 | Q_FLAGS(InputTypes) | ||
994 | 73 | Q_DECLARE_FLAGS(InputTypes, InputType) | ||
995 | 74 | |||
996 | 75 | explicit QInputDeviceInfo(QObject *parent = 0); | ||
997 | 76 | |||
998 | 77 | Q_INVOKABLE QVector <QInputDevice *> deviceList(); | ||
999 | 78 | |||
1000 | 79 | Q_INVOKABLE QMap <QString, QInputDevice *> deviceMap(); | ||
1001 | 80 | int deviceCount() { return deviceList().count(); } | ||
1002 | 81 | Q_SIGNALS: | ||
1003 | 82 | |||
1004 | 83 | void deviceAdded(const QString & devicePath); | ||
1005 | 84 | void deviceRemoved(const QString & devicePath); | ||
1006 | 85 | |||
1007 | 86 | void ready(); | ||
1008 | 87 | |||
1009 | 88 | public Q_SLOTS: | ||
1010 | 89 | void addedDevice(const QString & devicePath); | ||
1011 | 90 | |||
1012 | 91 | private: | ||
1013 | 92 | Q_DISABLE_COPY(QInputDeviceInfo) | ||
1014 | 93 | #if !defined(QT_SIMULATOR) | ||
1015 | 94 | QInputDeviceInfoPrivate *const d_ptr; | ||
1016 | 95 | Q_DECLARE_PRIVATE(QInputDeviceInfo) | ||
1017 | 96 | #endif | ||
1018 | 97 | }; | ||
1019 | 98 | |||
1020 | 99 | class QInputDevice : public QObject | ||
1021 | 100 | { | ||
1022 | 101 | friend class QInputDeviceInfoPrivate; | ||
1023 | 102 | Q_OBJECT | ||
1024 | 103 | Q_ENUMS(InputType) | ||
1025 | 104 | Q_FLAGS(InputTypes) | ||
1026 | 105 | Q_PROPERTY(QString name READ name NOTIFY nameChanged) | ||
1027 | 106 | Q_PROPERTY(QString devicePath READ devicePath NOTIFY devicePathChanged) | ||
1028 | 107 | Q_PROPERTY(QList <int> buttons READ buttons NOTIFY buttonsChanged) | ||
1029 | 108 | Q_PROPERTY(QList <int> switches READ switches NOTIFY switchesChanged) | ||
1030 | 109 | Q_PROPERTY(QList <int> relativeAxis READ relativeAxis NOTIFY relativeAxisChanged) | ||
1031 | 110 | Q_PROPERTY(QList <int> absoluteAxis READ absoluteAxis NOTIFY absoluteAxisChanged) | ||
1032 | 111 | Q_PROPERTY(QInputDeviceInfo::InputTypes types READ types NOTIFY typesChanged) | ||
1033 | 112 | |||
1034 | 113 | public: | ||
1035 | 114 | explicit QInputDevice(QObject *parent = 0); | ||
1036 | 115 | |||
1037 | 116 | QString name() const; | ||
1038 | 117 | QString devicePath() const; | ||
1039 | 118 | QList <int> buttons() const; //keys event code | ||
1040 | 119 | QList <int> switches() const; | ||
1041 | 120 | QList <int> relativeAxis() const; | ||
1042 | 121 | QList <int> absoluteAxis() const; | ||
1043 | 122 | |||
1044 | 123 | QInputDeviceInfo::InputTypes types(); | ||
1045 | 124 | Q_SIGNALS: | ||
1046 | 125 | void nameChanged(); | ||
1047 | 126 | void devicePathChanged(); | ||
1048 | 127 | void buttonsChanged(); | ||
1049 | 128 | void switchesChanged(); | ||
1050 | 129 | void relativeAxisChanged(); | ||
1051 | 130 | void absoluteAxisChanged(); | ||
1052 | 131 | void typesChanged(); | ||
1053 | 132 | private: | ||
1054 | 133 | QInputDevicePrivate *d_ptr; | ||
1055 | 134 | void setName(const QString &); | ||
1056 | 135 | void setDevicePath(const QString &); | ||
1057 | 136 | void addButton(int); | ||
1058 | 137 | void addSwitch(int); | ||
1059 | 138 | void addRelativeAxis(int); | ||
1060 | 139 | void addAbsoluteAxis(int); | ||
1061 | 140 | void setTypes(QInputDeviceInfo::InputTypes); | ||
1062 | 141 | }; | ||
1063 | 142 | |||
1064 | 143 | #endif // QINPUTINFO_H | ||
1065 | 0 | 144 | ||
1066 | === added file 'plugins/Unity/InputInfo/qmldir' | |||
1067 | --- plugins/Unity/InputInfo/qmldir 1970-01-01 00:00:00 +0000 | |||
1068 | +++ plugins/Unity/InputInfo/qmldir 2015-06-22 12:17:35 +0000 | |||
1069 | @@ -0,0 +1,3 @@ | |||
1070 | 1 | module Unity.InputInfo | ||
1071 | 2 | plugin InputInfo | ||
1072 | 3 | typeinfo InputInfo.qmltypes |
FAILED: Continuous integration, rev:1746 jenkins. qa.ubuntu. com/job/ unity8- ci/5675/ jenkins. qa.ubuntu. com/job/ generic- deb-autopilot- vivid-touch/ 2628/console jenkins. qa.ubuntu. com/job/ unity-phablet- qmluitests- vivid/840/ console jenkins. qa.ubuntu. com/job/ unity8- vivid-amd64- ci/840/ console jenkins. qa.ubuntu. com/job/ unity8- vivid-i386- ci/840/ console jenkins. qa.ubuntu. com/job/ generic- mediumtests- builder- vivid-armhf/ 2626/console
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild: s-jenkins. ubuntu- ci:8080/ job/unity8- ci/5675/ rebuild
http://