summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas McGuire <thomas.mcguire.qnx@kdab.com>2013-03-04 10:22:24 +0100
committerThomas McGuire <thomas.mcguire@kdab.com>2013-03-11 09:45:05 +0100
commita1cd792c51fbd53254423a1ead401394961a35d2 (patch)
treee6d97d684632f97e3a0164983f0dd0126d7bc97a
parent59a72f830b56a490e61e10336a69f7fc30505d3d (diff)
BlackBerry: Support QMagnetometer::returnGeoValues
This is a backport of QtSensors commit 4ef58f952f6fb87059cecddfe6447b14919be066 Change-Id: Ieb4779f36e1a20be52329020540cfeecd68057bc Reviewed-by: Bernd Weimer <bweimer@blackberry.com> Reviewed-by: Lorn Potter <lorn.potter@jollamobile.com>
-rw-r--r--plugins/sensors/blackberry/bbmagnetometer.cpp30
1 files changed, 21 insertions, 9 deletions
diff --git a/plugins/sensors/blackberry/bbmagnetometer.cpp b/plugins/sensors/blackberry/bbmagnetometer.cpp
index 7b84d6d483..b25dbb8607 100644
--- a/plugins/sensors/blackberry/bbmagnetometer.cpp
+++ b/plugins/sensors/blackberry/bbmagnetometer.cpp
@@ -53,15 +53,7 @@ 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;
QMagnetometer * const magnetometer = qobject_cast<QMagnetometer *>(sensor());
Q_ASSERT(magnetometer);
@@ -78,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;
}