summaryrefslogtreecommitdiffstats
path: root/src/plugins/sensors/ios/main.mm
diff options
context:
space:
mode:
authorJake Petroules <jake.petroules@qt.io>2016-09-30 18:33:12 -0700
committerJake Petroules <jake.petroules@qt.io>2016-10-05 23:17:53 +0000
commit8065e461421ea17a942ea09d67aaa053a136a54e (patch)
treec9ac30308a2e7686d584b7337ee41485f50b5363 /src/plugins/sensors/ios/main.mm
parentdf3374bd4bb8af1494f6a35b1102f15cfe9633e0 (diff)
Port the iOS sensors plugin to the other UIKit platformsv5.8.0-beta1
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 <mike.krus@kdab.com> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@theqtcompany.com>
Diffstat (limited to 'src/plugins/sensors/ios/main.mm')
-rw-r--r--src/plugins/sensors/ios/main.mm18
1 files changed, 17 insertions, 1 deletions
diff --git a/src/plugins/sensors/ios/main.mm b/src/plugins/sensors/ios/main.mm
index 40f84e9a..a4766c37 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 <CoreLocation/CoreLocation.h>
+#ifdef HAVE_COREMOTION
+#import <CoreMotion/CoreMotion.h>
+#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;
}
};