diff options
author | Thomas McGuire <thomas.mcguire.qnx@kdab.com> | 2013-01-10 13:38:43 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-01-23 18:33:17 +0100 |
commit | 78ad1fabee403ac910d29bb212cf0e3b9a670708 (patch) | |
tree | 9dbfdfdab19de9666eaf2923e79d2b9141cc4eaa /src/plugins/sensors/blackberry/bbcompass.cpp | |
parent | 5700ab09b06617d73b0495d2db0696512913ba51 (diff) |
Add a axes remapping feature
This allows orientable sensors like accelerometer or compass
to change to adapt the reading values based on the current
screen orientation.
Add support for the BlackBerry backend.
Change-Id: If7cfde8f20da4f677fdd13c38f7e11f2ed96bedd
Reviewed-by: Thomas McGuire <thomas.mcguire@kdab.com>
Diffstat (limited to 'src/plugins/sensors/blackberry/bbcompass.cpp')
-rw-r--r-- | src/plugins/sensors/blackberry/bbcompass.cpp | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/src/plugins/sensors/blackberry/bbcompass.cpp b/src/plugins/sensors/blackberry/bbcompass.cpp index 6e33d1a3..df8cc2e1 100644 --- a/src/plugins/sensors/blackberry/bbcompass.cpp +++ b/src/plugins/sensors/blackberry/bbcompass.cpp @@ -55,19 +55,28 @@ BbCompass::BbCompass(QSensor *sensor) bool BbCompass::updateReadingFromEvent(const sensor_event_t &event, QCompassReading *reading) { + float azimuth; #ifdef HAVE_COMPASS_SENSOR - reading->setAzimuth(event.compass_s.azimuth); + azimuth = event.compass_s.azimuth; #else float xRad, yRad, zRad; matrixToEulerZXY(event.rotation_matrix, xRad, yRad, zRad); - float azimuth = radiansToDegrees(zRad); + azimuth = radiansToDegrees(zRad); if (azimuth < 0) azimuth = -azimuth; else azimuth = 360.0f - azimuth; - reading->setAzimuth(azimuth); #endif + if (isAutoAxisRemappingEnabled()) { + azimuth += orientationForRemapping(); + if (azimuth >= 360.0f) + azimuth -= 360.0f; + } + + reading->setAzimuth(azimuth); + + switch (event.accuracy) { case SENSOR_ACCURACY_UNRELIABLE: reading->setCalibrationLevel(0.0f); |