From 8065e461421ea17a942ea09d67aaa053a136a54e Mon Sep 17 00:00:00 2001 From: Jake Petroules Date: Fri, 30 Sep 2016 18:33:12 -0700 Subject: Port the iOS sensors plugin to the other UIKit platforms MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit watchOS supports accelerometer, gyroscope, and magnetometer. tvOS supports only the proximity sensor. No sensors are available on macOS yet, but the plugin is still built there because many of the underlying APIs are available cross platform and so some macOS sensors can appear here in the future. Change-Id: I1668d81f09c745e60c1906be621a74f969841566 Reviewed-by: Mike Krus Reviewed-by: Tor Arne Vestbø --- src/plugins/sensors/ios/main.mm | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'src/plugins/sensors/ios/main.mm') diff --git a/src/plugins/sensors/ios/main.mm b/src/plugins/sensors/ios/main.mm index 40f84e9..a4766c3 100644 --- a/src/plugins/sensors/ios/main.mm +++ b/src/plugins/sensors/ios/main.mm @@ -48,6 +48,11 @@ #include "ioscompass.h" #include "iosproximitysensor.h" +#import +#ifdef HAVE_COREMOTION +#import +#endif + class IOSSensorPlugin : public QObject, public QSensorPluginInterface, public QSensorBackendFactory { Q_OBJECT @@ -56,30 +61,41 @@ class IOSSensorPlugin : public QObject, public QSensorPluginInterface, public QS public: void registerSensors() { +#ifdef HAVE_COREMOTION QSensorManager::registerBackend(QAccelerometer::type, IOSAccelerometer::id, this); if ([QIOSMotionManager sharedManager].gyroAvailable) QSensorManager::registerBackend(QGyroscope::type, IOSGyroscope::id, this); if ([QIOSMotionManager sharedManager].magnetometerAvailable) QSensorManager::registerBackend(QMagnetometer::type, IOSMagnetometer::id, this); +#endif +#ifdef HAVE_COMPASS if ([CLLocationManager headingAvailable]) QSensorManager::registerBackend(QCompass::type, IOSCompass::id, this); +#endif +#ifdef HAVE_UIDEVICE if (IOSProximitySensor::available()) QSensorManager::registerBackend(QProximitySensor::type, IOSProximitySensor::id, this); +#endif } QSensorBackend *createBackend(QSensor *sensor) { +#ifdef HAVE_COREMOTION if (sensor->identifier() == IOSAccelerometer::id) return new IOSAccelerometer(sensor); if (sensor->identifier() == IOSGyroscope::id) return new IOSGyroscope(sensor); if (sensor->identifier() == IOSMagnetometer::id) return new IOSMagnetometer(sensor); +#endif +#ifdef HAVE_COMPASS if (sensor->identifier() == IOSCompass::id) return new IOSCompass(sensor); +#endif +#ifdef HAVE_UIDEVICE if (sensor->identifier() == IOSProximitySensor::id) return new IOSProximitySensor(sensor); - +#endif return 0; } }; -- cgit v1.2.1