summaryrefslogtreecommitdiffstats
path: root/src/plugins/sensors/generic
diff options
context:
space:
mode:
authorPaul Olav Tvete <paul.tvete@digia.com>2013-03-04 14:09:10 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-03-05 16:34:19 +0100
commit96d4de7b36188cf8fe87b1d3f840bf9371744956 (patch)
tree9a6a9d71b90e6a56e89104510ecfa06107f68c08 /src/plugins/sensors/generic
parent61ce0635fca7c7d38d64e7c59bc99d9512d2d879 (diff)
Sensor implementation for Android
Based on the Necessitas project by Bogdan Vatra. Contributors to the Qt5 project: BogDan Vatra <bogdan@kde.org> Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@digia.com> Paul Olav Tvete <paul.tvete@digia.com> The full history of the Qt5 port can be found in refs/old-heads/android, SHA-1 caa4103a80ef90db5eb9836f6b6028b7ce36c73a Change-Id: I57e772ee5079c0ea74f685b65ae2864d73e7c750 Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@digia.com>
Diffstat (limited to 'src/plugins/sensors/generic')
-rw-r--r--src/plugins/sensors/generic/generic.pro12
-rw-r--r--src/plugins/sensors/generic/main.cpp34
2 files changed, 38 insertions, 8 deletions
diff --git a/src/plugins/sensors/generic/generic.pro b/src/plugins/sensors/generic/generic.pro
index 5bfeff64..fcc1bfcd 100644
--- a/src/plugins/sensors/generic/generic.pro
+++ b/src/plugins/sensors/generic/generic.pro
@@ -8,15 +8,23 @@ HEADERS += generictiltsensor.h
SOURCES += main.cpp\
generictiltsensor.cpp
+DEFINES += QTSENSORS_GENERICTILTSENSOR
!blackberry {
HEADERS += genericorientationsensor.h\
- genericrotationsensor.h\
genericalssensor.h
SOURCES += genericorientationsensor.cpp\
- genericrotationsensor.cpp\
genericalssensor.cpp
+ DEFINES += QTSENSORS_GENERICORIENTATIONSENSOR QTSENSORS_GENERICALSSENSOR
+}
+
+!blackberry:!android {
+ HEADERS += genericrotationsensor.h
+
+ SOURCES += genericrotationsensor.cpp
+
+ DEFINES += QTSENSORS_GENERICROTATIONSENSOR
}
OTHER_FILES = plugin.json
diff --git a/src/plugins/sensors/generic/main.cpp b/src/plugins/sensors/generic/main.cpp
index 4b348b19..aa9f58c2 100644
--- a/src/plugins/sensors/generic/main.cpp
+++ b/src/plugins/sensors/generic/main.cpp
@@ -39,12 +39,18 @@
**
****************************************************************************/
-#ifndef Q_OS_BLACKBERRY
+#ifdef QTSENSORS_GENERICORIENTATIONSENSOR
#include "genericorientationsensor.h"
+#endif
+#ifdef QTSENSORS_GENERICROTATIONSENSOR
#include "genericrotationsensor.h"
+#endif
+#ifdef QTSENSORS_GENERICALSSENSOR
#include "genericalssensor.h"
#endif
+#ifdef QTSENSORS_GENERICTILTSENSOR
#include "generictiltsensor.h"
+#endif
#include <qsensorplugin.h>
#include <qsensorbackend.h>
#include <qsensormanager.h>
@@ -66,44 +72,60 @@ public:
{
if (!QSensor::defaultSensorForType(QAccelerometer::type).isEmpty()) {
// There is an accelerometer available. Register the backends
-#ifndef Q_OS_BLACKBERRY
+#ifdef QTSENSORS_GENERICORIENTATIONSENSOR
if (!QSensorManager::isBackendRegistered(QOrientationSensor::type, genericorientationsensor::id))
QSensorManager::registerBackend(QOrientationSensor::type, genericorientationsensor::id, this);
+#endif
+#ifdef QTSENSORS_GENERICROTATIONSENSOR
if (!QSensorManager::isBackendRegistered(QRotationSensor::type, genericrotationsensor::id))
QSensorManager::registerBackend(QRotationSensor::type, genericrotationsensor::id, this);
+#endif
+#ifdef QTSENSORS_GENERICALSSENSOR
if (!QSensorManager::isBackendRegistered(QAmbientLightSensor::type, genericalssensor::id))
QSensorManager::registerBackend(QAmbientLightSensor::type, genericalssensor::id, this);
#endif
+#ifdef QTSENSORS_GENERICTILTSENSOR
if (!QSensorManager::isBackendRegistered(QTiltSensor::type, GenericTiltSensor::id))
QSensorManager::registerBackend(QTiltSensor::type, GenericTiltSensor::id, this);
+#endif
} else {
-#ifndef Q_OS_BLACKBERRY
+#ifdef QTSENSORS_GENERICORIENTATIONSENSOR
if (QSensorManager::isBackendRegistered(QOrientationSensor::type, genericorientationsensor::id))
QSensorManager::unregisterBackend(QOrientationSensor::type, genericorientationsensor::id);
+#endif
+#ifdef QTSENSORS_GENERICROTATIONSENSOR
if (QSensorManager::isBackendRegistered(QRotationSensor::type, genericrotationsensor::id))
QSensorManager::unregisterBackend(QRotationSensor::type, genericrotationsensor::id);
+#endif
+#ifdef QTSENSORS_GENERICALSSENSOR
if (QSensorManager::isBackendRegistered(QAmbientLightSensor::type, genericalssensor::id))
QSensorManager::unregisterBackend(QAmbientLightSensor::type, genericalssensor::id);
#endif
+#ifdef QTSENSORS_GENERICTILTSENSOR
if (QSensorManager::isBackendRegistered(QTiltSensor::type, GenericTiltSensor::id))
QSensorManager::unregisterBackend(QTiltSensor::type, GenericTiltSensor::id);
+#endif
}
}
QSensorBackend *createBackend(QSensor *sensor)
{
-#ifndef Q_OS_BLACKBERRY
+#ifdef QTSENSORS_GENERICORIENTATIONSENSOR
if (sensor->identifier() == genericorientationsensor::id)
return new genericorientationsensor(sensor);
-
+#endif
+#ifdef QTSENSORS_GENERICROTATIONSENSOR
if (sensor->identifier() == genericrotationsensor::id)
return new genericrotationsensor(sensor);
-
+#endif
+#ifdef QTSENSORS_GENERICALSSENSOR
if (sensor->identifier() == genericalssensor::id)
return new genericalssensor(sensor);
#endif
+#ifdef QTSENSORS_GENERICTILTSENSOR
if (sensor->identifier() == GenericTiltSensor::id)
return new GenericTiltSensor(sensor);
+#endif
return 0;
}