From 4383fa5df7a220670e0ae6567e56b8a5809d0704 Mon Sep 17 00:00:00 2001 From: Maurice Kalinowski Date: Thu, 7 Aug 2014 13:42:03 +0200 Subject: Add Windows Phone 8.1 supported sensors AmbientLight as well as Orientation sensors have been added to the Windows Phone 8.1 API. Furthermore accuracy for QCompass is now available on all WinRT related platforms. [ChangeLog][Windows Phone] Add support for QAmbientLightSensor and QOrientationSensor with Windows Phone 8.1 Task-number: QTBUG-39627 Change-Id: I6b2674c0d9935b874f35e6453f1e51d811133264 Reviewed-by: Andrew Knight --- src/plugins/sensors/winrt/main.cpp | 10 ++-------- src/plugins/sensors/winrt/winrt.pro | 13 ++++--------- src/plugins/sensors/winrt/winrtcompass.cpp | 3 +-- 3 files changed, 7 insertions(+), 19 deletions(-) diff --git a/src/plugins/sensors/winrt/main.cpp b/src/plugins/sensors/winrt/main.cpp index 13b87125..25251fd7 100644 --- a/src/plugins/sensors/winrt/main.cpp +++ b/src/plugins/sensors/winrt/main.cpp @@ -43,10 +43,8 @@ #include "winrtcompass.h" #include "winrtgyroscope.h" #include "winrtrotationsensor.h" -#ifndef Q_OS_WINPHONE -# include "winrtambientlightsensor.h" -# include "winrtorientationsensor.h" -#endif +#include "winrtambientlightsensor.h" +#include "winrtorientationsensor.h" #include #include #include @@ -69,10 +67,8 @@ public: QSensorManager::registerBackend(QCompass::type, QByteArrayLiteral("WinRtCompass"), this); QSensorManager::registerBackend(QGyroscope::type, QByteArrayLiteral("WinRtGyroscope"), this); QSensorManager::registerBackend(QRotationSensor::type, QByteArrayLiteral("WinRtRotationSensor"), this); -#ifndef Q_OS_WINPHONE QSensorManager::registerBackend(QAmbientLightSensor::type, QByteArrayLiteral("WinRtAmbientLightSensor"), this); QSensorManager::registerBackend(QOrientationSensor::type, QByteArrayLiteral("WinRtOrientationSensor"), this); -#endif } QSensorBackend *createBackend(QSensor *sensor) @@ -89,13 +85,11 @@ public: if (sensor->identifier() == QByteArrayLiteral("WinRtRotationSensor")) return new WinRtRotationSensor(sensor); -#ifndef Q_OS_WINPHONE if (sensor->identifier() == QByteArrayLiteral("WinRtAmbientLightSensor")) return new WinRtAmbientLightSensor(sensor); if (sensor->identifier() == QByteArrayLiteral("WinRtOrientationSensor")) return new WinRtOrientationSensor(sensor); -#endif // !Q_OS_WINPHONE return 0; } diff --git a/src/plugins/sensors/winrt/winrt.pro b/src/plugins/sensors/winrt/winrt.pro index e9f3274f..4a03bf2e 100644 --- a/src/plugins/sensors/winrt/winrt.pro +++ b/src/plugins/sensors/winrt/winrt.pro @@ -7,26 +7,21 @@ load(qt_plugin) HEADERS += \ winrtaccelerometer.h \ + winrtambientlightsensor.h \ winrtcommon.h \ winrtcompass.h \ + winrtorientationsensor.h \ winrtrotationsensor.h \ winrtgyroscope.h SOURCES += \ main.cpp \ winrtaccelerometer.cpp \ + winrtambientlightsensor.cpp \ winrtcommon.cpp \ winrtcompass.cpp \ + winrtorientationsensor.cpp \ winrtrotationsensor.cpp \ winrtgyroscope.cpp -!winphone { - HEADERS += \ - winrtambientlightsensor.h \ - winrtorientationsensor.h - SOURCES += \ - winrtambientlightsensor.cpp \ - winrtorientationsensor.cpp -} - OTHER_FILES = plugin.json diff --git a/src/plugins/sensors/winrt/winrtcompass.cpp b/src/plugins/sensors/winrt/winrtcompass.cpp index 6a678e2a..c2b72405 100644 --- a/src/plugins/sensors/winrt/winrtcompass.cpp +++ b/src/plugins/sensors/winrt/winrtcompass.cpp @@ -94,7 +94,6 @@ public: qCWarning(lcWinRtSensors) << "Failed to get compass reading timestamp." << qt_error_string(hr); return hr; } -#ifndef Q_OS_WINPHONE // Windows Phone doesn't implement the accuracy interface ComPtr accuracyReading; hr = value.As(&accuracyReading); if (FAILED(hr)) { @@ -124,7 +123,7 @@ public: reading.setCalibrationLevel(1.00); break; } -#endif + reading.setAzimuth(heading); reading.setTimestamp(dateTimeToMsSinceEpoch(dateTime)); q->newReadingAvailable(); -- cgit v1.2.3