From a1637c935a0c7055cfc905c02d072af8e54fc948 Mon Sep 17 00:00:00 2001 From: Thomas McGuire Date: Wed, 8 Aug 2012 15:46:10 +0200 Subject: Blackberry: Use real compass sensor if available Change-Id: Iecae90f4c315668d7ac16923ccdfcacf6153d0e8 Reviewed-by: Adam Parco Reviewed-by: Lorn Potter --- src/plugins/sensors/blackberry/bbcompass.cpp | 12 ++++++++++++ src/plugins/sensors/blackberry/blackberry.pro | 3 +++ 2 files changed, 15 insertions(+) (limited to 'src') diff --git a/src/plugins/sensors/blackberry/bbcompass.cpp b/src/plugins/sensors/blackberry/bbcompass.cpp index 9ada2cd..02f9c9f 100644 --- a/src/plugins/sensors/blackberry/bbcompass.cpp +++ b/src/plugins/sensors/blackberry/bbcompass.cpp @@ -44,13 +44,20 @@ using namespace BbUtil; BbCompass::BbCompass(QSensor *sensor) +#ifdef HAVE_COMPASS_SENSOR + : BbSensorBackend(devicePath(), SENSOR_TYPE_COMPASS, sensor) +#else : BbSensorBackend(devicePath(), SENSOR_TYPE_ROTATION_MATRIX, sensor) +#endif { setDescription(QLatin1String("Azimuth in degrees from magnetic north")); } bool BbCompass::updateReadingFromEvent(const sensor_event_t &event, QCompassReading *reading) { +#ifdef HAVE_COMPASS_SENSOR + reading->setAzimuth(event.compass_s.azimuth); +#else float xRad, yRad, zRad; matrixToEulerZXY(event.rotation_matrix, xRad, yRad, zRad); float azimuth = radiansToDegrees(zRad); @@ -59,6 +66,7 @@ bool BbCompass::updateReadingFromEvent(const sensor_event_t &event, QCompassRead else azimuth = 360.0f - azimuth; reading->setAzimuth(azimuth); +#endif switch (event.accuracy) { case SENSOR_ACCURACY_UNRELIABLE: @@ -85,5 +93,9 @@ bool BbCompass::updateReadingFromEvent(const sensor_event_t &event, QCompassRead QString BbCompass::devicePath() { +#ifdef HAVE_COMPASS_SENSOR + return QLatin1String("/dev/sensor/compass"); +#else return QLatin1String("/dev/sensor/rotMatrix"); +#endif } diff --git a/src/plugins/sensors/blackberry/blackberry.pro b/src/plugins/sensors/blackberry/blackberry.pro index ef6dda6..9972e44 100644 --- a/src/plugins/sensors/blackberry/blackberry.pro +++ b/src/plugins/sensors/blackberry/blackberry.pro @@ -9,6 +9,9 @@ load(qt_plugin) config_bbsensor_header { DEFINES += HAVE_NDK_SENSOR_H } +config_bbsensor_compass { + DEFINES += HAVE_COMPASS_SENSOR +} DESTDIR = $$QT.sensors.plugins/sensors -- cgit v1.2.1