diff options
author | Sergio Ahumada <sergio.ahumada@digia.com> | 2013-03-19 11:05:55 +0100 |
---|---|---|
committer | Sergio Ahumada <sergio.ahumada@digia.com> | 2013-03-19 11:06:33 +0100 |
commit | 50c16eab20a6d9884ab3149ef59137a10de63e6d (patch) | |
tree | 2684617d911514147283516ddd15803a4049da61 /src/plugins/sensors/blackberry/bbmagnetometer.cpp | |
parent | d2cafb8506b798bad7fa56f19557dd6e1cb25cd7 (diff) | |
parent | 879e5536b033302b2ad976750cd2351674e161d6 (diff) |
Merge branch 'dev' into stable
This starts Qt 5.1 release cycle
Change-Id: Idce0f9b94f9e585abfb6903f554500a06f4f8aaa
Diffstat (limited to 'src/plugins/sensors/blackberry/bbmagnetometer.cpp')
-rw-r--r-- | src/plugins/sensors/blackberry/bbmagnetometer.cpp | 34 |
1 files changed, 24 insertions, 10 deletions
diff --git a/src/plugins/sensors/blackberry/bbmagnetometer.cpp b/src/plugins/sensors/blackberry/bbmagnetometer.cpp index 489a0481..45fd49b3 100644 --- a/src/plugins/sensors/blackberry/bbmagnetometer.cpp +++ b/src/plugins/sensors/blackberry/bbmagnetometer.cpp @@ -53,17 +53,11 @@ QString BbMagnetometer::devicePath() bool BbMagnetometer::updateReadingFromEvent(const sensor_event_t &event, QMagnetometerReading *reading) { - // TODO: In the future, support returnGeoValues here. Right now, /dev/sensors/mag has no - // geomagnatic mode, but will gain it in the future. - float x = convertValue(event.motion.dsp.x); - float y = convertValue(event.motion.dsp.y); - float z = convertValue(event.motion.dsp.z); - remapAxes(&x, &y, &z); - reading->setX(x); - reading->setY(y); - reading->setZ(z); + float x, y, z; - const bool returnGeoValues = sensor()->property("returnGeoValues").toBool(); + QMagnetometer * const magnetometer = qobject_cast<QMagnetometer *>(sensor()); + Q_ASSERT(magnetometer); + const bool returnGeoValues = magnetometer->returnGeoValues(); if (returnGeoValues) { switch (event.accuracy) { case SENSOR_ACCURACY_UNRELIABLE: reading->setCalibrationLevel(0.0f); break; @@ -76,10 +70,30 @@ bool BbMagnetometer::updateReadingFromEvent(const sensor_event_t &event, QMagnet case SENSOR_ACCURACY_MEDIUM: reading->setCalibrationLevel(1.0f); break; case SENSOR_ACCURACY_HIGH: reading->setCalibrationLevel(1.0f); break; } + + x = convertValue(event.motion.dsp.x); + y = convertValue(event.motion.dsp.y); + z = convertValue(event.motion.dsp.z); + } else { reading->setCalibrationLevel(1.0f); + +#ifndef Q_OS_BLACKBERRY_TABLET + x = convertValue(event.motion.raw.x); + y = convertValue(event.motion.raw.y); + z = convertValue(event.motion.raw.z); +#else + // Blackberry Tablet OS does not support raw reading values + x = convertValue(event.motion.dsp.x); + y = convertValue(event.motion.dsp.y); + z = convertValue(event.motion.dsp.z); +#endif } + remapAxes(&x, &y, &z); + reading->setX(x); + reading->setY(y); + reading->setZ(z); return true; } |