Merge lp:~abreu-alexandre/oxide/accelerometer-support into lp:~oxide-developers/oxide/oxide.trunk
- accelerometer-support
- Merge into oxide.trunk
Proposed by
Alexandre Abreu
Status: | Work in progress | ||||
---|---|---|---|---|---|
Proposed branch: | lp:~abreu-alexandre/oxide/accelerometer-support | ||||
Merge into: | lp:~oxide-developers/oxide/oxide.trunk | ||||
Diff against target: |
573 lines (+487/-1) 8 files modified
qt/build/system.gyp (+17/-0) qt/core/browser/oxide_data_fetcher_shared_memory.cc (+215/-0) qt/core/browser/oxide_data_fetcher_shared_memory.h (+54/-0) qt/core/browser/oxide_qt_accelerometer.cc (+91/-0) qt/core/browser/oxide_qt_accelerometer.h (+39/-0) qt/core/browser/oxide_qt_accelerometer_p.h (+53/-0) qt/core/browser/oxide_qt_browser_startup.cc (+6/-1) qt/core/core.gyp (+12/-0) |
||||
To merge this branch: | bzr merge lp:~abreu-alexandre/oxide/accelerometer-support | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Chris Coulson | Pending | ||
Review via email: mp+277483@code.launchpad.net |
Commit message
Description of the change
WIP
To post a comment you must log in.
Unmerged revisions
- 1276. By Alexandre Abreu
-
simple port to trunk
- 1275. By Alexandre Abreu
-
pull trunk
- 1274. By Alexandre Abreu
-
back to trunk
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'qt/build/system.gyp' |
2 | --- qt/build/system.gyp 2015-10-28 19:09:39 +0000 |
3 | +++ qt/build/system.gyp 2015-11-13 20:15:31 +0000 |
4 | @@ -91,6 +91,23 @@ |
5 | }, |
6 | }, |
7 | { |
8 | + 'target_name': 'Qt5Sensors', |
9 | + 'type': 'none', |
10 | + 'direct_dependent_settings': { |
11 | + 'cflags_cc': [ |
12 | + '<!@(<(pkg_config) --cflags Qt5Sensors)' |
13 | + ] |
14 | + }, |
15 | + 'link_settings': { |
16 | + 'ldflags': [ |
17 | + '<!@(<(pkg_config) --libs-only-L --libs-only-other Qt5Sensors)', |
18 | + ], |
19 | + 'libraries': [ |
20 | + '<!@(<(pkg_config) --libs-only-l Qt5Sensors)', |
21 | + ], |
22 | + }, |
23 | + }, |
24 | + { |
25 | 'target_name': 'Qt5Positioning', |
26 | 'type': 'none', |
27 | 'direct_dependent_settings': { |
28 | |
29 | === added file 'qt/core/browser/oxide_data_fetcher_shared_memory.cc' |
30 | --- qt/core/browser/oxide_data_fetcher_shared_memory.cc 1970-01-01 00:00:00 +0000 |
31 | +++ qt/core/browser/oxide_data_fetcher_shared_memory.cc 2015-11-13 20:15:31 +0000 |
32 | @@ -0,0 +1,215 @@ |
33 | +// vim:expandtab:shiftwidth=2:tabstop=2: |
34 | +// Copyright (C) 2015 Canonical Ltd. |
35 | + |
36 | +// This library is free software; you can redistribute it and/or |
37 | +// modify it under the terms of the GNU Lesser General Public |
38 | +// License as published by the Free Software Foundation; either |
39 | +// version 2.1 of the License, or (at your option) any later version. |
40 | + |
41 | +// This library is distributed in the hope that it will be useful, |
42 | +// but WITHOUT ANY WARRANTY; without even the implied warranty of |
43 | +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
44 | +// Lesser General Public License for more details. |
45 | + |
46 | +// You should have received a copy of the GNU Lesser General Public |
47 | +// License along with this library; if not, write to the Free Software |
48 | +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
49 | + |
50 | +#include "oxide_data_fetcher_shared_memory.h" |
51 | + |
52 | +#include "base/logging.h" |
53 | +#include "base/metrics/histogram.h" |
54 | + |
55 | +#include "qt/core/browser/oxide_qt_accelerometer.h" |
56 | + |
57 | +namespace { |
58 | + |
59 | +static bool SetMotionBuffer(content::DeviceMotionHardwareBuffer* buffer, |
60 | + bool enabled) { |
61 | + if (!buffer) |
62 | + return false; |
63 | + buffer->seqlock.WriteBegin(); |
64 | + buffer->data.allAvailableSensorsAreActive = enabled; |
65 | + buffer->seqlock.WriteEnd(); |
66 | + return true; |
67 | +} |
68 | + |
69 | +static bool SetOrientationBuffer( |
70 | + content::DeviceOrientationHardwareBuffer* buffer, bool enabled) { |
71 | + if (!buffer) |
72 | + return false; |
73 | + buffer->seqlock.WriteBegin(); |
74 | + buffer->data.allAvailableSensorsAreActive = enabled; |
75 | + buffer->seqlock.WriteEnd(); |
76 | + return true; |
77 | +} |
78 | + |
79 | +static bool SetLightBuffer(content::DeviceLightHardwareBuffer* buffer, |
80 | + double lux) { |
81 | + if (!buffer) |
82 | + return false; |
83 | + buffer->seqlock.WriteBegin(); |
84 | + buffer->data.value = lux; |
85 | + buffer->seqlock.WriteEnd(); |
86 | + return true; |
87 | +} |
88 | + |
89 | +} // namespace |
90 | + |
91 | +namespace oxide { |
92 | + |
93 | +OxideDataFetcherSharedMemory::OxideDataFetcherSharedMemory() |
94 | + : motion_buffer_(nullptr), |
95 | + orientation_buffer_(nullptr), |
96 | + light_buffer_(nullptr) { |
97 | +} |
98 | + |
99 | +OxideDataFetcherSharedMemory::~OxideDataFetcherSharedMemory() { |
100 | +} |
101 | + |
102 | +void FetchOrientation( |
103 | + oxide::qt::AccelerometerSensorReader *sensor, |
104 | + content::DeviceOrientationHardwareBuffer* buffer) { |
105 | + DCHECK(buffer); |
106 | + DCHECK(sensor); |
107 | + |
108 | + double axis_value[3]; |
109 | + if (!sensor->GetData(axis_value)) { |
110 | + return; |
111 | + } |
112 | + |
113 | + const double kRad2deg = 180.0 / M_PI; |
114 | + double beta = kRad2deg * atan2(-axis_value[1], axis_value[2]); |
115 | + double gamma = kRad2deg * asin(axis_value[0]); |
116 | + |
117 | + if (beta == 180.0) { |
118 | + beta = -180; |
119 | + } |
120 | + if (gamma == 90.0) { |
121 | + gamma = nextafter(90, 0); |
122 | + } |
123 | + |
124 | + DCHECK_GE(beta, -180.0); |
125 | + DCHECK_LT(beta, 180.0); |
126 | + DCHECK_GE(gamma, -90.0); |
127 | + DCHECK_LT(gamma, 90.0); |
128 | + |
129 | + buffer->seqlock.WriteBegin(); |
130 | + buffer->data.beta = beta; |
131 | + buffer->data.hasBeta = true; |
132 | + buffer->data.gamma = gamma; |
133 | + buffer->data.hasGamma = true; |
134 | + buffer->data.allAvailableSensorsAreActive = true; |
135 | + buffer->seqlock.WriteEnd(); |
136 | +} |
137 | + |
138 | +void FetchMotion( |
139 | + oxide::qt::AccelerometerSensorReader* sensor, |
140 | + content::DeviceMotionHardwareBuffer* buffer) { |
141 | + DCHECK(buffer); |
142 | + DCHECK(sensor); |
143 | + |
144 | + double axis_value[3]; |
145 | + if (!sensor->GetData(axis_value)) { |
146 | + return; |
147 | + } |
148 | + |
149 | + buffer->seqlock.WriteBegin(); |
150 | + buffer->data.accelerationIncludingGravityX = axis_value[0]; |
151 | + buffer->data.hasAccelerationIncludingGravityX = true; |
152 | + buffer->data.accelerationIncludingGravityY = axis_value[1]; |
153 | + buffer->data.hasAccelerationIncludingGravityY = true; |
154 | + buffer->data.accelerationIncludingGravityZ = axis_value[2]; |
155 | + buffer->data.hasAccelerationIncludingGravityZ = true; |
156 | + buffer->data.allAvailableSensorsAreActive = true; |
157 | + buffer->seqlock.WriteEnd(); |
158 | +} |
159 | + |
160 | +void OxideDataFetcherSharedMemory::Fetch(unsigned consumer_bitmask) { |
161 | + DCHECK(base::MessageLoop::current() == GetPollingMessageLoop()); |
162 | + DCHECK(consumer_bitmask & content::CONSUMER_TYPE_ORIENTATION || |
163 | + consumer_bitmask & content::CONSUMER_TYPE_MOTION || |
164 | + consumer_bitmask & content::CONSUMER_TYPE_LIGHT); |
165 | + |
166 | + if (consumer_bitmask & content::CONSUMER_TYPE_ORIENTATION) { |
167 | + FetchOrientation(orientation_sensor_.get(), orientation_buffer_); |
168 | + } |
169 | + if (consumer_bitmask & content::CONSUMER_TYPE_MOTION) { |
170 | + FetchMotion(motion_sensor_.get(), motion_buffer_); |
171 | + } |
172 | +} |
173 | + |
174 | +content::DataFetcherSharedMemoryBase::FetcherType |
175 | +OxideDataFetcherSharedMemory::GetType() const { |
176 | + return content::DataFetcherSharedMemoryBase::FETCHER_TYPE_POLLING_CALLBACK; |
177 | +} |
178 | + |
179 | +bool OxideDataFetcherSharedMemory::Start( |
180 | + content::ConsumerType consumer_type, |
181 | + void* buffer) { |
182 | + DCHECK(buffer); |
183 | + |
184 | + switch (consumer_type) { |
185 | + case content::CONSUMER_TYPE_MOTION: |
186 | + { |
187 | + if (!motion_sensor_.get()) { |
188 | + motion_sensor_.reset( |
189 | + new oxide::qt::AccelerometerSensorReader()); |
190 | + } |
191 | + |
192 | + motion_buffer_ = |
193 | + static_cast<content::DeviceMotionHardwareBuffer*>(buffer); |
194 | + |
195 | + UMA_HISTOGRAM_BOOLEAN("InertialSensor.MotionDefaultAvailable", false); |
196 | + |
197 | + return SetMotionBuffer(motion_buffer_, true); |
198 | + } |
199 | + case content::CONSUMER_TYPE_ORIENTATION: |
200 | + { |
201 | + if (!orientation_sensor_.get()) { |
202 | + orientation_sensor_.reset( |
203 | + new oxide::qt::AccelerometerSensorReader()); |
204 | + } |
205 | + |
206 | + orientation_buffer_ = |
207 | + static_cast<content::DeviceOrientationHardwareBuffer*>(buffer); |
208 | + |
209 | + UMA_HISTOGRAM_BOOLEAN("InertialSensor.OrientationDefaultAvailable", |
210 | + false); |
211 | + |
212 | + return SetOrientationBuffer(orientation_buffer_, true); |
213 | + } |
214 | + case content::CONSUMER_TYPE_LIGHT: |
215 | + { |
216 | + light_buffer_ = |
217 | + static_cast<content::DeviceLightHardwareBuffer*>(buffer); |
218 | + |
219 | + return SetLightBuffer( |
220 | + light_buffer_, |
221 | + std::numeric_limits<double>::infinity()); |
222 | + } |
223 | + default: |
224 | + NOTREACHED(); |
225 | + } |
226 | + return false; |
227 | +} |
228 | + |
229 | +bool OxideDataFetcherSharedMemory::Stop(content::ConsumerType consumer_type) { |
230 | + switch (consumer_type) { |
231 | + case content::CONSUMER_TYPE_MOTION: |
232 | + motion_sensor_.reset(nullptr); |
233 | + |
234 | + return SetMotionBuffer(motion_buffer_, false); |
235 | + case content::CONSUMER_TYPE_ORIENTATION: |
236 | + orientation_sensor_.reset(nullptr); |
237 | + |
238 | + return SetOrientationBuffer(orientation_buffer_, false); |
239 | + case content::CONSUMER_TYPE_LIGHT: |
240 | + return SetLightBuffer(light_buffer_, -1); |
241 | + default: |
242 | + NOTREACHED(); |
243 | + } |
244 | + return false; |
245 | +} |
246 | + |
247 | +} // namespace oxide |
248 | |
249 | === added file 'qt/core/browser/oxide_data_fetcher_shared_memory.h' |
250 | --- qt/core/browser/oxide_data_fetcher_shared_memory.h 1970-01-01 00:00:00 +0000 |
251 | +++ qt/core/browser/oxide_data_fetcher_shared_memory.h 2015-11-13 20:15:31 +0000 |
252 | @@ -0,0 +1,54 @@ |
253 | +// vim:expandtab:shiftwidth=2:tabstop=2: |
254 | +// Copyright (C) 2015 Canonical Ltd. |
255 | + |
256 | +// This library is free software; you can redistribute it and/or |
257 | +// modify it under the terms of the GNU Lesser General Public |
258 | +// License as published by the Free Software Foundation; either |
259 | +// version 2.1 of the License, or (at your option) any later version. |
260 | + |
261 | +// This library is distributed in the hope that it will be useful, |
262 | +// but WITHOUT ANY WARRANTY; without even the implied warranty of |
263 | +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
264 | +// Lesser General Public License for more details. |
265 | + |
266 | +// You should have received a copy of the GNU Lesser General Public |
267 | +// License along with this library; if not, write to the Free Software |
268 | +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
269 | + |
270 | +#ifndef _OXIDE_DEVICE_SENSORS_DATA_FETCHER_SHARED_MEMORY_H_ |
271 | +#define _OXIDE_DEVICE_SENSORS_DATA_FETCHER_SHARED_MEMORY_H_ |
272 | + |
273 | +#include "content/browser/device_sensors/data_fetcher_shared_memory.h" |
274 | + |
275 | +namespace oxide { |
276 | + |
277 | +namespace qt { |
278 | +class AccelerometerSensorReader; |
279 | +} |
280 | + |
281 | +class CONTENT_EXPORT OxideDataFetcherSharedMemory |
282 | + : public content::DataFetcherSharedMemory { |
283 | + |
284 | + public: |
285 | + OxideDataFetcherSharedMemory(); |
286 | + ~OxideDataFetcherSharedMemory() override; |
287 | + |
288 | + private: |
289 | + bool Start(content::ConsumerType consumer_type, void* buffer) override; |
290 | + bool Stop(content::ConsumerType consumer_type) override; |
291 | + |
292 | + void Fetch(unsigned consumer_bitmask) override; |
293 | + content::DataFetcherSharedMemoryBase::FetcherType GetType() const override; |
294 | + scoped_ptr<oxide::qt::AccelerometerSensorReader> motion_sensor_; |
295 | + scoped_ptr<oxide::qt::AccelerometerSensorReader> orientation_sensor_; |
296 | + |
297 | + content::DeviceMotionHardwareBuffer* motion_buffer_; |
298 | + content::DeviceOrientationHardwareBuffer* orientation_buffer_; |
299 | + content::DeviceLightHardwareBuffer* light_buffer_; |
300 | + |
301 | + DISALLOW_COPY_AND_ASSIGN(OxideDataFetcherSharedMemory); |
302 | +}; |
303 | + |
304 | +} |
305 | + |
306 | +#endif // _OXIDE_DEVICE_SENSORS_DATA_FETCHER_SHARED_MEMORY_H_ |
307 | |
308 | === added file 'qt/core/browser/oxide_qt_accelerometer.cc' |
309 | --- qt/core/browser/oxide_qt_accelerometer.cc 1970-01-01 00:00:00 +0000 |
310 | +++ qt/core/browser/oxide_qt_accelerometer.cc 2015-11-13 20:15:31 +0000 |
311 | @@ -0,0 +1,91 @@ |
312 | +// vim:expandtab:shiftwidth=2:tabstop=2: |
313 | +// Copyright (C) 2015 Canonical Ltd. |
314 | + |
315 | +// This library is free software; you can redistribute it and/or |
316 | +// modify it under the terms of the GNU Lesser General Public |
317 | +// License as published by the Free Software Foundation; either |
318 | +// version 2.1 of the License, or (at your option) any later version. |
319 | + |
320 | +// This library is distributed in the hope that it will be useful, |
321 | +// but WITHOUT ANY WARRANTY; without even the implied warranty of |
322 | +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
323 | +// Lesser General Public License for more details. |
324 | + |
325 | +// You should have received a copy of the GNU Lesser General Public |
326 | +// License along with this library; if not, write to the Free Software |
327 | +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
328 | + |
329 | +#include "oxide_qt_accelerometer.h" |
330 | +#include "oxide_qt_accelerometer_p.h" |
331 | + |
332 | + |
333 | +namespace oxide { |
334 | +namespace qt { |
335 | + |
336 | +AccelerometerSensorReader::AccelerometerSensorReader() |
337 | + : instance_(AccelerometerSensorReaderImpl::GetInstance()) { |
338 | +} |
339 | + |
340 | +bool AccelerometerSensorReader::GetData(double buf[3]) { |
341 | + return instance_->GetData(buf); |
342 | +} |
343 | + |
344 | +QWeakPointer<AccelerometerSensorReaderImpl> AccelerometerSensorReaderImpl::instance_; |
345 | + |
346 | +QSharedPointer<AccelerometerSensorReaderImpl> AccelerometerSensorReaderImpl::GetInstance() { |
347 | + QSharedPointer<AccelerometerSensorReaderImpl> instance = |
348 | + instance_.toStrongRef(); |
349 | + |
350 | + if (!instance.data()) { |
351 | + instance = |
352 | + QSharedPointer<AccelerometerSensorReaderImpl>( |
353 | + new AccelerometerSensorReaderImpl()); |
354 | + |
355 | + instance->accelerometer_.moveToThread(&instance->thread_); |
356 | + instance->connect( |
357 | + &instance->accelerometer_, |
358 | + SIGNAL(readingChanged()), |
359 | + SLOT(updateSensor()), |
360 | + Qt::DirectConnection); |
361 | + instance->thread_.start(); |
362 | + QMetaObject::invokeMethod(&instance->accelerometer_, "start", Qt::QueuedConnection); |
363 | + |
364 | + instance_ = instance; |
365 | + } |
366 | + return instance; |
367 | +} |
368 | + |
369 | +bool AccelerometerSensorReaderImpl::GetData(double buf[3]) { |
370 | + if (!initialized_) { |
371 | + return false; |
372 | + } |
373 | + |
374 | + mutex_.lock(); |
375 | + buf[0] = x_; |
376 | + buf[1] = y_; |
377 | + buf[2] = z_; |
378 | + mutex_.unlock(); |
379 | + |
380 | + return true; |
381 | +} |
382 | + |
383 | +void AccelerometerSensorReaderImpl::updateSensor() { |
384 | + QAccelerometerReading *accelerometer = accelerometer_.reading(); |
385 | + if (!accelerometer) { |
386 | + return; |
387 | + } |
388 | + |
389 | + mutex_.lock(); |
390 | + x_ = accelerometer->x(); |
391 | + y_ = accelerometer->y(); |
392 | + z_ = accelerometer->z(); |
393 | + initialized_ = true; |
394 | + mutex_.unlock(); |
395 | +} |
396 | + |
397 | +AccelerometerSensorReaderImpl::AccelerometerSensorReaderImpl() |
398 | + : initialized_(false) { |
399 | +} |
400 | + |
401 | +} // namespace qt |
402 | +} // namespace oxide |
403 | |
404 | === added file 'qt/core/browser/oxide_qt_accelerometer.h' |
405 | --- qt/core/browser/oxide_qt_accelerometer.h 1970-01-01 00:00:00 +0000 |
406 | +++ qt/core/browser/oxide_qt_accelerometer.h 2015-11-13 20:15:31 +0000 |
407 | @@ -0,0 +1,39 @@ |
408 | +// vim:expandtab:shiftwidth=2:tabstop=2: |
409 | +// Copyright (C) 2015 Canonical Ltd. |
410 | + |
411 | +// This library is free software; you can redistribute it and/or |
412 | +// modify it under the terms of the GNU Lesser General Public |
413 | +// License as published by the Free Software Foundation; either |
414 | +// version 2.1 of the License, or (at your option) any later version. |
415 | + |
416 | +// This library is distributed in the hope that it will be useful, |
417 | +// but WITHOUT ANY WARRANTY; without even the implied warranty of |
418 | +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
419 | +// Lesser General Public License for more details. |
420 | + |
421 | +// You should have received a copy of the GNU Lesser General Public |
422 | +// License along with this library; if not, write to the Free Software |
423 | +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
424 | + |
425 | +#ifndef _OXIDE_QT_CORE_BROWSER_ACCELEROMETER_H_ |
426 | +#define _OXIDE_QT_CORE_BROWSER_ACCELEROMETER_H_ |
427 | + |
428 | +#include <QtCore> |
429 | + |
430 | +namespace oxide { |
431 | +namespace qt { |
432 | + |
433 | +class AccelerometerSensorReaderImpl; |
434 | + |
435 | +class AccelerometerSensorReader { |
436 | +public: |
437 | + AccelerometerSensorReader(); |
438 | + bool GetData(double buf[3]); |
439 | +private: |
440 | + QSharedPointer<AccelerometerSensorReaderImpl> instance_; |
441 | +}; |
442 | + |
443 | +} // namespace qt |
444 | +} // namespace oxide |
445 | + |
446 | +#endif // _OXIDE_QT_CORE_BROWSER_ACCELEROMETER_H_ |
447 | |
448 | === added file 'qt/core/browser/oxide_qt_accelerometer_p.h' |
449 | --- qt/core/browser/oxide_qt_accelerometer_p.h 1970-01-01 00:00:00 +0000 |
450 | +++ qt/core/browser/oxide_qt_accelerometer_p.h 2015-11-13 20:15:31 +0000 |
451 | @@ -0,0 +1,53 @@ |
452 | +// vim:expandtab:shiftwidth=2:tabstop=2: |
453 | +// Copyright (C) 2015 Canonical Ltd. |
454 | + |
455 | +// This library is free software; you can redistribute it and/or |
456 | +// modify it under the terms of the GNU Lesser General Public |
457 | +// License as published by the Free Software Foundation; either |
458 | +// version 2.1 of the License, or (at your option) any later version. |
459 | + |
460 | +// This library is distributed in the hope that it will be useful, |
461 | +// but WITHOUT ANY WARRANTY; without even the implied warranty of |
462 | +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
463 | +// Lesser General Public License for more details. |
464 | + |
465 | +// You should have received a copy of the GNU Lesser General Public |
466 | +// License along with this library; if not, write to the Free Software |
467 | +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
468 | + |
469 | +#ifndef _OXIDE_QT_CORE_BROWSER_ACCELEROMETER_P_H_ |
470 | +#define _OXIDE_QT_CORE_BROWSER_ACCELEROMETER_P_H_ |
471 | + |
472 | +#include <QtCore> |
473 | +#include <QAccelerometer> |
474 | + |
475 | +namespace oxide { |
476 | +namespace qt { |
477 | + |
478 | +class AccelerometerSensorReaderImpl: public QObject { |
479 | + Q_OBJECT |
480 | +public: |
481 | + static QSharedPointer<AccelerometerSensorReaderImpl> GetInstance(); |
482 | + |
483 | + bool GetData(double buf[3]); |
484 | + |
485 | +protected Q_SLOTS: |
486 | + void updateSensor(); |
487 | + |
488 | +private: |
489 | + AccelerometerSensorReaderImpl(); |
490 | + |
491 | + double x_, y_, z_; |
492 | + bool initialized_; |
493 | + QAccelerometer accelerometer_; |
494 | + QThread thread_; |
495 | + QMutex mutex_; |
496 | + |
497 | + //TODO: to QWeakPointer |
498 | + static QWeakPointer<AccelerometerSensorReaderImpl> instance_; |
499 | +}; |
500 | + |
501 | +} // namespace qt |
502 | +} // namespace oxide |
503 | + |
504 | +#endif // _OXIDE_QT_CORE_BROWSER_ACCELEROMETER_P_H_ |
505 | |
506 | === modified file 'qt/core/browser/oxide_qt_browser_startup.cc' |
507 | --- qt/core/browser/oxide_qt_browser_startup.cc 2015-04-20 19:22:23 +0000 |
508 | +++ qt/core/browser/oxide_qt_browser_startup.cc 2015-11-13 20:15:31 +0000 |
509 | @@ -30,6 +30,8 @@ |
510 | #include "qt/core/app/oxide_qt_platform_delegate.h" |
511 | #include "qt/core/gpu/oxide_qt_gl_context_dependent.h" |
512 | |
513 | +#include "content/browser/device_sensors/device_inertial_sensor_service.h" |
514 | +#include "oxide_data_fetcher_shared_memory.h" |
515 | #include "oxide_qt_web_context.h" |
516 | |
517 | namespace oxide { |
518 | @@ -48,7 +50,10 @@ |
519 | |
520 | BrowserStartup::BrowserStartup() |
521 | : process_model_is_from_env_(false), |
522 | - process_model_(oxide::PROCESS_MODEL_UNDEFINED) {} |
523 | + process_model_(oxide::PROCESS_MODEL_UNDEFINED) { |
524 | + content::DeviceInertialSensorService::GetInstance()->SetDataFetcherForTesting( |
525 | + new OxideDataFetcherSharedMemory()); |
526 | +} |
527 | |
528 | // static |
529 | BrowserStartup* BrowserStartup::GetInstance() { |
530 | |
531 | === modified file 'qt/core/core.gyp' |
532 | --- qt/core/core.gyp 2015-10-28 19:09:39 +0000 |
533 | +++ qt/core/core.gyp 2015-11-13 20:15:31 +0000 |
534 | @@ -30,6 +30,7 @@ |
535 | '../build/system.gyp:Qt5Gui-private', |
536 | '../build/system.gyp:Qt5Positioning', |
537 | '../build/system.gyp:Qt5Network', |
538 | + '../build/system.gyp:Qt5Sensors', |
539 | '../../shared/shared.gyp:oxide_shared', |
540 | '<(DEPTH)/base/base.gyp:base', |
541 | '<(DEPTH)/content/content.gyp:content_browser', |
542 | @@ -60,6 +61,7 @@ |
543 | 'sources': [ |
544 | '<(INTERMEDIATE_DIR)/moc_oxide_qt_browser_platform_integration.cc', |
545 | '<(INTERMEDIATE_DIR)/moc_oxide_qt_input_method_context.cc', |
546 | + '<(INTERMEDIATE_DIR)/moc_oxide_qt_accelerometer_p.cc', |
547 | 'api/internal/oxideqmediacapturedevices_p.cc', |
548 | 'api/internal/oxideqwebpreferences_p.cc', |
549 | 'app/oxide_qt_main.cc', |
550 | @@ -69,6 +71,11 @@ |
551 | 'browser/input/oxide_qt_input_method_context.cc', |
552 | 'browser/input/oxide_qt_input_method_context.h', |
553 | 'browser/input/oxide_qt_input_method_context_client.h', |
554 | + 'browser/oxide_qt_accelerometer_p.h', |
555 | + 'browser/oxide_qt_accelerometer.h', |
556 | + 'browser/oxide_qt_accelerometer.cc', |
557 | + 'browser/oxide_data_fetcher_shared_memory.cc', |
558 | + 'browser/oxide_data_fetcher_shared_memory.h', |
559 | 'browser/oxide_qt_browser_platform_integration.cc', |
560 | 'browser/oxide_qt_browser_platform_integration.h', |
561 | 'browser/oxide_qt_browser_startup.cc', |
562 | @@ -151,6 +158,11 @@ |
563 | ], |
564 | 'actions': [ |
565 | { |
566 | + 'action_name': 'moc_oxide_qt_accelerometer_p.cc', |
567 | + 'moc_input': 'browser/oxide_qt_accelerometer_p.h', |
568 | + 'includes': [ 'moc.gypi' ] |
569 | + }, |
570 | + { |
571 | 'action_name': 'oxide_qt_clipboard.moc', |
572 | 'moc_input': 'browser/oxide_qt_clipboard.cc', |
573 | 'includes': [ 'moc.gypi' ] |