summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.gitignore1
-rw-r--r--.qmake.conf2
-rw-r--r--config.tests/bbsensor_holster/bbsensor_holster.pro4
-rw-r--r--config.tests/bbsensor_holster/main.cpp57
-rw-r--r--doc/config/qt-cpp-ignore.qdocconf2
-rw-r--r--qtsensors.pro1
-rw-r--r--src/imports/sensors/plugins.qmltypes181
-rw-r--r--src/imports/sensors/qmlaccelerometer.cpp21
-rw-r--r--src/imports/sensors/qmlaccelerometer.h17
-rw-r--r--src/imports/sensors/qmlaltimeter.cpp133
-rw-r--r--src/imports/sensors/qmlaltimeter.h86
-rw-r--r--src/imports/sensors/qmlambientlightsensor.h2
-rw-r--r--src/imports/sensors/qmlambienttemperaturesensor.cpp133
-rw-r--r--src/imports/sensors/qmlambienttemperaturesensor.h86
-rw-r--r--src/imports/sensors/qmlcompass.h2
-rw-r--r--src/imports/sensors/qmlgyroscope.h2
-rw-r--r--src/imports/sensors/qmlholstersensor.cpp133
-rw-r--r--src/imports/sensors/qmlholstersensor.h86
-rw-r--r--src/imports/sensors/qmlirproximitysensor.h2
-rw-r--r--src/imports/sensors/qmllightsensor.cpp10
-rw-r--r--src/imports/sensors/qmllightsensor.h6
-rw-r--r--src/imports/sensors/qmlmagnetometer.cpp7
-rw-r--r--src/imports/sensors/qmlmagnetometer.h5
-rw-r--r--src/imports/sensors/qmlorientationsensor.h2
-rw-r--r--src/imports/sensors/qmlpressuresensor.cpp133
-rw-r--r--src/imports/sensors/qmlpressuresensor.h86
-rw-r--r--src/imports/sensors/qmlproximitysensor.h2
-rw-r--r--src/imports/sensors/qmlrotationsensor.cpp3
-rw-r--r--src/imports/sensors/qmlrotationsensor.h6
-rw-r--r--src/imports/sensors/qmlsensor.cpp120
-rw-r--r--src/imports/sensors/qmlsensor.h45
-rw-r--r--src/imports/sensors/qmlsensorglobal.h2
-rw-r--r--src/imports/sensors/qmlsensorrange.h2
-rw-r--r--src/imports/sensors/qmltapsensor.cpp8
-rw-r--r--src/imports/sensors/qmltapsensor.h5
-rw-r--r--src/imports/sensors/qmltiltsensor.h2
-rw-r--r--src/imports/sensors/sensors.cpp49
-rw-r--r--src/imports/sensors/sensors.pro10
-rw-r--r--src/plugins/sensors/android/android.pro2
-rw-r--r--src/plugins/sensors/android/jar/AndroidManifest.xml6
-rw-r--r--src/plugins/sensors/android/jar/jar.pro10
-rw-r--r--src/plugins/sensors/android/jar/src/org/qtproject/qt5/android/sensors/QtSensors.java161
-rw-r--r--src/plugins/sensors/android/src/androidaccelerometer.cpp63
-rw-r--r--src/plugins/sensors/android/src/androidaccelerometer.h59
-rw-r--r--src/plugins/sensors/android/src/androidcommonsensor.h88
-rw-r--r--src/plugins/sensors/android/src/androidgyroscope.cpp64
-rw-r--r--src/plugins/sensors/android/src/androidgyroscope.h57
-rw-r--r--src/plugins/sensors/android/src/androidjnisensors.cpp245
-rw-r--r--src/plugins/sensors/android/src/androidjnisensors.h83
-rw-r--r--src/plugins/sensors/android/src/androidlight.cpp62
-rw-r--r--src/plugins/sensors/android/src/androidlight.h57
-rw-r--r--src/plugins/sensors/android/src/androidmagnetometer.cpp63
-rw-r--r--src/plugins/sensors/android/src/androidmagnetometer.h57
-rw-r--r--src/plugins/sensors/android/src/androidrotation.cpp65
-rw-r--r--src/plugins/sensors/android/src/androidrotation.h56
-rw-r--r--src/plugins/sensors/android/src/main.cpp135
-rw-r--r--src/plugins/sensors/android/src/plugin.json1
-rw-r--r--src/plugins/sensors/android/src/src.pro29
-rw-r--r--src/plugins/sensors/blackberry/bbaccelerometer.cpp38
-rw-r--r--src/plugins/sensors/blackberry/bbaccelerometer.h4
-rw-r--r--src/plugins/sensors/blackberry/bbaltimeter.cpp27
-rw-r--r--src/plugins/sensors/blackberry/bbaltimeter.h17
-rw-r--r--src/plugins/sensors/blackberry/bbcompass.cpp15
-rw-r--r--src/plugins/sensors/blackberry/bbholstersensor.cpp58
-rw-r--r--src/plugins/sensors/blackberry/bbholstersensor.h60
-rw-r--r--src/plugins/sensors/blackberry/bbmagnetometer.cpp34
-rw-r--r--src/plugins/sensors/blackberry/bborientationsensor.cpp16
-rw-r--r--src/plugins/sensors/blackberry/bborientationsensor.h1
-rw-r--r--src/plugins/sensors/blackberry/bbpressuresensor.cpp29
-rw-r--r--src/plugins/sensors/blackberry/bbpressuresensor.h19
-rw-r--r--src/plugins/sensors/blackberry/bbproximitysensor.cpp3
-rw-r--r--src/plugins/sensors/blackberry/bbsensorbackend.cpp166
-rw-r--r--src/plugins/sensors/blackberry/bbsensorbackend.h5
-rw-r--r--src/plugins/sensors/blackberry/bbtemperaturesensor.cpp27
-rw-r--r--src/plugins/sensors/blackberry/bbtemperaturesensor.h17
-rw-r--r--src/plugins/sensors/blackberry/blackberry.pro9
-rw-r--r--src/plugins/sensors/blackberry/main.cpp20
-rw-r--r--src/plugins/sensors/dummy/dummy.pro2
-rw-r--r--src/plugins/sensors/generic/generic.pro30
-rw-r--r--src/plugins/sensors/generic/genericrotationsensor.cpp4
-rw-r--r--src/plugins/sensors/generic/genericrotationsensor.h1
-rw-r--r--src/plugins/sensors/generic/generictiltsensor.cpp47
-rw-r--r--src/plugins/sensors/generic/generictiltsensor.h4
-rw-r--r--src/plugins/sensors/generic/main.cpp44
-rw-r--r--src/plugins/sensors/ios/ios.pro17
-rw-r--r--src/plugins/sensors/ios/iosaccelerometer.h71
-rw-r--r--src/plugins/sensors/ios/iosaccelerometer.mm143
-rw-r--r--src/plugins/sensors/ios/iosmotionmanager.h55
-rw-r--r--src/plugins/sensors/ios/iosmotionmanager.mm57
-rw-r--r--src/plugins/sensors/ios/main.mm70
-rw-r--r--src/plugins/sensors/ios/plugin.json1
-rw-r--r--src/plugins/sensors/linux/linux.pro2
-rw-r--r--src/plugins/sensors/sensorfw/Sensors.conf11
-rw-r--r--src/plugins/sensors/sensorfw/main.cpp109
-rw-r--r--src/plugins/sensors/sensorfw/plugin.json1
-rw-r--r--src/plugins/sensors/sensorfw/sensorfw.pri26
-rw-r--r--src/plugins/sensors/sensorfw/sensorfw.pro17
-rw-r--r--src/plugins/sensors/sensorfw/sensorfwaccelerometer.cpp91
-rw-r--r--src/plugins/sensors/sensorfw/sensorfwaccelerometer.h74
-rw-r--r--src/plugins/sensors/sensorfw/sensorfwals.cpp111
-rw-r--r--src/plugins/sensors/sensorfw/sensorfwals.h75
-rw-r--r--src/plugins/sensors/sensorfw/sensorfwcompass.cpp80
-rw-r--r--src/plugins/sensors/sensorfw/sensorfwcompass.h70
-rw-r--r--src/plugins/sensors/sensorfw/sensorfwgyroscope.cpp90
-rw-r--r--src/plugins/sensors/sensorfw/sensorfwgyroscope.h78
-rw-r--r--src/plugins/sensors/sensorfw/sensorfwirproximitysensor.cpp81
-rw-r--r--src/plugins/sensors/sensorfw/sensorfwirproximitysensor.h71
-rw-r--r--src/plugins/sensors/sensorfw/sensorfwlightsensor.cpp71
-rw-r--r--src/plugins/sensors/sensorfw/sensorfwlightsensor.h72
-rw-r--r--src/plugins/sensors/sensorfw/sensorfwmagnetometer.cpp98
-rw-r--r--src/plugins/sensors/sensorfw/sensorfwmagnetometer.h79
-rw-r--r--src/plugins/sensors/sensorfw/sensorfworientationsensor.cpp98
-rw-r--r--src/plugins/sensors/sensorfw/sensorfworientationsensor.h74
-rw-r--r--src/plugins/sensors/sensorfw/sensorfwproximitysensor.cpp87
-rw-r--r--src/plugins/sensors/sensorfw/sensorfwproximitysensor.h75
-rw-r--r--src/plugins/sensors/sensorfw/sensorfwrotationsensor.cpp79
-rw-r--r--src/plugins/sensors/sensorfw/sensorfwrotationsensor.h75
-rw-r--r--src/plugins/sensors/sensorfw/sensorfwsensorbase.cpp189
-rw-r--r--src/plugins/sensors/sensorfw/sensorfwsensorbase.h170
-rw-r--r--src/plugins/sensors/sensorfw/sensorfwtapsensor.cpp110
-rw-r--r--src/plugins/sensors/sensorfw/sensorfwtapsensor.h73
-rw-r--r--src/plugins/sensors/sensors.pro16
-rw-r--r--src/sensors/doc/qtsensors.qdocconf37
-rw-r--r--src/sensors/doc/src/compatmap.qdoc89
-rw-r--r--src/sensors/doc/src/genericbackend.qdoc3
-rw-r--r--src/sensors/doc/src/porting.qdoc25
-rw-r--r--src/sensors/doc/src/qtsensors.qdoc3
-rw-r--r--src/sensors/doc/src/sensorfwbackend.qdoc39
-rw-r--r--src/sensors/gestures/qsensorgesture.h4
-rw-r--r--src/sensors/gestures/qsensorgesture_p.h2
-rw-r--r--src/sensors/gestures/qsensorgesturemanager.h4
-rw-r--r--src/sensors/gestures/qsensorgesturemanagerprivate_p.h2
-rw-r--r--src/sensors/gestures/qsensorgestureplugininterface.cpp2
-rw-r--r--src/sensors/gestures/qsensorgestureplugininterface.h4
-rw-r--r--src/sensors/gestures/qsensorgesturerecognizer.h4
-rwxr-xr-xsrc/sensors/make_sensor.pl184
-rw-r--r--src/sensors/qaccelerometer.cpp78
-rw-r--r--src/sensors/qaccelerometer.h24
-rw-r--r--src/sensors/qaccelerometer_p.h15
-rw-r--r--src/sensors/qaltimeter.cpp148
-rw-r--r--src/sensors/qaltimeter.h84
-rw-r--r--src/sensors/qaltimeter_p.h70
-rw-r--r--src/sensors/qambientlightsensor.h4
-rw-r--r--src/sensors/qambientlightsensor_p.h2
-rw-r--r--src/sensors/qambienttemperaturesensor.cpp144
-rw-r--r--src/sensors/qambienttemperaturesensor.h84
-rw-r--r--src/sensors/qambienttemperaturesensor_p.h70
-rw-r--r--src/sensors/qcompass.h4
-rw-r--r--src/sensors/qcompass_p.h2
-rw-r--r--src/sensors/qgyroscope.h4
-rw-r--r--src/sensors/qgyroscope_p.h2
-rw-r--r--src/sensors/qholstersensor.cpp148
-rw-r--r--src/sensors/qholstersensor.h84
-rw-r--r--src/sensors/qholstersensor_p.h70
-rw-r--r--src/sensors/qirproximitysensor.cpp6
-rw-r--r--src/sensors/qirproximitysensor.h4
-rw-r--r--src/sensors/qirproximitysensor_p.h2
-rw-r--r--src/sensors/qlightsensor.cpp30
-rw-r--r--src/sensors/qlightsensor.h17
-rw-r--r--src/sensors/qlightsensor_p.h13
-rw-r--r--src/sensors/qmagnetometer.cpp24
-rw-r--r--src/sensors/qmagnetometer.h17
-rw-r--r--src/sensors/qmagnetometer_p.h15
-rw-r--r--src/sensors/qorientationsensor.h4
-rw-r--r--src/sensors/qorientationsensor_p.h2
-rw-r--r--src/sensors/qpressuresensor.cpp147
-rw-r--r--src/sensors/qpressuresensor.h84
-rw-r--r--src/sensors/qpressuresensor_p.h70
-rw-r--r--src/sensors/qproximitysensor.h4
-rw-r--r--src/sensors/qproximitysensor_p.h2
-rw-r--r--src/sensors/qrotationsensor.cpp24
-rw-r--r--src/sensors/qrotationsensor.h17
-rw-r--r--src/sensors/qrotationsensor_p.h15
-rw-r--r--src/sensors/qsensor.cpp303
-rw-r--r--src/sensors/qsensor.h55
-rw-r--r--src/sensors/qsensor_p.h18
-rw-r--r--src/sensors/qsensorbackend.h4
-rw-r--r--src/sensors/qsensormanager.h4
-rw-r--r--src/sensors/qsensorplugin.h4
-rw-r--r--src/sensors/qsensorsglobal.h4
-rw-r--r--src/sensors/qtapsensor.cpp18
-rw-r--r--src/sensors/qtapsensor.h18
-rw-r--r--src/sensors/qtapsensor_p.h15
-rw-r--r--src/sensors/qtiltsensor.h4
-rw-r--r--src/sensors/qtiltsensor_p.h2
-rw-r--r--src/sensors/sensorlog_p.h2
-rw-r--r--src/sensors/sensors.pro9
-rw-r--r--tests/auto/qsensor/test_backends.h16
-rw-r--r--tests/auto/qsensor/tst_qsensor.cpp18
189 files changed, 8205 insertions, 506 deletions
diff --git a/.gitignore b/.gitignore
index 11a723e1..6bbb56a6 100644
--- a/.gitignore
+++ b/.gitignore
@@ -95,6 +95,7 @@ examples/sensors/shakeit/shakeit
# Generated config test binaries
config.tests/bbsensor_compass/bbsensor_compass
config.tests/bbsensor_header/bbsensor_header
+config.tests/bbsensor_holster/bbsensor_holster
# Directories to ignore
# ---------------------
diff --git a/.qmake.conf b/.qmake.conf
index 42ba8e45..f5a422c1 100644
--- a/.qmake.conf
+++ b/.qmake.conf
@@ -1 +1,3 @@
load(qt_build_config)
+
+MODULE_VERSION = 5.1.0
diff --git a/config.tests/bbsensor_holster/bbsensor_holster.pro b/config.tests/bbsensor_holster/bbsensor_holster.pro
new file mode 100644
index 00000000..349130a3
--- /dev/null
+++ b/config.tests/bbsensor_holster/bbsensor_holster.pro
@@ -0,0 +1,4 @@
+TEMPLATE = app
+SOURCES += main.cpp
+CONFIG += qt
+requires(blackberry)
diff --git a/config.tests/bbsensor_holster/main.cpp b/config.tests/bbsensor_holster/main.cpp
new file mode 100644
index 00000000..52dde466
--- /dev/null
+++ b/config.tests/bbsensor_holster/main.cpp
@@ -0,0 +1,57 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Research In Motion
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtSensors module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <QtCore/qglobal.h>
+#ifndef Q_OS_BLACKBERRY
+#error "Missing Q_OS_BLACKBERRY"
+#endif
+#include <sensor/sensor.h>
+
+int main(int argc, char** argv)
+{
+ Q_UNUSED(argc);
+ Q_UNUSED(argv);
+ sensor_event_t event;
+ const int type = SENSOR_TYPE_HOLSTER;
+ const bool holstered = event.holster_s.holstered;
+ Q_UNUSED(type);
+ Q_UNUSED(holstered);
+ return 0;
+}
diff --git a/doc/config/qt-cpp-ignore.qdocconf b/doc/config/qt-cpp-ignore.qdocconf
index 9b09a60a..28c21195 100644
--- a/doc/config/qt-cpp-ignore.qdocconf
+++ b/doc/config/qt-cpp-ignore.qdocconf
@@ -19,9 +19,7 @@ Cpp.ignoretokens = QAXFACTORY_EXPORT \
QM_EXPORT_XML \
QT_ASCII_CAST_WARN \
QT_ASCII_CAST_WARN_CONSTRUCTOR \
- QT_BEGIN_HEADER \
QT_DESIGNER_STATIC \
- QT_END_HEADER \
QT_FASTCALL \
QT_WIDGET_PLUGIN_EXPORT \
Q_COMPAT_EXPORT \
diff --git a/qtsensors.pro b/qtsensors.pro
index 0c706b21..77441730 100644
--- a/qtsensors.pro
+++ b/qtsensors.pro
@@ -2,6 +2,7 @@ load(configure)
blackberry {
qtCompileTest(bbsensor_header)
qtCompileTest(bbsensor_compass)
+ qtCompileTest(bbsensor_holster)
}
load(qt_parts)
diff --git a/src/imports/sensors/plugins.qmltypes b/src/imports/sensors/plugins.qmltypes
index 687a1f25..2deff792 100644
--- a/src/imports/sensors/plugins.qmltypes
+++ b/src/imports/sensors/plugins.qmltypes
@@ -3,90 +3,146 @@ import QtQuick.tooling 1.1
// This file describes the plugin-supplied types contained in the library.
// It is used for QML tooling purposes only.
//
-// This file was auto-generated with the command 'qmlplugindump QtSensors 5.0 /home/thomas/src/qtbase/imports/'.
+// This file was auto-generated with the command 'qmlplugindump QtSensors 5.0 /home/thomas/src/qtbase/qml'.
Module {
Component {
name: "QmlAccelerometer"
prototype: "QmlSensor"
- exports: ["Accelerometer 5.0"]
+ exports: ["Accelerometer 5.0", "Accelerometer 5.1"]
+ exportMetaObjectRevisions: [0, 1]
+ Enum {
+ name: "AccelerationMode"
+ values: {
+ "Combined": 0,
+ "Gravity": 1,
+ "User": 2
+ }
+ }
+ Property { name: "accelerationMode"; revision: 1; type: "AccelerationMode" }
+ Signal {
+ name: "accelerationModeChanged"
+ Parameter { name: "accelerationMode"; type: "AccelerationMode" }
+ }
}
Component {
name: "QmlAccelerometerReading"
prototype: "QmlSensorReading"
- exports: ["AccelerometerReading 5.0"]
+ exports: ["AccelerometerReading 5.0", "AccelerometerReading 5.1"]
Property { name: "x"; type: "double"; isReadonly: true }
Property { name: "y"; type: "double"; isReadonly: true }
Property { name: "z"; type: "double"; isReadonly: true }
}
Component {
+ name: "QmlAltimeter"
+ prototype: "QmlSensor"
+ exports: ["Altimeter 5.1"]
+ }
+ Component {
+ name: "QmlAltimeterReading"
+ prototype: "QmlSensorReading"
+ exports: ["AltimeterReading 5.1"]
+ Property { name: "altitude"; type: "double"; isReadonly: true }
+ }
+ Component {
name: "QmlAmbientLightSensor"
prototype: "QmlSensor"
- exports: ["AmbientLightSensor 5.0"]
+ exports: ["AmbientLightSensor 5.0", "AmbientLightSensor 5.1"]
}
Component {
name: "QmlAmbientLightSensorReading"
prototype: "QmlSensorReading"
- exports: ["AmbientLightReading 5.0"]
+ exports: ["AmbientLightReading 5.0", "AmbientLightReading 5.1"]
Property { name: "lightLevel"; type: "QAmbientLightReading::LightLevel"; isReadonly: true }
}
Component {
+ name: "QmlAmbientTemperatureReading"
+ prototype: "QmlSensorReading"
+ exports: ["AmbientTemperatureReading 5.1"]
+ Property { name: "temperature"; type: "double"; isReadonly: true }
+ }
+ Component {
+ name: "QmlAmbientTemperatureSensor"
+ prototype: "QmlSensor"
+ exports: ["AmbientTemperatureSensor 5.1"]
+ }
+ Component {
name: "QmlCompass"
prototype: "QmlSensor"
- exports: ["Compass 5.0"]
+ exports: ["Compass 5.0", "Compass 5.1"]
}
Component {
name: "QmlCompassReading"
prototype: "QmlSensorReading"
- exports: ["CompassReading 5.0"]
+ exports: ["CompassReading 5.0", "CompassReading 5.1"]
Property { name: "azimuth"; type: "double"; isReadonly: true }
Property { name: "calibrationLevel"; type: "double"; isReadonly: true }
}
Component {
name: "QmlGyroscope"
prototype: "QmlSensor"
- exports: ["Gyroscope 5.0"]
+ exports: ["Gyroscope 5.0", "Gyroscope 5.1"]
}
Component {
name: "QmlGyroscopeReading"
prototype: "QmlSensorReading"
- exports: ["GyroscopeReading 5.0"]
+ exports: ["GyroscopeReading 5.0", "GyroscopeReading 5.1"]
Property { name: "x"; type: "double"; isReadonly: true }
Property { name: "y"; type: "double"; isReadonly: true }
Property { name: "z"; type: "double"; isReadonly: true }
}
Component {
+ name: "QmlHolsterReading"
+ prototype: "QmlSensorReading"
+ exports: ["HolsterReading 5.1"]
+ Property { name: "holstered"; type: "bool"; isReadonly: true }
+ }
+ Component {
+ name: "QmlHolsterSensor"
+ prototype: "QmlSensor"
+ exports: ["HolsterSensor 5.1"]
+ }
+ Component {
name: "QmlIRProximitySensor"
prototype: "QmlSensor"
- exports: ["IRProximitySensor 5.0"]
+ exports: ["IRProximitySensor 5.0", "IRProximitySensor 5.1"]
}
Component {
name: "QmlIRProximitySensorReading"
prototype: "QmlSensorReading"
- exports: ["IRProximityReading 5.0"]
+ exports: ["IRProximityReading 5.0", "IRProximityReading 5.1"]
Property { name: "reflectance"; type: "double"; isReadonly: true }
}
Component {
name: "QmlLightSensor"
prototype: "QmlSensor"
- exports: ["LightSensor 5.0"]
+ exports: ["LightSensor 5.0", "LightSensor 5.1"]
Property { name: "fieldOfView"; type: "double"; isReadonly: true }
+ Signal {
+ name: "fieldOfViewChanged"
+ Parameter { name: "fieldOfView"; type: "double" }
+ }
}
Component {
name: "QmlLightSensorReading"
prototype: "QmlSensorReading"
- exports: ["LightReading 5.0"]
+ exports: ["LightReading 5.0", "LightReading 5.1"]
Property { name: "illuminance"; type: "double"; isReadonly: true }
}
Component {
name: "QmlMagnetometer"
prototype: "QmlSensor"
- exports: ["Magnetometer 5.0"]
+ exports: ["Magnetometer 5.0", "Magnetometer 5.1"]
+ Property { name: "returnGeoValues"; type: "bool" }
+ Signal {
+ name: "returnGeoValuesChanged"
+ Parameter { name: "returnGeoValues"; type: "bool" }
+ }
}
Component {
name: "QmlMagnetometerReading"
prototype: "QmlSensorReading"
- exports: ["MagnetometerReading 5.0"]
+ exports: ["MagnetometerReading 5.0", "MagnetometerReading 5.1"]
Property { name: "x"; type: "double"; isReadonly: true }
Property { name: "y"; type: "double"; isReadonly: true }
Property { name: "z"; type: "double"; isReadonly: true }
@@ -95,35 +151,50 @@ Module {
Component {
name: "QmlOrientationSensor"
prototype: "QmlSensor"
- exports: ["OrientationSensor 5.0"]
+ exports: ["OrientationSensor 5.0", "OrientationSensor 5.1"]
}
Component {
name: "QmlOrientationSensorReading"
prototype: "QmlSensorReading"
- exports: ["OrientationReading 5.0"]
+ exports: ["OrientationReading 5.0", "OrientationReading 5.1"]
Property { name: "orientation"; type: "QOrientationReading::Orientation"; isReadonly: true }
}
Component {
+ name: "QmlPressureReading"
+ prototype: "QmlSensorReading"
+ exports: ["PressureReading 5.1"]
+ Property { name: "pressure"; type: "double"; isReadonly: true }
+ }
+ Component {
+ name: "QmlPressureSensor"
+ prototype: "QmlSensor"
+ exports: ["PressureSensor 5.1"]
+ }
+ Component {
name: "QmlProximitySensor"
prototype: "QmlSensor"
- exports: ["ProximitySensor 5.0"]
+ exports: ["ProximitySensor 5.0", "ProximitySensor 5.1"]
}
Component {
name: "QmlProximitySensorReading"
prototype: "QmlSensorReading"
- exports: ["ProximityReading 5.0"]
+ exports: ["ProximityReading 5.0", "ProximityReading 5.1"]
Property { name: "near"; type: "bool"; isReadonly: true }
}
Component {
name: "QmlRotationSensor"
prototype: "QmlSensor"
- exports: ["RotationSensor 5.0"]
+ exports: ["RotationSensor 5.0", "RotationSensor 5.1"]
Property { name: "hasZ"; type: "bool"; isReadonly: true }
+ Signal {
+ name: "hasZChanged"
+ Parameter { name: "hasZ"; type: "bool" }
+ }
}
Component {
name: "QmlRotationSensorReading"
prototype: "QmlSensorReading"
- exports: ["RotationReading 5.0"]
+ exports: ["RotationReading 5.0", "RotationReading 5.1"]
Property { name: "x"; type: "double"; isReadonly: true }
Property { name: "y"; type: "double"; isReadonly: true }
Property { name: "z"; type: "double"; isReadonly: true }
@@ -131,7 +202,16 @@ Module {
Component {
name: "QmlSensor"
prototype: "QObject"
- exports: ["Sensor 5.0"]
+ exports: ["Sensor 5.0", "Sensor 5.1"]
+ exportMetaObjectRevisions: [0, 1]
+ Enum {
+ name: "AxesOrientationMode"
+ values: {
+ "FixedOrientation": 0,
+ "AutomaticOrientation": 1,
+ "UserOrientation": 2
+ }
+ }
Property { name: "identifier"; type: "string" }
Property { name: "type"; type: "string"; isReadonly: true }
Property { name: "connectedToBackend"; type: "bool"; isReadonly: true }
@@ -145,13 +225,48 @@ Module {
Property { name: "description"; type: "string"; isReadonly: true }
Property { name: "error"; type: "int"; isReadonly: true }
Property { name: "alwaysOn"; type: "bool" }
+ Property { name: "skipDuplicates"; revision: 1; type: "bool" }
+ Property { name: "axesOrientationMode"; revision: 1; type: "AxesOrientationMode" }
+ Property { name: "currentOrientation"; revision: 1; type: "int"; isReadonly: true }
+ Property { name: "userOrientation"; revision: 1; type: "int" }
+ Property { name: "maxBufferSize"; revision: 1; type: "int"; isReadonly: true }
+ Property { name: "efficientBufferSize"; revision: 1; type: "int"; isReadonly: true }
+ Property { name: "bufferSize"; revision: 1; type: "int" }
+ Signal {
+ name: "skipDuplicatesChanged"
+ Parameter { name: "skipDuplicates"; type: "bool" }
+ }
+ Signal {
+ name: "axesOrientationModeChanged"
+ Parameter { name: "axesOrientationMode"; type: "AxesOrientationMode" }
+ }
+ Signal {
+ name: "currentOrientationChanged"
+ Parameter { name: "currentOrientation"; type: "int" }
+ }
+ Signal {
+ name: "userOrientationChanged"
+ Parameter { name: "userOrientation"; type: "int" }
+ }
+ Signal {
+ name: "maxBufferSizeChanged"
+ Parameter { name: "maxBufferSize"; type: "int" }
+ }
+ Signal {
+ name: "efficientBufferSizeChanged"
+ Parameter { name: "efficientBufferSize"; type: "int" }
+ }
+ Signal {
+ name: "bufferSizeChanged"
+ Parameter { name: "bufferSize"; type: "int" }
+ }
Method { name: "start"; type: "bool" }
Method { name: "stop" }
}
Component {
name: "QmlSensorGesture"
prototype: "QObject"
- exports: ["SensorGesture 5.0"]
+ exports: ["SensorGesture 5.0", "SensorGesture 5.1"]
Property { name: "availableGestures"; type: "QStringList"; isReadonly: true }
Property { name: "gestures"; type: "QStringList" }
Property { name: "validGestures"; type: "QStringList"; isReadonly: true }
@@ -165,7 +280,7 @@ Module {
Component {
name: "QmlSensorGlobal"
prototype: "QObject"
- exports: ["QmlSensors 5.0"]
+ exports: ["QmlSensors 5.0", "QmlSensors 5.1"]
Signal { name: "availableSensorsChanged" }
Method { name: "sensorTypes"; type: "QStringList" }
Method {
@@ -182,7 +297,7 @@ Module {
Component {
name: "QmlSensorOutputRange"
prototype: "QObject"
- exports: ["OutputRange 5.0"]
+ exports: ["OutputRange 5.0", "OutputRange 5.1"]
Property { name: "minimum"; type: "double"; isReadonly: true }
Property { name: "maximum"; type: "double"; isReadonly: true }
Property { name: "accuracy"; type: "double"; isReadonly: true }
@@ -190,26 +305,30 @@ Module {
Component {
name: "QmlSensorRange"
prototype: "QObject"
- exports: ["Range 5.0"]
+ exports: ["Range 5.0", "Range 5.1"]
Property { name: "minimum"; type: "int"; isReadonly: true }
Property { name: "maximum"; type: "int"; isReadonly: true }
}
Component {
name: "QmlSensorReading"
prototype: "QObject"
- exports: ["SensorReading 5.0"]
+ exports: ["SensorReading 5.0", "SensorReading 5.1"]
Property { name: "timestamp"; type: "qulonglong"; isReadonly: true }
}
Component {
name: "QmlTapSensor"
prototype: "QmlSensor"
- exports: ["TapSensor 5.0"]
+ exports: ["TapSensor 5.0", "TapSensor 5.1"]
Property { name: "returnDoubleTapEvents"; type: "bool" }
+ Signal {
+ name: "returnDoubleTapEventsChanged"
+ Parameter { name: "returnDoubleTapEvents"; type: "bool" }
+ }
}
Component {
name: "QmlTapSensorReading"
prototype: "QmlSensorReading"
- exports: ["TapReading 5.0"]
+ exports: ["TapReading 5.0", "TapReading 5.1"]
Property { name: "tapDirection"; type: "QTapReading::TapDirection"; isReadonly: true }
Property { name: "doubleTap"; type: "bool"; isReadonly: true }
Signal { name: "isDoubleTapChanged" }
@@ -217,13 +336,13 @@ Module {
Component {
name: "QmlTiltSensor"
prototype: "QmlSensor"
- exports: ["TiltSensor 5.0"]
+ exports: ["TiltSensor 5.0", "TiltSensor 5.1"]
Method { name: "calibrate" }
}
Component {
name: "QmlTiltSensorReading"
prototype: "QmlSensorReading"
- exports: ["TiltReading 5.0"]
+ exports: ["TiltReading 5.0", "TiltReading 5.1"]
Property { name: "yRotation"; type: "double"; isReadonly: true }
Property { name: "xRotation"; type: "double"; isReadonly: true }
}
diff --git a/src/imports/sensors/qmlaccelerometer.cpp b/src/imports/sensors/qmlaccelerometer.cpp
index 390f8beb..6fc82eab 100644
--- a/src/imports/sensors/qmlaccelerometer.cpp
+++ b/src/imports/sensors/qmlaccelerometer.cpp
@@ -65,12 +65,33 @@ QmlAccelerometer::QmlAccelerometer(QObject *parent)
: QmlSensor(parent)
, m_sensor(new QAccelerometer(this))
{
+ connect(m_sensor, SIGNAL(accelerationModeChanged(AccelerationMode)),
+ this, SIGNAL(accelerationModeChanged(AccelerationMode)));
}
QmlAccelerometer::~QmlAccelerometer()
{
}
+/*!
+ \qmlproperty AccelerationMode Accelerometer::accelerationMode
+ \since QtSensors 5.1
+
+ This property holds the current acceleration mode.
+
+ Please see QAccelerometer::accelerationMode for information about this property.
+*/
+
+QmlAccelerometer::AccelerationMode QmlAccelerometer::accelerationMode() const
+{
+ return static_cast<QmlAccelerometer::AccelerationMode>(m_sensor->accelerationMode());
+}
+
+void QmlAccelerometer::setAccelerationMode(QmlAccelerometer::AccelerationMode accelerationMode)
+{
+ m_sensor->setAccelerationMode(static_cast<QAccelerometer::AccelerationMode>(accelerationMode));
+}
+
QmlSensorReading *QmlAccelerometer::createReading() const
{
return new QmlAccelerometerReading(m_sensor);
diff --git a/src/imports/sensors/qmlaccelerometer.h b/src/imports/sensors/qmlaccelerometer.h
index 95785ed4..7a9a4cd0 100644
--- a/src/imports/sensors/qmlaccelerometer.h
+++ b/src/imports/sensors/qmlaccelerometer.h
@@ -44,7 +44,6 @@
#include "qmlsensor.h"
-QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
class QAccelerometer;
@@ -52,10 +51,25 @@ class QAccelerometer;
class QmlAccelerometer : public QmlSensor
{
Q_OBJECT
+ Q_ENUMS(AccelerationMode)
+ Q_PROPERTY(AccelerationMode accelerationMode READ accelerationMode WRITE setAccelerationMode
+ NOTIFY accelerationModeChanged REVISION 1)
public:
explicit QmlAccelerometer(QObject *parent = 0);
~QmlAccelerometer();
+ // Keep this enum in sync with QAccelerometer::AccelerationMode
+ enum AccelerationMode {
+ Combined,
+ Gravity,
+ User
+ };
+
+ AccelerationMode accelerationMode() const;
+ void setAccelerationMode(AccelerationMode accelerationMode);
+
+signals:
+ void accelerationModeChanged(AccelerationMode accelerationMode);
private:
QSensor *sensor() const Q_DECL_OVERRIDE;
@@ -92,5 +106,4 @@ private:
};
QT_END_NAMESPACE
-QT_END_HEADER
#endif
diff --git a/src/imports/sensors/qmlaltimeter.cpp b/src/imports/sensors/qmlaltimeter.cpp
new file mode 100644
index 00000000..abe3f922
--- /dev/null
+++ b/src/imports/sensors/qmlaltimeter.cpp
@@ -0,0 +1,133 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Research In Motion
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtSensors module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include "qmlaltimeter.h"
+#include <QAltimeter>
+
+/*!
+ \qmltype Altimeter
+ \instantiates QmlAltimeter
+ \ingroup qml-sensors_type
+ \inqmlmodule QtSensors 5.0
+ \since QtSensors 5.1
+ \inherits Sensor
+ \brief The Altimeter element reports on altitude.
+
+ The Altimeter element reports on altitude.
+
+ This element wraps the QAltimeter class. Please see the documentation for
+ QAltimeter for details.
+
+ \sa AltimeterReading
+*/
+
+QmlAltimeter::QmlAltimeter(QObject *parent)
+ : QmlSensor(parent)
+ , m_sensor(new QAltimeter(this))
+{
+}
+
+QmlAltimeter::~QmlAltimeter()
+{
+}
+
+QmlSensorReading *QmlAltimeter::createReading() const
+{
+ return new QmlAltimeterReading(m_sensor);
+}
+
+QSensor *QmlAltimeter::sensor() const
+{
+ return m_sensor;
+}
+
+/*!
+ \qmltype AltimeterReading
+ \instantiates QmlAltimeterReading
+ \ingroup qml-sensors_reading
+ \inqmlmodule QtSensors 5.0
+ \since QtSensors 5.1
+ \inherits SensorReading
+ \brief The AltimeterReading element holds the most recent Altimeter reading.
+
+ The AltimeterReading element holds the most recent Altimeter reading.
+
+ This element wraps the QAltimeterReading class. Please see the documentation for
+ QAltimeterReading for details.
+
+ This element cannot be directly created.
+*/
+
+QmlAltimeterReading::QmlAltimeterReading(QAltimeter *sensor)
+ : QmlSensorReading(sensor)
+ , m_sensor(sensor)
+ , m_altitude(0)
+{
+}
+
+QmlAltimeterReading::~QmlAltimeterReading()
+{
+}
+
+/*!
+ \qmlproperty qreal AltimeterReading::altitude
+ This property holds the altitude of the device.
+
+ Please see QAltimeterReading::altitude for information about this property.
+*/
+
+qreal QmlAltimeterReading::altitude() const
+{
+ return m_altitude;
+}
+
+QSensorReading *QmlAltimeterReading::reading() const
+{
+ return m_sensor->reading();
+}
+
+void QmlAltimeterReading::readingUpdate()
+{
+ qreal altitude = m_sensor->reading()->altitude();
+ if (m_altitude != altitude) {
+ m_altitude = altitude;
+ Q_EMIT altitudeChanged();
+ }
+}
diff --git a/src/imports/sensors/qmlaltimeter.h b/src/imports/sensors/qmlaltimeter.h
new file mode 100644
index 00000000..4568baaa
--- /dev/null
+++ b/src/imports/sensors/qmlaltimeter.h
@@ -0,0 +1,86 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Research In Motion
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtSensors module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#ifndef QMLALTIMETER_H
+#define QMLALTIMETER_H
+
+#include "qmlsensor.h"
+
+QT_BEGIN_NAMESPACE
+
+class QAltimeter;
+
+class QmlAltimeter : public QmlSensor
+{
+ Q_OBJECT
+public:
+ explicit QmlAltimeter(QObject *parent = 0);
+ ~QmlAltimeter();
+
+private:
+ QSensor *sensor() const Q_DECL_OVERRIDE;
+ QmlSensorReading *createReading() const Q_DECL_OVERRIDE;
+
+ QAltimeter *m_sensor;
+};
+
+class QmlAltimeterReading : public QmlSensorReading
+{
+ Q_OBJECT
+ Q_PROPERTY(qreal altitude READ altitude NOTIFY altitudeChanged)
+public:
+ explicit QmlAltimeterReading(QAltimeter *sensor);
+ ~QmlAltimeterReading();
+
+ qreal altitude() const;
+
+Q_SIGNALS:
+ void altitudeChanged();
+
+private:
+ QSensorReading *reading() const Q_DECL_OVERRIDE;
+ void readingUpdate() Q_DECL_OVERRIDE;
+
+ QAltimeter *m_sensor;
+ qreal m_altitude;
+};
+
+QT_END_NAMESPACE
+#endif
diff --git a/src/imports/sensors/qmlambientlightsensor.h b/src/imports/sensors/qmlambientlightsensor.h
index eecb6b12..7715a39f 100644
--- a/src/imports/sensors/qmlambientlightsensor.h
+++ b/src/imports/sensors/qmlambientlightsensor.h
@@ -45,7 +45,6 @@
#include "qmlsensor.h"
#include <QAmbientLightSensor>
-QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
class QAmbientLightSensor;
@@ -86,5 +85,4 @@ private:
};
QT_END_NAMESPACE
-QT_END_HEADER
#endif
diff --git a/src/imports/sensors/qmlambienttemperaturesensor.cpp b/src/imports/sensors/qmlambienttemperaturesensor.cpp
new file mode 100644
index 00000000..1190fca6
--- /dev/null
+++ b/src/imports/sensors/qmlambienttemperaturesensor.cpp
@@ -0,0 +1,133 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Research In Motion
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtSensors module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include "qmlambienttemperaturesensor.h"
+#include <QAmbientTemperatureSensor>
+
+/*!
+ \qmltype AmbientTemperatureSensor
+ \instantiates QmlAmbientTemperatureSensor
+ \ingroup qml-sensors_type
+ \inqmlmodule QtSensors 5.0
+ \since QtSensors 5.1
+ \inherits Sensor
+ \brief The AmbientTemperatureSensor element reports on the ambient temperature.
+
+ The AmbientTemperatureSensor element reports on the ambient temperature.
+
+ This element wraps the QAmbientTemperatureSensor class. Please see the documentation for
+ QAmbientTemperatureSensor for details.
+
+ \sa AmbientTemperatureReading
+*/
+
+QmlAmbientTemperatureSensor::QmlAmbientTemperatureSensor(QObject *parent)
+ : QmlSensor(parent)
+ , m_sensor(new QAmbientTemperatureSensor(this))
+{
+}
+
+QmlAmbientTemperatureSensor::~QmlAmbientTemperatureSensor()
+{
+}
+
+QmlSensorReading *QmlAmbientTemperatureSensor::createReading() const
+{
+ return new QmlAmbientTemperatureReading(m_sensor);
+}
+
+QSensor *QmlAmbientTemperatureSensor::sensor() const
+{
+ return m_sensor;
+}
+
+/*!
+ \qmltype AmbientTemperatureReading
+ \instantiates QmlAmbientTemperatureReading
+ \ingroup qml-sensors_reading
+ \inqmlmodule QtSensors 5.0
+ \since QtSensors 5.1
+ \inherits SensorReading
+ \brief The AmbientTemperatureReading element holds the most recent temperature reading.
+
+ The AmbientTemperatureReading element holds the most recent temperature reading.
+
+ This element wraps the QAmbientTemperatureReading class. Please see the documentation for
+ QAmbientTemperatureReading for details.
+
+ This element cannot be directly created.
+*/
+
+QmlAmbientTemperatureReading::QmlAmbientTemperatureReading(QAmbientTemperatureSensor *sensor)
+ : QmlSensorReading(sensor)
+ , m_sensor(sensor)
+ , m_temperature(0)
+{
+}
+
+QmlAmbientTemperatureReading::~QmlAmbientTemperatureReading()
+{
+}
+
+/*!
+ \qmlproperty qreal AmbientTemperatureReading::temperature
+ This property holds the ambient temperature in degree Celsius.
+
+ Please see QAmbientTemperatureReading::temperature for information about this property.
+*/
+
+qreal QmlAmbientTemperatureReading::temperature() const
+{
+ return m_temperature;
+}
+
+QSensorReading *QmlAmbientTemperatureReading::reading() const
+{
+ return m_sensor->reading();
+}
+
+void QmlAmbientTemperatureReading::readingUpdate()
+{
+ const qreal temperature = m_sensor->reading()->temperature();
+ if (m_temperature != temperature) {
+ m_temperature = temperature;
+ Q_EMIT temperatureChanged();
+ }
+}
diff --git a/src/imports/sensors/qmlambienttemperaturesensor.h b/src/imports/sensors/qmlambienttemperaturesensor.h
new file mode 100644
index 00000000..1c1d8dd6
--- /dev/null
+++ b/src/imports/sensors/qmlambienttemperaturesensor.h
@@ -0,0 +1,86 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Research In Motion
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtSensors module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#ifndef QMLAMBIENTTEMPERATURESENSOR_H
+#define QMLAMBIENTTEMPERATURESENSOR_H
+
+#include "qmlsensor.h"
+
+QT_BEGIN_NAMESPACE
+
+class QAmbientTemperatureSensor;
+
+class QmlAmbientTemperatureSensor : public QmlSensor
+{
+ Q_OBJECT
+public:
+ explicit QmlAmbientTemperatureSensor(QObject *parent = 0);
+ ~QmlAmbientTemperatureSensor();
+
+private:
+ QSensor *sensor() const Q_DECL_OVERRIDE;
+ QmlSensorReading *createReading() const Q_DECL_OVERRIDE;
+
+ QAmbientTemperatureSensor *m_sensor;
+};
+
+class QmlAmbientTemperatureReading : public QmlSensorReading
+{
+ Q_OBJECT
+ Q_PROPERTY(qreal temperature READ temperature NOTIFY temperatureChanged)
+public:
+ explicit QmlAmbientTemperatureReading(QAmbientTemperatureSensor *sensor);
+ ~QmlAmbientTemperatureReading();
+
+ qreal temperature() const;
+
+Q_SIGNALS:
+ void temperatureChanged();
+
+private:
+ QSensorReading *reading() const Q_DECL_OVERRIDE;
+ void readingUpdate() Q_DECL_OVERRIDE;
+
+ QAmbientTemperatureSensor *m_sensor;
+ qreal m_temperature;
+};
+
+QT_END_NAMESPACE
+#endif
diff --git a/src/imports/sensors/qmlcompass.h b/src/imports/sensors/qmlcompass.h
index 30edbf0a..76294bf9 100644
--- a/src/imports/sensors/qmlcompass.h
+++ b/src/imports/sensors/qmlcompass.h
@@ -44,7 +44,6 @@
#include "qmlsensor.h"
-QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
class QCompass;
@@ -88,5 +87,4 @@ private:
};
QT_END_NAMESPACE
-QT_END_HEADER
#endif
diff --git a/src/imports/sensors/qmlgyroscope.h b/src/imports/sensors/qmlgyroscope.h
index c5f6c902..f6fb6795 100644
--- a/src/imports/sensors/qmlgyroscope.h
+++ b/src/imports/sensors/qmlgyroscope.h
@@ -44,7 +44,6 @@
#include "qmlsensor.h"
-QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
class QGyroscope;
@@ -92,5 +91,4 @@ private:
};
QT_END_NAMESPACE
-QT_END_HEADER
#endif
diff --git a/src/imports/sensors/qmlholstersensor.cpp b/src/imports/sensors/qmlholstersensor.cpp
new file mode 100644
index 00000000..a1eae05b
--- /dev/null
+++ b/src/imports/sensors/qmlholstersensor.cpp
@@ -0,0 +1,133 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Research In Motion
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtSensors module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include "qmlholstersensor.h"
+#include <QHolsterSensor>
+
+/*!
+ \qmltype HolsterSensor
+ \instantiates QmlHolsterSensor
+ \ingroup qml-sensors_type
+ \inqmlmodule QtSensors 5.0
+ \since QtSensors 5.1
+ \inherits Sensor
+ \brief The HolsterSensor element reports on whether a device is holstered.
+
+ The HolsterSensor element reports on whether a device is holstered.
+
+ This element wraps the QHolsterSensor class. Please see the documentation for
+ QHolsterSensor for details.
+
+ \sa HolsterReading
+*/
+
+QmlHolsterSensor::QmlHolsterSensor(QObject *parent)
+ : QmlSensor(parent)
+ , m_sensor(new QHolsterSensor(this))
+{
+}
+
+QmlHolsterSensor::~QmlHolsterSensor()
+{
+}
+
+QmlSensorReading *QmlHolsterSensor::createReading() const
+{
+ return new QmlHolsterReading(m_sensor);
+}
+
+QSensor *QmlHolsterSensor::sensor() const
+{
+ return m_sensor;
+}
+
+/*!
+ \qmltype HolsterReading
+ \instantiates QmlHolsterReading
+ \ingroup qml-sensors_reading
+ \inqmlmodule QtSensors 5.0
+ \since QtSensors 5.1
+ \inherits SensorReading
+ \brief The HolsterReading element holds the most recent HolsterSensor reading.
+
+ The HolsterReading element holds the most recent HolsterSensor reading.
+
+ This element wraps the QHolsterReading class. Please see the documentation for
+ QHolsterReading for details.
+
+ This element cannot be directly created.
+*/
+
+QmlHolsterReading::QmlHolsterReading(QHolsterSensor *sensor)
+ : QmlSensorReading(sensor)
+ , m_sensor(sensor)
+ , m_holstered(false)
+{
+}
+
+QmlHolsterReading::~QmlHolsterReading()
+{
+}
+
+/*!
+ \qmlproperty qreal HolsterReading::holstered
+ This property holds whether the device is holstered.
+
+ Please see QHolsterReading::holstered for information about this property.
+*/
+
+bool QmlHolsterReading::holstered() const
+{
+ return m_holstered;
+}
+
+QSensorReading *QmlHolsterReading::reading() const
+{
+ return m_sensor->reading();
+}
+
+void QmlHolsterReading::readingUpdate()
+{
+ qreal holstered = m_sensor->reading()->holstered();
+ if (m_holstered != holstered) {
+ m_holstered = holstered;
+ Q_EMIT holsteredChanged();
+ }
+}
diff --git a/src/imports/sensors/qmlholstersensor.h b/src/imports/sensors/qmlholstersensor.h
new file mode 100644
index 00000000..262ba69d
--- /dev/null
+++ b/src/imports/sensors/qmlholstersensor.h
@@ -0,0 +1,86 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Research In Motion
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtSensors module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#ifndef QMLHOLSTERSENSOR_H
+#define QMLHOLSTERSENSOR_H
+
+#include "qmlsensor.h"
+
+QT_BEGIN_NAMESPACE
+
+class QHolsterSensor;
+
+class QmlHolsterSensor : public QmlSensor
+{
+ Q_OBJECT
+public:
+ explicit QmlHolsterSensor(QObject *parent = 0);
+ ~QmlHolsterSensor();
+
+private:
+ QSensor *sensor() const Q_DECL_OVERRIDE;
+ QmlSensorReading *createReading() const Q_DECL_OVERRIDE;
+
+ QHolsterSensor *m_sensor;
+};
+
+class QmlHolsterReading : public QmlSensorReading
+{
+ Q_OBJECT
+ Q_PROPERTY(bool holstered READ holstered NOTIFY holsteredChanged)
+public:
+ explicit QmlHolsterReading(QHolsterSensor *sensor);
+ ~QmlHolsterReading();
+
+ bool holstered() const;
+
+Q_SIGNALS:
+ void holsteredChanged();
+
+private:
+ QSensorReading *reading() const Q_DECL_OVERRIDE;
+ void readingUpdate() Q_DECL_OVERRIDE;
+
+ QHolsterSensor *m_sensor;
+ bool m_holstered;
+};
+
+QT_END_NAMESPACE
+#endif
diff --git a/src/imports/sensors/qmlirproximitysensor.h b/src/imports/sensors/qmlirproximitysensor.h
index 2b2d4c49..ec39fe8b 100644
--- a/src/imports/sensors/qmlirproximitysensor.h
+++ b/src/imports/sensors/qmlirproximitysensor.h
@@ -44,7 +44,6 @@
#include "qmlsensor.h"
-QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
class QIRProximitySensor;
@@ -83,5 +82,4 @@ private:
};
QT_END_NAMESPACE
-QT_END_HEADER
#endif
diff --git a/src/imports/sensors/qmllightsensor.cpp b/src/imports/sensors/qmllightsensor.cpp
index 1c3fed2c..86126a2a 100644
--- a/src/imports/sensors/qmllightsensor.cpp
+++ b/src/imports/sensors/qmllightsensor.cpp
@@ -63,6 +63,8 @@ QmlLightSensor::QmlLightSensor(QObject *parent)
: QmlSensor(parent)
, m_sensor(new QLightSensor(this))
{
+ connect(m_sensor, SIGNAL(fieldOfViewChanged(qreal)),
+ this, SIGNAL(fieldOfViewChanged(qreal)));
}
QmlLightSensor::~QmlLightSensor()
@@ -88,13 +90,7 @@ QSensor *QmlLightSensor::sensor() const
qreal QmlLightSensor::fieldOfView() const
{
- return m_sensor->property("fieldOfView").value<qreal>();
-}
-
-void QmlLightSensor::_update()
-{
- if (fieldOfView() != qreal())
- Q_EMIT fieldOfViewChanged();
+ return m_sensor->fieldOfView();
}
/*!
diff --git a/src/imports/sensors/qmllightsensor.h b/src/imports/sensors/qmllightsensor.h
index 90fe0b7f..e42d7818 100644
--- a/src/imports/sensors/qmllightsensor.h
+++ b/src/imports/sensors/qmllightsensor.h
@@ -44,7 +44,6 @@
#include "qmlsensor.h"
-QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
class QLightSensor;
@@ -59,13 +58,11 @@ public:
qreal fieldOfView() const;
-
Q_SIGNALS:
- void fieldOfViewChanged();
+ void fieldOfViewChanged(qreal fieldOfView);
private:
QSensor *sensor() const Q_DECL_OVERRIDE;
- void _update();
QLightSensor *m_sensor;
QmlSensorReading *createReading() const Q_DECL_OVERRIDE;
};
@@ -91,5 +88,4 @@ private:
};
QT_END_NAMESPACE
-QT_END_HEADER
#endif
diff --git a/src/imports/sensors/qmlmagnetometer.cpp b/src/imports/sensors/qmlmagnetometer.cpp
index 1f95b3f2..2c531f70 100644
--- a/src/imports/sensors/qmlmagnetometer.cpp
+++ b/src/imports/sensors/qmlmagnetometer.cpp
@@ -65,6 +65,8 @@ QmlMagnetometer::QmlMagnetometer(QObject *parent)
: QmlSensor(parent)
, m_sensor(new QMagnetometer(this))
{
+ connect(m_sensor, SIGNAL(returnGeoValuesChanged(bool)),
+ this, SIGNAL(returnGeoValuesChanged(bool)));
}
QmlMagnetometer::~QmlMagnetometer()
@@ -90,13 +92,12 @@ QSensor *QmlMagnetometer::sensor() const
bool QmlMagnetometer::returnGeoValues() const
{
- return m_sensor->property("returnGeoValues").toBool();
+ return m_sensor->returnGeoValues();
}
void QmlMagnetometer::setReturnGeoValues(bool geo)
{
- if (m_sensor->property("returnGeoValues").toBool() == geo) return;
- m_sensor->setProperty("returnGeoValues", geo);
+ m_sensor->setReturnGeoValues(geo);
}
/*!
diff --git a/src/imports/sensors/qmlmagnetometer.h b/src/imports/sensors/qmlmagnetometer.h
index d6c75c1e..6e5facda 100644
--- a/src/imports/sensors/qmlmagnetometer.h
+++ b/src/imports/sensors/qmlmagnetometer.h
@@ -44,7 +44,6 @@
#include "qmlsensor.h"
-QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
class QMagnetometer;
@@ -52,6 +51,7 @@ class QMagnetometer;
class QmlMagnetometer : public QmlSensor
{
Q_OBJECT
+ Q_PROPERTY(bool returnGeoValues READ returnGeoValues WRITE setReturnGeoValues NOTIFY returnGeoValuesChanged)
public:
explicit QmlMagnetometer(QObject *parent = 0);
~QmlMagnetometer();
@@ -59,6 +59,8 @@ public:
bool returnGeoValues() const;
void setReturnGeoValues(bool geo);
+Q_SIGNALS:
+ void returnGeoValuesChanged(bool returnGeoValues);
private:
QSensor *sensor() const Q_DECL_OVERRIDE;
@@ -99,5 +101,4 @@ private:
};
QT_END_NAMESPACE
-QT_END_HEADER
#endif
diff --git a/src/imports/sensors/qmlorientationsensor.h b/src/imports/sensors/qmlorientationsensor.h
index d14197e8..35e9d6fb 100644
--- a/src/imports/sensors/qmlorientationsensor.h
+++ b/src/imports/sensors/qmlorientationsensor.h
@@ -45,7 +45,6 @@
#include "qmlsensor.h"
#include <QOrientationSensor>
-QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
class QOrientationSensor;
@@ -86,5 +85,4 @@ private:
};
QT_END_NAMESPACE
-QT_END_HEADER
#endif
diff --git a/src/imports/sensors/qmlpressuresensor.cpp b/src/imports/sensors/qmlpressuresensor.cpp
new file mode 100644
index 00000000..a21f7c0d
--- /dev/null
+++ b/src/imports/sensors/qmlpressuresensor.cpp
@@ -0,0 +1,133 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Research In Motion
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtSensors module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include "qmlpressuresensor.h"
+#include <QPressureSensor>
+
+/*!
+ \qmltype PressureSensor
+ \instantiates QmlPressureSensor
+ \ingroup qml-sensors_type
+ \inqmlmodule QtSensors 5.0
+ \since QtSensors 5.1
+ \inherits Sensor
+ \brief The PressureSensor element reports on atmospheric pressure values.
+
+ The PressureSensor element reports on atmospheric pressure values.
+
+ This element wraps the QPressureSensor class. Please see the documentation for
+ QPressureSensor for details.
+
+ \sa PressureReading
+*/
+
+QmlPressureSensor::QmlPressureSensor(QObject *parent)
+ : QmlSensor(parent)
+ , m_sensor(new QPressureSensor(this))
+{
+}
+
+QmlPressureSensor::~QmlPressureSensor()
+{
+}
+
+QmlSensorReading *QmlPressureSensor::createReading() const
+{
+ return new QmlPressureReading(m_sensor);
+}
+
+QSensor *QmlPressureSensor::sensor() const
+{
+ return m_sensor;
+}
+
+/*!
+ \qmltype PressureReading
+ \instantiates QmlPressureReading
+ \ingroup qml-sensors_reading
+ \inqmlmodule QtSensors 5.0
+ \since QtSensors 5.1
+ \inherits SensorReading
+ \brief The PressureReading element holds the most recent PressureSensor reading.
+
+ The PressureReading element holds the most recent PressureSensor reading.
+
+ This element wraps the QPressureReading class. Please see the documentation for
+ QPressureReading for details.
+
+ This element cannot be directly created.
+*/
+
+QmlPressureReading::QmlPressureReading(QPressureSensor *sensor)
+ : QmlSensorReading(sensor)
+ , m_sensor(sensor)
+ , m_pressure(0)
+{
+}
+
+QmlPressureReading::~QmlPressureReading()
+{
+}
+
+/*!
+ \qmlproperty qreal PressureReading::pressure
+ This property holds the atmospheric pressure value in Pascals.
+
+ Please see QPressureReading::pressure for information about this property.
+*/
+
+qreal QmlPressureReading::pressure() const
+{
+ return m_pressure;
+}
+
+QSensorReading *QmlPressureReading::reading() const
+{
+ return m_sensor->reading();
+}
+
+void QmlPressureReading::readingUpdate()
+{
+ qreal pressure = m_sensor->reading()->pressure();
+ if (m_pressure != pressure) {
+ m_pressure = pressure;
+ Q_EMIT pressureChanged();
+ }
+}
diff --git a/src/imports/sensors/qmlpressuresensor.h b/src/imports/sensors/qmlpressuresensor.h
new file mode 100644
index 00000000..627915a6
--- /dev/null
+++ b/src/imports/sensors/qmlpressuresensor.h
@@ -0,0 +1,86 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Research In Motion
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtSensors module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#ifndef QMLPRESSURESENSOR_H
+#define QMLPRESSURESENSOR_H
+
+#include "qmlsensor.h"
+
+QT_BEGIN_NAMESPACE
+
+class QPressureSensor;
+
+class QmlPressureSensor : public QmlSensor
+{
+ Q_OBJECT
+public:
+ explicit QmlPressureSensor(QObject *parent = 0);
+ ~QmlPressureSensor();
+
+private:
+ QSensor *sensor() const Q_DECL_OVERRIDE;
+ QmlSensorReading *createReading() const Q_DECL_OVERRIDE;
+
+ QPressureSensor *m_sensor;
+};
+
+class QmlPressureReading : public QmlSensorReading
+{
+ Q_OBJECT
+ Q_PROPERTY(qreal pressure READ pressure NOTIFY pressureChanged)
+public:
+ explicit QmlPressureReading(QPressureSensor *sensor);
+ ~QmlPressureReading();
+
+ qreal pressure() const;
+
+Q_SIGNALS:
+ void pressureChanged();
+
+private:
+ QSensorReading *reading() const Q_DECL_OVERRIDE;
+ void readingUpdate() Q_DECL_OVERRIDE;
+
+ QPressureSensor *m_sensor;
+ qreal m_pressure;
+};
+
+QT_END_NAMESPACE
+#endif
diff --git a/src/imports/sensors/qmlproximitysensor.h b/src/imports/sensors/qmlproximitysensor.h
index afbc3a01..17cb2f9a 100644
--- a/src/imports/sensors/qmlproximitysensor.h
+++ b/src/imports/sensors/qmlproximitysensor.h
@@ -44,7 +44,6 @@
#include "qmlsensor.h"
-QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
class QProximitySensor;
@@ -84,5 +83,4 @@ private:
};
QT_END_NAMESPACE
-QT_END_HEADER
#endif
diff --git a/src/imports/sensors/qmlrotationsensor.cpp b/src/imports/sensors/qmlrotationsensor.cpp
index e58a3f8c..f1821641 100644
--- a/src/imports/sensors/qmlrotationsensor.cpp
+++ b/src/imports/sensors/qmlrotationsensor.cpp
@@ -65,6 +65,7 @@ QmlRotationSensor::QmlRotationSensor(QObject *parent)
: QmlSensor(parent)
, m_sensor(new QRotationSensor(this))
{
+ connect(m_sensor, SIGNAL(hasZChanged(bool)), this, SIGNAL(hasZChanged(bool)));
}
QmlRotationSensor::~QmlRotationSensor()
@@ -90,7 +91,7 @@ QSensor *QmlRotationSensor::sensor() const
bool QmlRotationSensor::hasZ() const
{
- return m_sensor->property("hasZ").toBool();
+ return m_sensor->hasZ();
}
void QmlRotationSensor::_update()
diff --git a/src/imports/sensors/qmlrotationsensor.h b/src/imports/sensors/qmlrotationsensor.h
index db3b62f6..4d7b543a 100644
--- a/src/imports/sensors/qmlrotationsensor.h
+++ b/src/imports/sensors/qmlrotationsensor.h
@@ -44,7 +44,6 @@
#include "qmlsensor.h"
-QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
class QRotationSensor;
@@ -52,13 +51,15 @@ class QRotationSensor;
class QmlRotationSensor : public QmlSensor
{
Q_OBJECT
- Q_PROPERTY(bool hasZ READ hasZ)
+ Q_PROPERTY(bool hasZ READ hasZ NOTIFY hasZChanged)
public:
explicit QmlRotationSensor(QObject *parent = 0);
~QmlRotationSensor();
bool hasZ() const;
+Q_SIGNALS:
+ void hasZChanged(bool hasZ);
private:
QSensor *sensor() const Q_DECL_OVERRIDE;
@@ -96,5 +97,4 @@ private:
};
QT_END_NAMESPACE
-QT_END_HEADER
#endif
diff --git a/src/imports/sensors/qmlsensor.cpp b/src/imports/sensors/qmlsensor.cpp
index ec1b0691..3d59a72d 100644
--- a/src/imports/sensors/qmlsensor.cpp
+++ b/src/imports/sensors/qmlsensor.cpp
@@ -171,6 +171,25 @@ void QmlSensor::setAlwaysOn(bool alwaysOn)
}
/*!
+ \qmlproperty bool Sensor::skipDuplicates
+ \since QtSensors 5.1
+
+ This property indicates whether duplicate reading values should be omitted.
+
+ Please see QSensor::skipDuplicates for information about this property.
+*/
+
+bool QmlSensor::skipDuplicates() const
+{
+ return sensor()->skipDuplicates();
+}
+
+void QmlSensor::setSkipDuplicates(bool skipDuplicates)
+{
+ sensor()->setSkipDuplicates(skipDuplicates);
+}
+
+/*!
\qmlproperty list<Range> Sensor::availableDataRates
This property holds the data rates that the sensor supports.
@@ -288,6 +307,99 @@ QmlSensorReading *QmlSensor::reading() const
}
/*!
+ \qmlproperty Sensor::AxesOrientationMode Sensor::axesOrientationMode
+ \since QtSensors 5.1
+ This property holds the mode that affects how the screen orientation changes reading values.
+
+ Please see QSensor::axesOrientationMode for information about this property.
+*/
+
+QmlSensor::AxesOrientationMode QmlSensor::axesOrientationMode() const
+{
+ return static_cast<QmlSensor::AxesOrientationMode>(sensor()->axesOrientationMode());
+}
+
+void QmlSensor::setAxesOrientationMode(QmlSensor::AxesOrientationMode axesOrientationMode)
+{
+ sensor()->setAxesOrientationMode(static_cast<QSensor::AxesOrientationMode>(axesOrientationMode));
+}
+
+/*!
+ \qmlproperty int Sensor::currentOrientation
+ \since QtSensors 5.1
+ This property holds the current orientation that is used for rotating the reading values.
+
+ Please see QSensor::currentOrientation for information about this property.
+*/
+
+int QmlSensor::currentOrientation() const
+{
+ return sensor()->currentOrientation();
+}
+
+/*!
+ \qmlproperty int Sensor::userOrientation
+ \since QtSensors 5.1
+ This property holds the angle used for rotating the reading values in the UserOrientation mode.
+
+ Please see QSensor::userOrientation for information about this property.
+*/
+
+int QmlSensor::userOrientation() const
+{
+ return sensor()->userOrientation();
+}
+
+void QmlSensor::setUserOrientation(int userOrientation)
+{
+ sensor()->setUserOrientation(userOrientation);
+}
+
+/*!
+ \qmlproperty int Sensor::maxBufferSize
+ \since QtSensors 5.1
+ This property holds the maximum buffer size.
+
+ Please see QSensor::maxBufferSize for information about this property.
+*/
+
+int QmlSensor::maxBufferSize() const
+{
+ return sensor()->maxBufferSize();
+}
+
+/*!
+ \qmlproperty int Sensor::efficientBufferSize
+ \since QtSensors 5.1
+ The property holds the most efficient buffer size.
+
+ Please see QSensor::efficientBufferSize for information about this property.
+*/
+
+int QmlSensor::efficientBufferSize() const
+{
+ return sensor()->efficientBufferSize();
+}
+
+/*!
+ \qmlproperty int Sensor::bufferSize
+ \since QtSensors 5.1
+ This property holds the size of the buffer.
+
+ Please see QSensor::bufferSize for information about this property.
+*/
+
+int QmlSensor::bufferSize() const
+{
+ return sensor()->bufferSize();
+}
+
+void QmlSensor::setBufferSize(int bufferSize)
+{
+ sensor()->setBufferSize(bufferSize);
+}
+
+/*!
\qmlmethod bool Sensor::start()
Start retrieving values from the sensor. Returns true if the sensor was started, false otherwise.
@@ -323,6 +435,14 @@ void QmlSensor::componentComplete()
connect(sensor(), SIGNAL(sensorError(int)), this, SIGNAL(errorChanged()));
connect(sensor(), SIGNAL(activeChanged()), this, SIGNAL(activeChanged()));
connect(sensor(), SIGNAL(alwaysOnChanged()), this, SIGNAL(alwaysOnChanged()));
+ connect(sensor(), SIGNAL(skipDuplicatesChanged(bool)), this, SIGNAL(skipDuplicatesChanged(bool)));
+ connect(sensor(), SIGNAL(axesOrientationModeChanged(AxesOrientationMode)),
+ this, SIGNAL(axesOrientationModeChanged(AxesOrientationMode)));
+ connect(sensor(), SIGNAL(userOrientationChanged(int)), this, SIGNAL(userOrientationChanged(int)));
+ connect(sensor(), SIGNAL(currentOrientationChanged(int)), this, SIGNAL(currentOrientationChanged(int)));
+ connect(sensor(), SIGNAL(bufferSizeChanged(int)), this, SIGNAL(bufferSizeChanged(int)));
+ connect(sensor(), SIGNAL(maxBufferSizeChanged(int)), this, SIGNAL(maxBufferSizeChanged(int)));
+ connect(sensor(), SIGNAL(efficientBufferSizeChanged(int)), this, SIGNAL(efficientBufferSizeChanged(int)));
// We need to set this on the sensor object now
sensor()->setIdentifier(m_identifier.toLocal8Bit());
diff --git a/src/imports/sensors/qmlsensor.h b/src/imports/sensors/qmlsensor.h
index a4ac852d..f72234ae 100644
--- a/src/imports/sensors/qmlsensor.h
+++ b/src/imports/sensors/qmlsensor.h
@@ -46,7 +46,6 @@
#include <QQmlListProperty>
#include "qmlsensorrange.h"
-QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
class QSensor;
@@ -57,6 +56,7 @@ class QmlSensorReading;
class QmlSensor : public QObject, public QQmlParserStatus
{
Q_OBJECT
+ Q_ENUMS(AxesOrientationMode)
Q_INTERFACES(QQmlParserStatus)
Q_PROPERTY(QString identifier READ identifier WRITE setIdentifier NOTIFY identifierChanged)
Q_PROPERTY(QString type READ type NOTIFY typeChanged)
@@ -71,7 +71,22 @@ class QmlSensor : public QObject, public QQmlParserStatus
Q_PROPERTY(QString description READ description NOTIFY descriptionChanged)
Q_PROPERTY(int error READ error NOTIFY errorChanged)
Q_PROPERTY(bool alwaysOn READ isAlwaysOn WRITE setAlwaysOn NOTIFY alwaysOnChanged)
+ Q_PROPERTY(bool skipDuplicates READ skipDuplicates WRITE setSkipDuplicates NOTIFY skipDuplicatesChanged REVISION 1)
+ Q_PROPERTY(AxesOrientationMode axesOrientationMode READ axesOrientationMode WRITE setAxesOrientationMode NOTIFY axesOrientationModeChanged REVISION 1)
+ Q_PROPERTY(int currentOrientation READ currentOrientation NOTIFY currentOrientationChanged REVISION 1)
+ Q_PROPERTY(int userOrientation READ userOrientation WRITE setUserOrientation NOTIFY userOrientationChanged REVISION 1)
+ Q_PROPERTY(int maxBufferSize READ maxBufferSize NOTIFY maxBufferSizeChanged REVISION 1)
+ Q_PROPERTY(int efficientBufferSize READ efficientBufferSize NOTIFY efficientBufferSizeChanged REVISION 1)
+ Q_PROPERTY(int bufferSize READ bufferSize WRITE setBufferSize NOTIFY bufferSizeChanged REVISION 1)
+
public:
+ // Keep in sync with QSensor::AxesOrientationMode
+ enum AxesOrientationMode {
+ FixedOrientation,
+ AutomaticOrientation,
+ UserOrientation
+ };
+
explicit QmlSensor(QObject *parent = 0);
~QmlSensor();
@@ -90,6 +105,9 @@ public:
bool isAlwaysOn() const;
void setAlwaysOn(bool alwaysOn);
+ bool skipDuplicates() const;
+ void setSkipDuplicates(bool skipDuplicates);
+
QQmlListProperty<QmlSensorRange> availableDataRates() const;
int dataRate() const;
void setDataRate(int rate);
@@ -103,6 +121,21 @@ public:
QmlSensorReading *reading() const;
+ AxesOrientationMode axesOrientationMode() const;
+ void setAxesOrientationMode(AxesOrientationMode axesOrientationMode);
+
+ int currentOrientation() const;
+
+ int userOrientation() const;
+ void setUserOrientation(int userOrientation);
+
+ int maxBufferSize() const;
+
+ int efficientBufferSize() const;
+
+ int bufferSize() const;
+ void setBufferSize(int bufferSize);
+
public Q_SLOTS:
bool start();
void stop();
@@ -120,6 +153,13 @@ Q_SIGNALS:
void descriptionChanged();
void errorChanged();
void alwaysOnChanged();
+ void skipDuplicatesChanged(bool skipDuplicates);
+ void axesOrientationModeChanged(AxesOrientationMode axesOrientationMode);
+ void currentOrientationChanged(int currentOrientation);
+ void userOrientationChanged(int userOrientation);
+ void maxBufferSizeChanged(int maxBufferSize);
+ void efficientBufferSizeChanged(int efficientBufferSize);
+ void bufferSizeChanged(int bufferSize);
protected:
virtual QSensor *sensor() const = 0;
@@ -127,6 +167,8 @@ protected:
private Q_SLOTS:
void updateReading();
+
+protected Q_SLOTS:
void componentComplete();
private:
@@ -159,6 +201,5 @@ private:
};
QT_END_NAMESPACE
-QT_END_HEADER
#endif
diff --git a/src/imports/sensors/qmlsensorglobal.h b/src/imports/sensors/qmlsensorglobal.h
index fbbd30d7..cd28ffef 100644
--- a/src/imports/sensors/qmlsensorglobal.h
+++ b/src/imports/sensors/qmlsensorglobal.h
@@ -45,7 +45,6 @@
#include <QObject>
#include <QStringList>
-QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
class QSensor;
@@ -69,6 +68,5 @@ private:
};
QT_END_NAMESPACE
-QT_END_HEADER
#endif
diff --git a/src/imports/sensors/qmlsensorrange.h b/src/imports/sensors/qmlsensorrange.h
index 261825b5..f2fcb510 100644
--- a/src/imports/sensors/qmlsensorrange.h
+++ b/src/imports/sensors/qmlsensorrange.h
@@ -44,7 +44,6 @@
#include <QObject>
-QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
class QmlSensorRange : public QObject
@@ -94,5 +93,4 @@ private:
};
QT_END_NAMESPACE
-QT_END_HEADER
#endif
diff --git a/src/imports/sensors/qmltapsensor.cpp b/src/imports/sensors/qmltapsensor.cpp
index 65afcb59..8877b0b0 100644
--- a/src/imports/sensors/qmltapsensor.cpp
+++ b/src/imports/sensors/qmltapsensor.cpp
@@ -65,6 +65,8 @@ QmlTapSensor::QmlTapSensor(QObject *parent)
: QmlSensor(parent)
, m_sensor(new QTapSensor(this))
{
+ connect(m_sensor, SIGNAL(returnDoubleTapEventsChanged(bool)),
+ this, SIGNAL(returnDoubleTapEventsChanged(bool)));
}
QmlTapSensor::~QmlTapSensor()
@@ -90,14 +92,12 @@ QSensor *QmlTapSensor::sensor() const
bool QmlTapSensor::returnDoubleTapEvents() const
{
- return m_sensor->property("returnDoubleTapEvents").toBool();
+ return m_sensor->returnDoubleTapEvents();
}
void QmlTapSensor::setReturnDoubleTapEvents(bool ret)
{
- if (m_sensor->property("returnDoubleTapEvents").toBool() == ret) return;
- m_sensor->setProperty("returnDoubleTapEvents", ret);
- Q_EMIT returnDoubleTapEventsChanged();
+ m_sensor->setReturnDoubleTapEvents(ret);
}
/*!
diff --git a/src/imports/sensors/qmltapsensor.h b/src/imports/sensors/qmltapsensor.h
index f9ae94bd..b0c2fa5c 100644
--- a/src/imports/sensors/qmltapsensor.h
+++ b/src/imports/sensors/qmltapsensor.h
@@ -45,7 +45,6 @@
#include "qmlsensor.h"
#include <QTapSensor>
-QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
class QTapSensor;
@@ -61,9 +60,8 @@ public:
bool returnDoubleTapEvents() const;
void setReturnDoubleTapEvents(bool ret);
-
Q_SIGNALS:
- void returnDoubleTapEventsChanged();
+ void returnDoubleTapEventsChanged(bool returnDoubleTapEvents);
private:
QSensor *sensor() const Q_DECL_OVERRIDE;
@@ -97,5 +95,4 @@ private:
};
QT_END_NAMESPACE
-QT_END_HEADER
#endif
diff --git a/src/imports/sensors/qmltiltsensor.h b/src/imports/sensors/qmltiltsensor.h
index 9afed564..422c21dd 100644
--- a/src/imports/sensors/qmltiltsensor.h
+++ b/src/imports/sensors/qmltiltsensor.h
@@ -45,7 +45,6 @@
#include "qmlsensor.h"
#include <QtSensors/QTiltSensor>
-QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
class QTiltSensor;
@@ -90,5 +89,4 @@ private:
};
QT_END_NAMESPACE
-QT_END_HEADER
#endif
diff --git a/src/imports/sensors/sensors.cpp b/src/imports/sensors/sensors.cpp
index 50ccdf93..77ad754a 100644
--- a/src/imports/sensors/sensors.cpp
+++ b/src/imports/sensors/sensors.cpp
@@ -44,7 +44,9 @@
#include <QtSensors/QSensorManager>
#include <QtSensors/qaccelerometer.h>
+#include <QtSensors/qaltimeter.h>
#include <QtSensors/qambientlightsensor.h>
+#include <QtSensors/qambienttemperaturesensor.h>
#include <QtSensors/qcompass.h>
#include <QtSensors/qmagnetometer.h>
#include <QtSensors/qorientationsensor.h>
@@ -59,13 +61,17 @@
#include "qmlsensorglobal.h"
#include "qmlsensor.h"
#include "qmlaccelerometer.h"
+#include "qmlaltimeter.h"
#include "qmlambientlightsensor.h"
+#include "qmlambienttemperaturesensor.h"
#include "qmlcompass.h"
#include "qmlgyroscope.h"
+#include "qmlholstersensor.h"
#include "qmlirproximitysensor.h"
#include "qmllightsensor.h"
#include "qmlmagnetometer.h"
#include "qmlorientationsensor.h"
+#include "qmlpressuresensor.h"
#include "qmlproximitysensor.h"
#include "qmlrotationsensor.h"
#include "qmltapsensor.h"
@@ -125,6 +131,49 @@ public:
qmlRegisterUncreatableType<QmlTiltSensorReading >(package, major, minor, "TiltReading", QLatin1String("Cannot create TiltReading"));
qmlRegisterType <QmlSensorGesture >(package, major, minor, "SensorGesture");
+
+ // Register the 5.1 interfaces
+ major = 5;
+ minor = 1;
+ qmlRegisterSingletonType <QmlSensorGlobal >(package, major, minor, "QmlSensors", global_object_50);
+ qmlRegisterUncreatableType<QmlSensorRange >(package, major, minor, "Range", QLatin1String("Cannot create Range"));
+ qmlRegisterUncreatableType<QmlSensorOutputRange >(package, major, minor, "OutputRange", QLatin1String("Cannot create OutputRange"));
+ qmlRegisterUncreatableType<QmlSensor,1 >(package, major, minor, "Sensor", QLatin1String("Cannot create Sensor"));
+ qmlRegisterUncreatableType<QmlSensorReading >(package, major, minor, "SensorReading", QLatin1String("Cannot create SensorReading"));
+ qmlRegisterType <QmlAccelerometer,1 >(package, major, minor, "Accelerometer");
+ qmlRegisterUncreatableType<QmlAccelerometerReading >(package, major, minor, "AccelerometerReading", QLatin1String("Cannot create AccelerometerReading"));
+ qmlRegisterType <QmlAltimeter >(package, major, minor, "Altimeter");
+ qmlRegisterUncreatableType<QmlAltimeterReading >(package, major, minor, "AltimeterReading", QLatin1String("Cannot create AltimeterReading"));
+ qmlRegisterType <QmlAmbientLightSensor >(package, major, minor, "AmbientLightSensor");
+ qmlRegisterUncreatableType<QmlAmbientLightSensorReading>(package, major, minor, "AmbientLightReading", QLatin1String("Cannot create AmbientLightReading"));
+ qmlRegisterType <QmlAmbientTemperatureSensor >(package, major, minor, "AmbientTemperatureSensor");
+ qmlRegisterUncreatableType<QmlAmbientTemperatureReading>(package, major, minor, "AmbientTemperatureReading", QLatin1String("Cannot create AmbientTemperatureReading"));
+ qmlRegisterType <QmlCompass >(package, major, minor, "Compass");
+ qmlRegisterUncreatableType<QmlCompassReading >(package, major, minor, "CompassReading", QLatin1String("Cannot create CompassReading"));
+ qmlRegisterType <QmlGyroscope >(package, major, minor, "Gyroscope");
+ qmlRegisterUncreatableType<QmlGyroscopeReading >(package, major, minor, "GyroscopeReading", QLatin1String("Cannot create GyroscopeReading"));
+ qmlRegisterType <QmlHolsterSensor >(package, major, minor, "HolsterSensor");
+ qmlRegisterUncreatableType<QmlHolsterReading >(package, major, minor, "HolsterReading", QLatin1String("Cannot create HolsterReading"));
+ qmlRegisterType <QmlIRProximitySensor >(package, major, minor, "IRProximitySensor");
+ qmlRegisterUncreatableType<QmlIRProximitySensorReading >(package, major, minor, "IRProximityReading", QLatin1String("Cannot create IRProximityReading"));
+ qmlRegisterType <QmlLightSensor >(package, major, minor, "LightSensor");
+ qmlRegisterUncreatableType<QmlLightSensorReading >(package, major, minor, "LightReading", QLatin1String("Cannot create LightReading"));
+ qmlRegisterType <QmlMagnetometer >(package, major, minor, "Magnetometer");
+ qmlRegisterUncreatableType<QmlMagnetometerReading >(package, major, minor, "MagnetometerReading", QLatin1String("Cannot create MagnetometerReading"));
+ qmlRegisterType <QmlOrientationSensor >(package, major, minor, "OrientationSensor");
+ qmlRegisterUncreatableType<QmlOrientationSensorReading >(package, major, minor, "OrientationReading", QLatin1String("Cannot create OrientationReading"));
+ qmlRegisterType <QmlPressureSensor >(package, major, minor, "PressureSensor");
+ qmlRegisterUncreatableType<QmlPressureReading >(package, major, minor, "PressureReading", QLatin1String("Cannot create PressureReading"));
+ qmlRegisterType <QmlProximitySensor >(package, major, minor, "ProximitySensor");
+ qmlRegisterUncreatableType<QmlProximitySensorReading >(package, major, minor, "ProximityReading", QLatin1String("Cannot create ProximityReading"));
+ qmlRegisterType <QmlRotationSensor >(package, major, minor, "RotationSensor");
+ qmlRegisterUncreatableType<QmlRotationSensorReading >(package, major, minor, "RotationReading", QLatin1String("Cannot create RotationReading"));
+ qmlRegisterType <QmlTapSensor >(package, major, minor, "TapSensor");
+ qmlRegisterUncreatableType<QmlTapSensorReading >(package, major, minor, "TapReading", QLatin1String("Cannot create TapReading"));
+ qmlRegisterType <QmlTiltSensor >(package, major, minor, "TiltSensor");
+ qmlRegisterUncreatableType<QmlTiltSensorReading >(package, major, minor, "TiltReading", QLatin1String("Cannot create TiltReading"));
+
+ qmlRegisterType <QmlSensorGesture >(package, major, minor, "SensorGesture");
}
};
diff --git a/src/imports/sensors/sensors.pro b/src/imports/sensors/sensors.pro
index 210ceac1..2236ce11 100644
--- a/src/imports/sensors/sensors.pro
+++ b/src/imports/sensors/sensors.pro
@@ -1,7 +1,7 @@
CXX_MODULE = sensors
TARGET = declarative_sensors
TARGETPATH = QtSensors
-IMPORT_VERSION = 5.0 # Doesn't matter, as long as it's a valid version?!
+IMPORT_VERSION = 5.1 # Doesn't matter, as long as it's a valid version?!
QT += qml sensors sensors-private
@@ -9,13 +9,17 @@ HEADERS += \
qmlsensor.h \
qmlsensorrange.h \
qmlaccelerometer.h \
+ qmlaltimeter.h \
qmlambientlightsensor.h \
+ qmlambienttemperaturesensor.h \
qmlcompass.h \
qmlgyroscope.h \
+ qmlholstersensor.h \
qmlirproximitysensor.h \
qmllightsensor.h \
qmlmagnetometer.h \
qmlorientationsensor.h \
+ qmlpressuresensor.h\
qmlproximitysensor.h \
qmltapsensor.h \
qmlrotationsensor.h \
@@ -27,13 +31,17 @@ SOURCES += sensors.cpp \
qmlsensor.cpp \
qmlsensorrange.cpp \
qmlaccelerometer.cpp \
+ qmlaltimeter.cpp \
qmlambientlightsensor.cpp \
+ qmlambienttemperaturesensor.cpp \
qmlcompass.cpp \
qmlgyroscope.cpp \
+ qmlholstersensor.cpp \
qmlirproximitysensor.cpp \
qmllightsensor.cpp \
qmlmagnetometer.cpp \
qmlorientationsensor.cpp \
+ qmlpressuresensor.cpp\
qmlproximitysensor.cpp \
qmltapsensor.cpp \
qmlrotationsensor.cpp \
diff --git a/src/plugins/sensors/android/android.pro b/src/plugins/sensors/android/android.pro
new file mode 100644
index 00000000..0dc6a3fc
--- /dev/null
+++ b/src/plugins/sensors/android/android.pro
@@ -0,0 +1,2 @@
+TEMPLATE = subdirs
+SUBDIRS += jar src
diff --git a/src/plugins/sensors/android/jar/AndroidManifest.xml b/src/plugins/sensors/android/jar/AndroidManifest.xml
new file mode 100644
index 00000000..5d15cab2
--- /dev/null
+++ b/src/plugins/sensors/android/jar/AndroidManifest.xml
@@ -0,0 +1,6 @@
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="org.qtproject.qt5.android.sensors"
+ android:versionCode="1"
+ android:versionName="1.0" >
+ <supports-screens android:largeScreens="true" android:normalScreens="true" android:anyDensity="true" android:smallScreens="true"/>
+</manifest>
diff --git a/src/plugins/sensors/android/jar/jar.pro b/src/plugins/sensors/android/jar/jar.pro
new file mode 100644
index 00000000..a9350743
--- /dev/null
+++ b/src/plugins/sensors/android/jar/jar.pro
@@ -0,0 +1,10 @@
+load(qt_build_paths)
+
+CONFIG += java
+TARGET = QtSensors
+DESTDIR = $$MODULE_BASE_OUTDIR/jar
+
+JAVACLASSPATH += $$PWD/src
+
+JAVASOURCES += \
+ $$PWD/src/org/qtproject/qt5/android/sensors/QtSensors.java
diff --git a/src/plugins/sensors/android/jar/src/org/qtproject/qt5/android/sensors/QtSensors.java b/src/plugins/sensors/android/jar/src/org/qtproject/qt5/android/sensors/QtSensors.java
new file mode 100644
index 00000000..c7956d2d
--- /dev/null
+++ b/src/plugins/sensors/android/jar/src/org/qtproject/qt5/android/sensors/QtSensors.java
@@ -0,0 +1,161 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 BogDan Vatra <bogdan@kde.org>
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtSensor module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+package org.qtproject.qt5.android.sensors;
+
+import java.util.HashSet;
+import java.util.List;
+
+import android.app.Activity;
+import android.hardware.Sensor;
+import android.hardware.SensorEvent;
+import android.hardware.SensorEventListener;
+import android.hardware.SensorManager;
+import android.os.Build;
+import android.util.SparseArray;
+
+import android.util.Log;
+
+public class QtSensors implements SensorEventListener
+{
+ static final QtSensors m_sensorsListener = new QtSensors();
+ static SensorManager m_sensorManager = null;
+ static SparseArray<Sensor> m_registeredSensors = new SparseArray<Sensor>();
+ static Object m_syncObject = new Object();
+ static public void setActivity(Activity activity, Object acitvityDelegate)
+ {
+ try {
+ m_sensorManager = (SensorManager)activity.getSystemService(Activity.SENSOR_SERVICE);
+ } catch(Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ private static String getSensorDescription(int sensorType)
+ {
+ try {
+ Sensor s = m_sensorManager.getDefaultSensor(sensorType);
+ return s.getName() + " " + s.getVendor() + " v" + s.getVersion();
+ } catch(Exception e) {
+ e.printStackTrace();
+ }
+ return null;
+ }
+
+ private static int[] getSensorList()
+ {
+ try {
+ List<Sensor> list = m_sensorManager.getSensorList(Sensor.TYPE_ALL);
+ HashSet<Integer> filteredList = new HashSet<Integer>();
+ for (Sensor s : list)
+ filteredList.add(s.getType());
+ int retList[] = new int[filteredList.size()];
+ int pos = 0;
+ for (int type : filteredList)
+ retList[pos++] = type;
+ return retList;
+ } catch(Exception e) {
+ e.printStackTrace();
+ }
+ return null;
+ }
+
+ private static boolean registerSensor(int sensorType, int rate)
+ {
+ synchronized (m_syncObject) {
+ try {
+ Sensor s = m_sensorManager.getDefaultSensor(sensorType);
+ m_sensorManager.registerListener(m_sensorsListener, s, rate);
+ m_registeredSensors.put(sensorType, s);
+ } catch(Exception e) {
+ e.printStackTrace();
+ return false;
+ }
+ }
+ return true;
+ }
+
+ private static boolean unregisterSensor(int sensorType)
+ {
+ synchronized (m_syncObject) {
+ try {
+ Sensor s = m_registeredSensors.get(sensorType);
+ if (s != null) {
+ m_sensorManager.unregisterListener(m_sensorsListener, m_registeredSensors.get(sensorType));
+ m_registeredSensors.remove(sensorType);
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ return false;
+ }
+ }
+ return true;
+ }
+
+ private static float[] convertQuaternionToEuler(float[] rotationVector)
+ {
+ float matrix[] = new float[9];
+ SensorManager.getRotationMatrixFromVector (matrix, rotationVector);
+ float angles[] = new float[3];
+ SensorManager.getOrientation (matrix, angles);
+ return angles;
+ }
+
+ public static native void accuracyChanged(int sensorType, int accuracy);
+ public static native void sensorChanged(int sensorType, long timestamp, float[] values);
+
+ @Override
+ public void onAccuracyChanged(Sensor sensor, int accuracy)
+ {
+ accuracyChanged(sensor.getType(), accuracy);
+ }
+
+ @Override
+ public void onSensorChanged(SensorEvent sensorEvent)
+ {
+ if (sensorEvent.sensor.getType() == Sensor.TYPE_ROTATION_VECTOR) {
+ //#### hacky, but much easier than exposing the convert function and converting the arrays back and forth...
+ sensorChanged(sensorEvent.sensor.getType(), sensorEvent.timestamp, convertQuaternionToEuler(sensorEvent.values));
+ } else {
+ sensorChanged(sensorEvent.sensor.getType(), sensorEvent.timestamp, sensorEvent.values);
+ }
+ }
+}
diff --git a/src/plugins/sensors/android/src/androidaccelerometer.cpp b/src/plugins/sensors/android/src/androidaccelerometer.cpp
new file mode 100644
index 00000000..b64536ef
--- /dev/null
+++ b/src/plugins/sensors/android/src/androidaccelerometer.cpp
@@ -0,0 +1,63 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 BogDan Vatra <bogdan@kde.org>
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtSensors module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "androidaccelerometer.h"
+
+AndroidAccelerometer::AndroidAccelerometer(AndroidSensors::AndroidSensorType type, QSensor *sensor)
+ : AndroidCommonSensor<QAccelerometerReading>(type, sensor)
+{}
+
+void AndroidAccelerometer::onSensorChanged(jlong timestamp, const jfloat *values, uint size)
+{
+ if (size < 3)
+ return;
+ m_reader.setTimestamp(timestamp);
+ // check https://developer.android.com/reference/android/hardware/SensorEvent.html#values
+ m_reader.setX(values[0]);
+ m_reader.setY(values[1]);
+ m_reader.setZ(values[2]);
+ newReadingAvailable();
+}
+
+void AndroidAccelerometer::onAccuracyChanged(jint accuracy)
+{
+ Q_UNUSED(accuracy)
+}
diff --git a/src/plugins/sensors/android/src/androidaccelerometer.h b/src/plugins/sensors/android/src/androidaccelerometer.h
new file mode 100644
index 00000000..6c95fdb3
--- /dev/null
+++ b/src/plugins/sensors/android/src/androidaccelerometer.h
@@ -0,0 +1,59 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 BogDan Vatra <bogdan@kde.org>
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtSensors module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef ANDROIDACCELEROMETER_H
+#define ANDROIDACCELEROMETER_H
+#include <qaccelerometer.h>
+
+#include "androidcommonsensor.h"
+
+class AndroidAccelerometer : public AndroidCommonSensor<QAccelerometerReading>
+{
+public:
+ AndroidAccelerometer(AndroidSensors::AndroidSensorType type, QSensor *sensor);
+
+private:
+ virtual void onAccuracyChanged(jint accuracy);
+ virtual void onSensorChanged(jlong timestamp, const jfloat *values, uint size);
+
+};
+
+#endif // ANDROIDACCELEROMETER_H
diff --git a/src/plugins/sensors/android/src/androidcommonsensor.h b/src/plugins/sensors/android/src/androidcommonsensor.h
new file mode 100644
index 00000000..40f118ed
--- /dev/null
+++ b/src/plugins/sensors/android/src/androidcommonsensor.h
@@ -0,0 +1,88 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 BogDan Vatra <bogdan@kde.org>
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtSensors module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef ANDROIDCOMMONSENSOR_H
+#define ANDROIDCOMMONSENSOR_H
+
+#include <qsensorbackend.h>
+#include <qsensor.h>
+#include "androidjnisensors.h"
+
+template <typename ReaderType>
+class AndroidCommonSensor : public QSensorBackend, protected AndroidSensors::AndroidSensorsListenerInterface
+{
+public:
+ AndroidCommonSensor(AndroidSensors::AndroidSensorType type, QSensor *sensor) : QSensorBackend(sensor)
+ {
+ setDescription(AndroidSensors::sensorDescription(type));
+ setReading<ReaderType>(&m_reader);
+ m_type = type;
+ m_isStarted = false;
+ }
+
+ virtual ~AndroidCommonSensor()
+ {
+ if (m_isStarted)
+ stop();
+ }
+ virtual void start()
+ {
+ if (AndroidSensors::registerListener(m_type, this, sensor()->dataRate()))
+ m_isStarted = true;
+ }
+
+ virtual void stop()
+ {
+ if (m_isStarted) {
+ m_isStarted = false;
+ AndroidSensors::unregisterListener(m_type, this);
+ }
+ }
+
+protected:
+ ReaderType m_reader;
+
+private:
+ AndroidSensors::AndroidSensorType m_type;
+ bool m_isStarted;
+};
+
+#endif // ANDROIDCOMMONSENSOR_H
diff --git a/src/plugins/sensors/android/src/androidgyroscope.cpp b/src/plugins/sensors/android/src/androidgyroscope.cpp
new file mode 100644
index 00000000..69a05c18
--- /dev/null
+++ b/src/plugins/sensors/android/src/androidgyroscope.cpp
@@ -0,0 +1,64 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 BogDan Vatra <bogdan@kde.org>
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtSensors module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "androidgyroscope.h"
+#include <math.h>
+
+AndroidGyroscope::AndroidGyroscope(AndroidSensors::AndroidSensorType type, QSensor *sensor)
+ : AndroidCommonSensor<QGyroscopeReading>(type, sensor)
+{}
+
+void AndroidGyroscope::onSensorChanged(jlong timestamp, const jfloat *values, uint size)
+{
+ if (size < 3)
+ return;
+ m_reader.setTimestamp(timestamp);
+ // check https://developer.android.com/reference/android/hardware/SensorEvent.html#values
+ m_reader.setX(values[0]*180/M_PI);
+ m_reader.setY(values[1]*180/M_PI);
+ m_reader.setZ(values[2]*180/M_PI);
+ newReadingAvailable();
+}
+
+void AndroidGyroscope::onAccuracyChanged(jint accuracy)
+{
+ Q_UNUSED(accuracy)
+}
diff --git a/src/plugins/sensors/android/src/androidgyroscope.h b/src/plugins/sensors/android/src/androidgyroscope.h
new file mode 100644
index 00000000..3b633b7c
--- /dev/null
+++ b/src/plugins/sensors/android/src/androidgyroscope.h
@@ -0,0 +1,57 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 BogDan Vatra <bogdan@kde.org>
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtSensors module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef ANDROIDGYROSCOPE_H
+#define ANDROIDGYROSCOPE_H
+#include <qgyroscope.h>
+
+#include "androidcommonsensor.h"
+
+class AndroidGyroscope : public AndroidCommonSensor<QGyroscopeReading>
+{
+public:
+ AndroidGyroscope(AndroidSensors::AndroidSensorType type, QSensor *sensor);
+private:
+ virtual void onAccuracyChanged(jint accuracy);
+ virtual void onSensorChanged(jlong timestamp, const jfloat *values, uint size);
+};
+
+#endif // ANDROIDGYROSCOPE_H
diff --git a/src/plugins/sensors/android/src/androidjnisensors.cpp b/src/plugins/sensors/android/src/androidjnisensors.cpp
new file mode 100644
index 00000000..6365433c
--- /dev/null
+++ b/src/plugins/sensors/android/src/androidjnisensors.cpp
@@ -0,0 +1,245 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 BogDan Vatra <bogdan@kde.org>
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtSensors module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <qglobal.h>
+#include <android/log.h>
+#include <QtCore/QReadWriteLock>
+#include <QtCore/QHash>
+
+#include "androidjnisensors.h"
+
+static JavaVM *javaVM = 0;
+jclass sensorsClass;
+
+static jmethodID getSensorListMethodId;
+static jmethodID registerSensorMethodId;
+static jmethodID unregisterSensorMethodId;
+static jmethodID getSensorDescriptionMethodId;
+
+static QHash<int, QList<AndroidSensors::AndroidSensorsListenerInterface *> > listenersHash;
+QReadWriteLock listenersLocker;
+enum {
+ SENSOR_DELAY_FASTEST = 0,
+ SENSOR_DELAY_GAME = 1,
+ SENSOR_DELAY_NORMAL = 3,
+ SENSOR_DELAY_UI =2
+};
+namespace AndroidSensors
+{
+ struct AttachedJNIEnv
+ {
+ AttachedJNIEnv()
+ {
+ attached = false;
+ if (javaVM->GetEnv((void**)&jniEnv, JNI_VERSION_1_6) < 0) {
+ if (javaVM->AttachCurrentThread(&jniEnv, NULL) < 0) {
+ __android_log_print(ANDROID_LOG_ERROR, "Qt", "AttachCurrentThread failed");
+ jniEnv = 0;
+ return;
+ }
+ attached = true;
+ }
+ }
+
+ ~AttachedJNIEnv()
+ {
+ if (attached)
+ javaVM->DetachCurrentThread();
+ }
+ bool attached;
+ JNIEnv *jniEnv;
+ };
+
+ QVector<AndroidSensorType> availableSensors()
+ {
+ QVector<AndroidSensorType> ret;
+ AttachedJNIEnv aenv;
+ if (!aenv.jniEnv)
+ return ret;
+ jintArray jsensors = static_cast<jintArray>(aenv.jniEnv->CallStaticObjectMethod(sensorsClass,
+ getSensorListMethodId));
+ jint *sensors = aenv.jniEnv->GetIntArrayElements(jsensors, 0);
+ const uint sz = aenv.jniEnv->GetArrayLength(jsensors);
+ for (uint i = 0; i < sz; i++)
+ ret.push_back(AndroidSensorType(sensors[i]));
+ aenv.jniEnv->ReleaseIntArrayElements(jsensors, sensors, 0);
+ return ret;
+ }
+
+ QString sensorDescription(AndroidSensorType sensor)
+ {
+ AttachedJNIEnv aenv;
+ if (!aenv.jniEnv)
+ return QString();
+ jstring jstr = static_cast<jstring>(aenv.jniEnv->CallStaticObjectMethod(sensorsClass,
+ getSensorDescriptionMethodId,
+ jint(sensor)));
+ const jchar *pstr = aenv.jniEnv->GetStringChars(jstr, 0);
+ QString ret(reinterpret_cast<const QChar *>(pstr), aenv.jniEnv->GetStringLength(jstr));
+ aenv.jniEnv->ReleaseStringChars(jstr, pstr);
+ aenv.jniEnv->DeleteLocalRef(jstr);
+ return ret;
+ }
+
+ bool registerListener(AndroidSensorType sensor, AndroidSensorsListenerInterface *listener, int dataRate)
+ {
+ listenersLocker.lockForWrite();
+ bool startService = listenersHash[sensor].empty();
+ listenersHash[sensor].push_back(listener);
+ listenersLocker.unlock();
+ if (startService) {
+ AttachedJNIEnv aenv;
+ if (!aenv.jniEnv)
+ return false;
+ int rate = dataRate > 0 ? 1000000/dataRate : SENSOR_DELAY_GAME;
+ return aenv.jniEnv->CallStaticBooleanMethod(sensorsClass,
+ registerSensorMethodId,
+ jint(sensor),
+ jint(rate));
+ }
+ return true;
+ }
+
+ bool unregisterListener(AndroidSensorType sensor, AndroidSensorsListenerInterface *listener)
+ {
+ listenersLocker.lockForWrite();
+ listenersHash[sensor].removeOne(listener);
+ bool stopService = listenersHash[sensor].empty();
+ if (stopService)
+ listenersHash.remove(sensor);
+ listenersLocker.unlock();
+ if (stopService) {
+ AttachedJNIEnv aenv;
+ if (!aenv.jniEnv)
+ return false;
+ return aenv.jniEnv->CallStaticBooleanMethod(sensorsClass, unregisterSensorMethodId, jint(sensor));
+ }
+ return true;
+ }
+}
+
+static const char logTag[] = "Qt";
+static const char classErrorMsg[] = "Can't find class \"%s\"";
+static const char methodErrorMsg[] = "Can't find method \"%s%s\"";
+
+static void accuracyChanged(JNIEnv * /*env*/, jobject /*thiz*/, jint sensor, jint accuracy)
+{
+ listenersLocker.lockForRead();
+ foreach (AndroidSensors::AndroidSensorsListenerInterface *listener, listenersHash[sensor])
+ listener->onAccuracyChanged(accuracy);
+ listenersLocker.unlock();
+}
+
+static void sensorChanged(JNIEnv *env, jobject /*thiz*/, jint sensor, jlong timeStamp, jfloatArray array)
+{
+ uint size = env->GetArrayLength(array);
+ jfloat *values = env->GetFloatArrayElements(array, 0);
+ listenersLocker.lockForRead();
+ foreach (AndroidSensors::AndroidSensorsListenerInterface *listener, listenersHash[sensor])
+ listener->onSensorChanged(timeStamp, values, size);
+ listenersLocker.unlock();
+ env->ReleaseFloatArrayElements(array, values, JNI_ABORT); // don't copy back the elements
+
+}
+
+static JNINativeMethod methods[] = {
+ {"accuracyChanged", "(II)V", (void *)accuracyChanged},
+ {"sensorChanged", "(IJ[F)V", (void *)sensorChanged}
+};
+
+#define FIND_AND_CHECK_CLASS(CLASS_NAME) \
+clazz = env->FindClass(CLASS_NAME); \
+if (!clazz) { \
+ __android_log_print(ANDROID_LOG_FATAL, logTag, classErrorMsg, CLASS_NAME); \
+ return JNI_FALSE; \
+}
+
+#define GET_AND_CHECK_STATIC_METHOD(VAR, CLASS, METHOD_NAME, METHOD_SIGNATURE) \
+VAR = env->GetStaticMethodID(CLASS, METHOD_NAME, METHOD_SIGNATURE); \
+if (!VAR) { \
+ __android_log_print(ANDROID_LOG_FATAL, logTag, methodErrorMsg, METHOD_NAME, METHOD_SIGNATURE); \
+ return JNI_FALSE; \
+}
+
+static bool registerNatives(JNIEnv *env)
+{
+ jclass clazz;
+ FIND_AND_CHECK_CLASS("org/qtproject/qt5/android/sensors/QtSensors");
+ sensorsClass = static_cast<jclass>(env->NewGlobalRef(clazz));
+
+ if (env->RegisterNatives(sensorsClass, methods, sizeof(methods) / sizeof(methods[0])) < 0) {
+ __android_log_print(ANDROID_LOG_FATAL, logTag, "RegisterNatives failed");
+ return JNI_FALSE;
+ }
+
+ GET_AND_CHECK_STATIC_METHOD(getSensorListMethodId, sensorsClass, "getSensorList", "()[I");
+ GET_AND_CHECK_STATIC_METHOD(registerSensorMethodId, sensorsClass, "registerSensor", "(II)Z");
+ GET_AND_CHECK_STATIC_METHOD(unregisterSensorMethodId, sensorsClass, "unregisterSensor", "(I)Z");
+ GET_AND_CHECK_STATIC_METHOD(getSensorDescriptionMethodId, sensorsClass, "getSensorDescription", "(I)Ljava/lang/String;");
+
+ return true;
+}
+
+Q_DECL_EXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void * /*reserved*/)
+{
+ typedef union {
+ JNIEnv *nativeEnvironment;
+ void *venv;
+ } UnionJNIEnvToVoid;
+
+ __android_log_print(ANDROID_LOG_INFO, logTag, "Sensors start");
+ UnionJNIEnvToVoid uenv;
+ uenv.venv = NULL;
+ javaVM = 0;
+
+ if (vm->GetEnv(&uenv.venv, JNI_VERSION_1_4) != JNI_OK) {
+ __android_log_print(ANDROID_LOG_FATAL, logTag, "GetEnv failed");
+ return -1;
+ }
+ JNIEnv *env = uenv.nativeEnvironment;
+ if (!registerNatives(env)) {
+ __android_log_print(ANDROID_LOG_FATAL, logTag, "registerNatives failed");
+ return -1;
+ }
+
+ javaVM = vm;
+ return JNI_VERSION_1_4;
+}
diff --git a/src/plugins/sensors/android/src/androidjnisensors.h b/src/plugins/sensors/android/src/androidjnisensors.h
new file mode 100644
index 00000000..53ca58d0
--- /dev/null
+++ b/src/plugins/sensors/android/src/androidjnisensors.h
@@ -0,0 +1,83 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 BogDan Vatra <bogdan@kde.org>
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtSensors module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef ANDROIDJNISENSORS_H
+#define ANDROIDJNISENSORS_H
+
+#include <jni.h>
+
+#include <QtCore/QVector>
+#include <QtCore/QString>
+
+namespace AndroidSensors
+{
+ // must be in sync with https://developer.android.com/reference/android/hardware/Sensor.html#TYPE_ACCELEROMETER
+ enum AndroidSensorType
+ {
+ TYPE_ACCELEROMETER = 1,
+ TYPE_AMBIENT_TEMPERATURE = 13,
+ TYPE_GRAVITY = 9,
+ TYPE_GYROSCOPE = 4,
+ TYPE_LIGHT = 5,
+ TYPE_LINEAR_ACCELERATION = 10,
+ TYPE_MAGNETIC_FIELD = 2,
+ TYPE_ORIENTATION = 3, //This constant was deprecated in API level 8. use SensorManager.getOrientation() instead.
+ TYPE_PRESSURE = 6,
+ TYPE_PROXIMITY = 8,
+ TYPE_RELATIVE_HUMIDITY = 12,
+ TYPE_ROTATION_VECTOR = 11,
+ TYPE_TEMPERATURE = 7 //This constant was deprecated in API level 14. use Sensor.TYPE_AMBIENT_TEMPERATURE instead.
+ };
+
+ struct AndroidSensorsListenerInterface
+ {
+ virtual ~AndroidSensorsListenerInterface() {}
+ virtual void onAccuracyChanged(jint accuracy) = 0;
+ virtual void onSensorChanged(jlong timestamp, const jfloat *values, uint size) = 0;
+ };
+
+ QVector<AndroidSensorType> availableSensors();
+ QString sensorDescription(AndroidSensorType sensor);
+ bool registerListener(AndroidSensorType sensor, AndroidSensorsListenerInterface *listener, int dataRate = 0);
+ bool unregisterListener(AndroidSensorType sensor, AndroidSensorsListenerInterface *listener);
+}
+
+#endif // ANDROIDJNISENSORS_H
diff --git a/src/plugins/sensors/android/src/androidlight.cpp b/src/plugins/sensors/android/src/androidlight.cpp
new file mode 100644
index 00000000..42295e54
--- /dev/null
+++ b/src/plugins/sensors/android/src/androidlight.cpp
@@ -0,0 +1,62 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 BogDan Vatra <bogdan@kde.org>
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtSensors module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "androidlight.h"
+
+AndroidLight::AndroidLight(AndroidSensors::AndroidSensorType type, QSensor *sensor)
+ : AndroidCommonSensor<QLightReading>(type, sensor)
+{}
+
+
+void AndroidLight::onAccuracyChanged(jint accuracy)
+{
+ Q_UNUSED(accuracy)
+}
+
+void AndroidLight::onSensorChanged(jlong timestamp, const jfloat *values, uint size)
+{
+ if (size < 1)
+ return;
+ m_reader.setTimestamp(timestamp);
+ // check https://developer.android.com/reference/android/hardware/SensorEvent.html#values
+ m_reader.setLux(values[0]);
+ newReadingAvailable();
+}
diff --git a/src/plugins/sensors/android/src/androidlight.h b/src/plugins/sensors/android/src/androidlight.h
new file mode 100644
index 00000000..fdea3edb
--- /dev/null
+++ b/src/plugins/sensors/android/src/androidlight.h
@@ -0,0 +1,57 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 BogDan Vatra <bogdan@kde.org>
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtSensors module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef ANDROIDLIGHT_H
+#define ANDROIDLIGHT_H
+#include <qlightsensor.h>
+
+#include "androidcommonsensor.h"
+
+class AndroidLight : public AndroidCommonSensor<QLightReading>
+{
+public:
+ AndroidLight(AndroidSensors::AndroidSensorType type, QSensor *sensor);
+private:
+ virtual void onAccuracyChanged(jint accuracy);
+ virtual void onSensorChanged(jlong timestamp, const jfloat *values, uint size);
+};
+
+#endif // ANDROIDLIGHT_H
diff --git a/src/plugins/sensors/android/src/androidmagnetometer.cpp b/src/plugins/sensors/android/src/androidmagnetometer.cpp
new file mode 100644
index 00000000..9175f584
--- /dev/null
+++ b/src/plugins/sensors/android/src/androidmagnetometer.cpp
@@ -0,0 +1,63 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 BogDan Vatra <bogdan@kde.org>
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtSensors module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "androidmagnetometer.h"
+
+AndroidMagnetometer::AndroidMagnetometer(AndroidSensors::AndroidSensorType type, QSensor *sensor)
+ :AndroidCommonSensor<QMagnetometerReading>(type, sensor)
+{}
+
+void AndroidMagnetometer::onAccuracyChanged(jint accuracy)
+{
+ m_reader.setCalibrationLevel(accuracy);
+}
+
+void AndroidMagnetometer::onSensorChanged(jlong timestamp, const jfloat *values, uint size)
+{
+ if (size<3)
+ return;
+ m_reader.setTimestamp(timestamp);
+ // check https://developer.android.com/reference/android/hardware/SensorEvent.html#values
+ m_reader.setX(values[0]/1e6);
+ m_reader.setY(values[1]/1e6);
+ m_reader.setZ(values[2]/1e6);
+ newReadingAvailable();
+}
diff --git a/src/plugins/sensors/android/src/androidmagnetometer.h b/src/plugins/sensors/android/src/androidmagnetometer.h
new file mode 100644
index 00000000..57d9f36d
--- /dev/null
+++ b/src/plugins/sensors/android/src/androidmagnetometer.h
@@ -0,0 +1,57 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 BogDan Vatra <bogdan@kde.org>
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtSensors module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef ANDROIDMAGNETOMETER_H
+#define ANDROIDMAGNETOMETER_H
+#include <qmagnetometer.h>
+
+#include "androidcommonsensor.h"
+
+class AndroidMagnetometer : public AndroidCommonSensor<QMagnetometerReading>
+{
+public:
+ AndroidMagnetometer(AndroidSensors::AndroidSensorType type, QSensor *sensor);
+private:
+ virtual void onAccuracyChanged(jint accuracy);
+ virtual void onSensorChanged(jlong timestamp, const jfloat *values, uint size);
+};
+
+#endif // ANDROIDMAGNETOMETER_H
diff --git a/src/plugins/sensors/android/src/androidrotation.cpp b/src/plugins/sensors/android/src/androidrotation.cpp
new file mode 100644
index 00000000..602575fe
--- /dev/null
+++ b/src/plugins/sensors/android/src/androidrotation.cpp
@@ -0,0 +1,65 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 BogDan Vatra <bogdan@kde.org>
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtSensors module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "androidrotation.h"
+#include <math.h>
+
+AndroidRotation::AndroidRotation(AndroidSensors::AndroidSensorType type, QSensor *sensor)
+ : AndroidCommonSensor<QRotationReading>(type, sensor)
+{}
+
+void AndroidRotation::onAccuracyChanged(jint accuracy)
+{
+ Q_UNUSED(accuracy)
+}
+
+void AndroidRotation::onSensorChanged(jlong timestamp, const jfloat *values, uint size)
+{
+ if (size < 3)
+ return;
+ m_reader.setTimestamp(timestamp);
+
+ float rz = -values[0]*180/M_PI;
+ float rx = -values[1]*180/M_PI;
+ float ry = values[2]*180/M_PI;
+ m_reader.setFromEuler(rx, ry, rz);
+ newReadingAvailable();
+}
diff --git a/src/plugins/sensors/android/src/androidrotation.h b/src/plugins/sensors/android/src/androidrotation.h
new file mode 100644
index 00000000..cd2c4d65
--- /dev/null
+++ b/src/plugins/sensors/android/src/androidrotation.h
@@ -0,0 +1,56 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 BogDan Vatra <bogdan@kde.org>
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtSensors module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef ANDROIDROTATION_H
+#define ANDROIDROTATION_H
+#include <qrotationsensor.h>
+
+#include "androidcommonsensor.h"
+class AndroidRotation : public AndroidCommonSensor<QRotationReading>
+{
+public:
+ AndroidRotation(AndroidSensors::AndroidSensorType type, QSensor *sensor);
+private:
+ virtual void onAccuracyChanged(jint accuracy);
+ virtual void onSensorChanged(jlong timestamp, const jfloat *values, uint size);
+};
+
+#endif // ANDROIDROTATION_H
diff --git a/src/plugins/sensors/android/src/main.cpp b/src/plugins/sensors/android/src/main.cpp
new file mode 100644
index 00000000..0cb4de49
--- /dev/null
+++ b/src/plugins/sensors/android/src/main.cpp
@@ -0,0 +1,135 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 BogDan Vatra <bogdan@kde.org>
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtSensors module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <qplugin.h>
+#include <qsensorplugin.h>
+#include <qsensorbackend.h>
+#include <qsensormanager.h>
+#include "androidaccelerometer.h"
+#include "androidgyroscope.h"
+#include "androidlight.h"
+#include "androidmagnetometer.h"
+#include "androidrotation.h"
+
+using namespace AndroidSensors;
+
+class AndroidSensorPlugin : public QObject, public QSensorPluginInterface, public QSensorBackendFactory
+{
+ Q_OBJECT
+ Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QSensorPluginInterface/1.0" FILE "plugin.json")
+ Q_INTERFACES(QSensorPluginInterface)
+public:
+ void registerSensors()
+ {
+ foreach (AndroidSensorType sensor, availableSensors()) {
+ switch (sensor) {
+ case TYPE_ACCELEROMETER:
+ QSensorManager::registerBackend(QAccelerometer::type, QByteArray::number(sensor), this);
+ break;
+ case TYPE_AMBIENT_TEMPERATURE:
+ case TYPE_TEMPERATURE:
+ break; // add the temperature sensor backend
+ case TYPE_GRAVITY:
+ break; // add the gravity sensor backend
+ case TYPE_GYROSCOPE:
+ QSensorManager::registerBackend(QGyroscope::type, QByteArray::number(sensor), this);
+ break;
+ case TYPE_LIGHT:
+ QSensorManager::registerBackend(QLightSensor::type, QByteArray::number(sensor), this);
+ break; // add the light sensor backend
+ case TYPE_LINEAR_ACCELERATION:
+ break; // add the linear acceleration sensor backend
+ case TYPE_MAGNETIC_FIELD:
+ QSensorManager::registerBackend(QMagnetometer::type, QByteArray::number(sensor), this);
+ break;
+ case TYPE_ORIENTATION:
+ break; // add the orientation sensor backend
+ case TYPE_PRESSURE:
+ break; // add the pressure sensor backend
+ case TYPE_PROXIMITY:
+ break; // add the proximity sensor backend
+ case TYPE_RELATIVE_HUMIDITY:
+ break; // add the relative humidity sensor backend
+ case TYPE_ROTATION_VECTOR:
+ QSensorManager::registerBackend(QRotationSensor::type, QByteArray::number(sensor), this);
+ break;
+ }
+ }
+ }
+
+ QSensorBackend *createBackend(QSensor *sensor)
+ {
+ AndroidSensorType type = static_cast<AndroidSensorType>(sensor->identifier().toInt());
+ switch (type) {
+ case TYPE_ACCELEROMETER:
+ return new AndroidAccelerometer(type, sensor);
+ case TYPE_AMBIENT_TEMPERATURE:
+ case TYPE_TEMPERATURE:
+ break; // add the temperature sensor backend
+ case TYPE_GRAVITY:
+ break; // add the gravity sensor backend
+ case TYPE_GYROSCOPE:
+ return new AndroidGyroscope(type, sensor);
+ case TYPE_LIGHT:
+ return new AndroidLight(type, sensor);
+ case TYPE_LINEAR_ACCELERATION:
+ break; // add the linear acceleration sensor backend
+ case TYPE_MAGNETIC_FIELD:
+ return new AndroidMagnetometer(type, sensor);
+ case TYPE_ORIENTATION:
+ break; // add the orientation sensor backend
+ case TYPE_PRESSURE:
+ break; // add the pressure sensor backend
+ case TYPE_PROXIMITY:
+ break; // add the proximity sensor backend
+ case TYPE_RELATIVE_HUMIDITY:
+ break; // add the relative humidity sensor backend
+ case TYPE_ROTATION_VECTOR:
+ return new AndroidRotation(type, sensor);
+ }
+ return 0;
+ }
+};
+
+Q_IMPORT_PLUGIN (AndroidSensorPlugin) // automatically register the plugin
+
+#include "main.moc"
+
diff --git a/src/plugins/sensors/android/src/plugin.json b/src/plugins/sensors/android/src/plugin.json
new file mode 100644
index 00000000..8a55b3ae
--- /dev/null
+++ b/src/plugins/sensors/android/src/plugin.json
@@ -0,0 +1 @@
+{ "Keys": [ "notused" ] }
diff --git a/src/plugins/sensors/android/src/src.pro b/src/plugins/sensors/android/src/src.pro
new file mode 100644
index 00000000..715a0111
--- /dev/null
+++ b/src/plugins/sensors/android/src/src.pro
@@ -0,0 +1,29 @@
+TARGET = qtsensors_android
+QT = sensors core
+
+PLUGIN_TYPE = sensors
+load(qt_plugin)
+
+# STATICPLUGIN needed because there's a Q_IMPORT_PLUGIN in main.cpp
+# Yes, the plugin imports itself statically
+DEFINES += QT_STATICPLUGIN
+
+HEADERS = \
+ androidjnisensors.h \
+ androidaccelerometer.h \
+ androidcommonsensor.h \
+ androidgyroscope.h \
+ androidmagnetometer.h \
+ androidrotation.h \
+ androidlight.h
+
+SOURCES = \
+ main.cpp \
+ androidjnisensors.cpp \
+ androidaccelerometer.cpp \
+ androidgyroscope.cpp \
+ androidmagnetometer.cpp \
+ androidrotation.cpp \
+ androidlight.cpp
+
+OTHER_FILES = plugin.json
diff --git a/src/plugins/sensors/blackberry/bbaccelerometer.cpp b/src/plugins/sensors/blackberry/bbaccelerometer.cpp
index dcbd7fcc..0826cf7a 100644
--- a/src/plugins/sensors/blackberry/bbaccelerometer.cpp
+++ b/src/plugins/sensors/blackberry/bbaccelerometer.cpp
@@ -44,6 +44,12 @@ BbAccelerometer::BbAccelerometer(QSensor *sensor)
: BbSensorBackend<QAccelerometerReading>(devicePath(), SENSOR_TYPE_ACCELEROMETER, sensor)
{
setDescription(QLatin1String("X, Y, and Z axes accelerations in m/s^2"));
+
+ QAccelerometer * const accelerometer = qobject_cast<QAccelerometer *>(sensor);
+ if (accelerometer) {
+ connect(accelerometer, SIGNAL(accelerationModeChanged(AccelerationMode)),
+ this, SLOT(applyAccelerationMode()));
+ }
}
bool BbAccelerometer::updateReadingFromEvent(const sensor_event_t &event, QAccelerometerReading *reading)
@@ -58,7 +64,39 @@ bool BbAccelerometer::updateReadingFromEvent(const sensor_event_t &event, QAccel
return true;
}
+void BbAccelerometer::start()
+{
+ applyAccelerationMode();
+ BbSensorBackend<QAccelerometerReading>::start();
+}
+
QString BbAccelerometer::devicePath()
{
return QLatin1String("/dev/sensor/accel");
}
+
+void BbAccelerometer::applyAccelerationMode()
+{
+ const QAccelerometer * const accelerometer = qobject_cast<QAccelerometer *>(sensor());
+ if (accelerometer) {
+ QString fileName;
+ sensor_type_e sensorType;
+ switch (accelerometer->accelerationMode()) {
+ case QAccelerometer::Gravity:
+ fileName = QLatin1String("/dev/sensor/gravity");
+ sensorType = SENSOR_TYPE_GRAVITY;
+ break;
+ case QAccelerometer::User:
+ fileName = QLatin1String("/dev/sensor/linAccel");
+ sensorType = SENSOR_TYPE_LINEAR_ACCEL;
+ break;
+ default:
+ case QAccelerometer::Combined:
+ fileName = devicePath();
+ sensorType = SENSOR_TYPE_ACCELEROMETER;
+ break;
+ }
+
+ setDevice(fileName, sensorType);
+ }
+}
diff --git a/src/plugins/sensors/blackberry/bbaccelerometer.h b/src/plugins/sensors/blackberry/bbaccelerometer.h
index aa47873c..3071c801 100644
--- a/src/plugins/sensors/blackberry/bbaccelerometer.h
+++ b/src/plugins/sensors/blackberry/bbaccelerometer.h
@@ -51,10 +51,14 @@ class BbAccelerometer : public BbSensorBackend<QAccelerometerReading>
public:
explicit BbAccelerometer(QSensor *sensor);
+ void start() Q_DECL_OVERRIDE;
static QString devicePath();
protected:
bool updateReadingFromEvent(const sensor_event_t &event, QAccelerometerReading *reading) Q_DECL_OVERRIDE;
+
+private Q_SLOTS:
+ void applyAccelerationMode();
};
#endif
diff --git a/src/plugins/sensors/blackberry/bbaltimeter.cpp b/src/plugins/sensors/blackberry/bbaltimeter.cpp
index 07aa2646..3d21ef32 100644
--- a/src/plugins/sensors/blackberry/bbaltimeter.cpp
+++ b/src/plugins/sensors/blackberry/bbaltimeter.cpp
@@ -40,36 +40,13 @@
****************************************************************************/
#include "bbaltimeter.h"
-class BbAltimeterReadingPrivate
-{
-public:
- BbAltimeterReadingPrivate()
- : altitude(0)
- {
- }
-
- qreal altitude;
-};
-
-IMPLEMENT_READING(BbAltimeterReading)
-
-qreal BbAltimeterReading::altitude() const
-{
- return d->altitude;
-}
-
-void BbAltimeterReading::setAltitude(qreal altitude)
-{
- d->altitude = altitude;
-}
-
BbAltimeter::BbAltimeter(QSensor *sensor)
- : BbSensorBackend<BbAltimeterReading>(devicePath(), SENSOR_TYPE_ALTIMETER, sensor)
+ : BbSensorBackend<QAltimeterReading>(devicePath(), SENSOR_TYPE_ALTIMETER, sensor)
{
setDescription(QLatin1String("Altitude in meters relative to mean sea level"));
}
-bool BbAltimeter::updateReadingFromEvent(const sensor_event_t &event, BbAltimeterReading *reading)
+bool BbAltimeter::updateReadingFromEvent(const sensor_event_t &event, QAltimeterReading *reading)
{
reading->setAltitude(event.altitude_s.altitude);
return true;
diff --git a/src/plugins/sensors/blackberry/bbaltimeter.h b/src/plugins/sensors/blackberry/bbaltimeter.h
index 4744a3ff..b369c6cb 100644
--- a/src/plugins/sensors/blackberry/bbaltimeter.h
+++ b/src/plugins/sensors/blackberry/bbaltimeter.h
@@ -42,20 +42,9 @@
#define BBALTIMETER_H
#include "bbsensorbackend.h"
+#include <qaltimeter.h>
-class BbAltimeterReadingPrivate;
-
-class BbAltimeterReading : public QSensorReading
-{
- Q_OBJECT
- Q_PROPERTY(qreal altitude READ altitude)
- DECLARE_READING(BbAltimeterReading)
-public:
- qreal altitude() const;
- void setAltitude(qreal altitude);
-};
-
-class BbAltimeter : public BbSensorBackend<BbAltimeterReading>
+class BbAltimeter : public BbSensorBackend<QAltimeterReading>
{
Q_OBJECT
@@ -65,7 +54,7 @@ public:
static QString devicePath();
protected:
- bool updateReadingFromEvent(const sensor_event_t &event, BbAltimeterReading *reading) Q_DECL_OVERRIDE;
+ bool updateReadingFromEvent(const sensor_event_t &event, QAltimeterReading *reading) Q_DECL_OVERRIDE;
};
#endif
diff --git a/src/plugins/sensors/blackberry/bbcompass.cpp b/src/plugins/sensors/blackberry/bbcompass.cpp
index 6e33d1a3..df8cc2e1 100644
--- a/src/plugins/sensors/blackberry/bbcompass.cpp
+++ b/src/plugins/sensors/blackberry/bbcompass.cpp
@@ -55,19 +55,28 @@ BbCompass::BbCompass(QSensor *sensor)
bool BbCompass::updateReadingFromEvent(const sensor_event_t &event, QCompassReading *reading)
{
+ float azimuth;
#ifdef HAVE_COMPASS_SENSOR
- reading->setAzimuth(event.compass_s.azimuth);
+ azimuth = event.compass_s.azimuth;
#else
float xRad, yRad, zRad;
matrixToEulerZXY(event.rotation_matrix, xRad, yRad, zRad);
- float azimuth = radiansToDegrees(zRad);
+ azimuth = radiansToDegrees(zRad);
if (azimuth < 0)
azimuth = -azimuth;
else
azimuth = 360.0f - azimuth;
- reading->setAzimuth(azimuth);
#endif
+ if (isAutoAxisRemappingEnabled()) {
+ azimuth += orientationForRemapping();
+ if (azimuth >= 360.0f)
+ azimuth -= 360.0f;
+ }
+
+ reading->setAzimuth(azimuth);
+
+
switch (event.accuracy) {
case SENSOR_ACCURACY_UNRELIABLE:
reading->setCalibrationLevel(0.0f);
diff --git a/src/plugins/sensors/blackberry/bbholstersensor.cpp b/src/plugins/sensors/blackberry/bbholstersensor.cpp
new file mode 100644
index 00000000..53888f58
--- /dev/null
+++ b/src/plugins/sensors/blackberry/bbholstersensor.cpp
@@ -0,0 +1,58 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Research In Motion
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtSensors module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include "bbholstersensor.h"
+
+BbHolsterSensor::BbHolsterSensor(QSensor *sensor)
+ : BbSensorBackend<QHolsterReading>(devicePath(), SENSOR_TYPE_HOLSTER, sensor)
+{
+ setDescription(QLatin1String("Whether the device is holstered or not"));
+}
+
+bool BbHolsterSensor::updateReadingFromEvent(const sensor_event_t &event, QHolsterReading *reading)
+{
+ reading->setHolstered(event.holster_s.holstered == 1);
+ return true;
+}
+
+QString BbHolsterSensor::devicePath()
+{
+ return QLatin1String("/dev/sensor/holster");
+}
diff --git a/src/plugins/sensors/blackberry/bbholstersensor.h b/src/plugins/sensors/blackberry/bbholstersensor.h
new file mode 100644
index 00000000..b33b391d
--- /dev/null
+++ b/src/plugins/sensors/blackberry/bbholstersensor.h
@@ -0,0 +1,60 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Research In Motion
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtSensors module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#ifndef BBHOLSTERSENSOR_H
+#define BBHOLSTERSENSOR_H
+
+#include "bbsensorbackend.h"
+#include <qholstersensor.h>
+
+class BbHolsterSensor : public BbSensorBackend<QHolsterReading>
+{
+ Q_OBJECT
+
+public:
+ explicit BbHolsterSensor(QSensor *sensor);
+
+ static QString devicePath();
+
+protected:
+ bool updateReadingFromEvent(const sensor_event_t &event, QHolsterReading *reading) Q_DECL_OVERRIDE;
+};
+
+#endif
diff --git a/src/plugins/sensors/blackberry/bbmagnetometer.cpp b/src/plugins/sensors/blackberry/bbmagnetometer.cpp
index 489a0481..45fd49b3 100644
--- a/src/plugins/sensors/blackberry/bbmagnetometer.cpp
+++ b/src/plugins/sensors/blackberry/bbmagnetometer.cpp
@@ -53,17 +53,11 @@ QString BbMagnetometer::devicePath()
bool BbMagnetometer::updateReadingFromEvent(const sensor_event_t &event, QMagnetometerReading *reading)
{
- // TODO: In the future, support returnGeoValues here. Right now, /dev/sensors/mag has no
- // geomagnatic mode, but will gain it in the future.
- float x = convertValue(event.motion.dsp.x);
- float y = convertValue(event.motion.dsp.y);
- float z = convertValue(event.motion.dsp.z);
- remapAxes(&x, &y, &z);
- reading->setX(x);
- reading->setY(y);
- reading->setZ(z);
+ float x, y, z;
- const bool returnGeoValues = sensor()->property("returnGeoValues").toBool();
+ QMagnetometer * const magnetometer = qobject_cast<QMagnetometer *>(sensor());
+ Q_ASSERT(magnetometer);
+ const bool returnGeoValues = magnetometer->returnGeoValues();
if (returnGeoValues) {
switch (event.accuracy) {
case SENSOR_ACCURACY_UNRELIABLE: reading->setCalibrationLevel(0.0f); break;
@@ -76,10 +70,30 @@ bool BbMagnetometer::updateReadingFromEvent(const sensor_event_t &event, QMagnet
case SENSOR_ACCURACY_MEDIUM: reading->setCalibrationLevel(1.0f); break;
case SENSOR_ACCURACY_HIGH: reading->setCalibrationLevel(1.0f); break;
}
+
+ x = convertValue(event.motion.dsp.x);
+ y = convertValue(event.motion.dsp.y);
+ z = convertValue(event.motion.dsp.z);
+
} else {
reading->setCalibrationLevel(1.0f);
+
+#ifndef Q_OS_BLACKBERRY_TABLET
+ x = convertValue(event.motion.raw.x);
+ y = convertValue(event.motion.raw.y);
+ z = convertValue(event.motion.raw.z);
+#else
+ // Blackberry Tablet OS does not support raw reading values
+ x = convertValue(event.motion.dsp.x);
+ y = convertValue(event.motion.dsp.y);
+ z = convertValue(event.motion.dsp.z);
+#endif
}
+ remapAxes(&x, &y, &z);
+ reading->setX(x);
+ reading->setY(y);
+ reading->setZ(z);
return true;
}
diff --git a/src/plugins/sensors/blackberry/bborientationsensor.cpp b/src/plugins/sensors/blackberry/bborientationsensor.cpp
index 68ed735b..3d9d120c 100644
--- a/src/plugins/sensors/blackberry/bborientationsensor.cpp
+++ b/src/plugins/sensors/blackberry/bborientationsensor.cpp
@@ -44,6 +44,9 @@ BbOrientationSensor::BbOrientationSensor(QSensor *sensor)
: BbSensorBackend<QOrientationReading>(devicePath(), SENSOR_TYPE_ORIENTATION, sensor)
{
setDescription(QLatin1String("Device orientation"));
+
+ // Orientation rarely changes, so enable skipping of duplicates by default
+ sensor->setSkipDuplicates(true);
}
QString BbOrientationSensor::devicePath()
@@ -51,19 +54,6 @@ QString BbOrientationSensor::devicePath()
return QLatin1String("/dev/sensor/orientation");
}
-void BbOrientationSensor::start()
-{
- BbSensorBackend<QOrientationReading>::start();
-
- // Orientation rarely changes, so enable skiping of duplicates
- sensor_devctl_skipdupevent_u deviceSkip;
- deviceSkip.tx.enable = 1;
- const int result = devctl(deviceFile().handle(), DCMD_SENSOR_SKIPDUPEVENT, &deviceSkip,
- sizeof(deviceSkip), NULL);
- if (result != EOK)
- perror("Enabling duplicate skipping for orientation sensor failed");
-}
-
void BbOrientationSensor::additionalDeviceInit()
{
// When querying the OS service for the range, it gives us the angles, which we don't need.
diff --git a/src/plugins/sensors/blackberry/bborientationsensor.h b/src/plugins/sensors/blackberry/bborientationsensor.h
index 07dc3d0f..85c7bd67 100644
--- a/src/plugins/sensors/blackberry/bborientationsensor.h
+++ b/src/plugins/sensors/blackberry/bborientationsensor.h
@@ -53,7 +53,6 @@ public:
static QString devicePath();
- void start() Q_DECL_OVERRIDE;
void additionalDeviceInit() Q_DECL_OVERRIDE;
bool addDefaultRange() Q_DECL_OVERRIDE;
diff --git a/src/plugins/sensors/blackberry/bbpressuresensor.cpp b/src/plugins/sensors/blackberry/bbpressuresensor.cpp
index 01a2493b..8cb9b1ea 100644
--- a/src/plugins/sensors/blackberry/bbpressuresensor.cpp
+++ b/src/plugins/sensors/blackberry/bbpressuresensor.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2012 Research In Motion
+** Copyright (C) 2013 Research In Motion
** Contact: http://www.qt-project.org/legal
**
** This file is part of the QtSensors module of the Qt Toolkit.
@@ -40,31 +40,8 @@
****************************************************************************/
#include "bbpressuresensor.h"
-class BbPressureReadingPrivate
-{
-public:
- BbPressureReadingPrivate()
- : pressure(0)
- {
- }
-
- qreal pressure;
-};
-
-IMPLEMENT_READING(BbPressureReading)
-
-qreal BbPressureReading::pressure() const
-{
- return d->pressure;
-}
-
-void BbPressureReading::setPressure(qreal pressure)
-{
- d->pressure = pressure;
-}
-
BbPressureSensor::BbPressureSensor(QSensor *sensor)
- : BbSensorBackend<BbPressureReading>(devicePath(), SENSOR_TYPE_PRESSURE, sensor)
+ : BbSensorBackend<QPressureReading>(devicePath(), SENSOR_TYPE_PRESSURE, sensor)
{
setDescription(QLatin1String("Pressure in Pascals"));
}
@@ -74,7 +51,7 @@ QString BbPressureSensor::devicePath()
return QLatin1String("/dev/sensor/pressure");
}
-bool BbPressureSensor::updateReadingFromEvent(const sensor_event_t &event, BbPressureReading *reading)
+bool BbPressureSensor::updateReadingFromEvent(const sensor_event_t &event, QPressureReading *reading)
{
// TODO: I was unable to test this since the device I was testing this with did not have
// a pressure sensor. Verify that this works and check that the units are correct.
diff --git a/src/plugins/sensors/blackberry/bbpressuresensor.h b/src/plugins/sensors/blackberry/bbpressuresensor.h
index 833832c4..7531bd68 100644
--- a/src/plugins/sensors/blackberry/bbpressuresensor.h
+++ b/src/plugins/sensors/blackberry/bbpressuresensor.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2012 Research In Motion
+** Copyright (C) 2013 Research In Motion
** Contact: http://www.qt-project.org/legal
**
** This file is part of the QtSensors module of the Qt Toolkit.
@@ -42,20 +42,9 @@
#define BBPRESSURESENSOR_H
#include "bbsensorbackend.h"
+#include <qpressuresensor.h>
-class BbPressureReadingPrivate;
-
-class BbPressureReading : public QSensorReading
-{
- Q_OBJECT
- Q_PROPERTY(qreal pressure READ pressure)
- DECLARE_READING(BbPressureReading)
-public:
- qreal pressure() const;
- void setPressure(qreal pressure);
-};
-
-class BbPressureSensor : public BbSensorBackend<BbPressureReading>
+class BbPressureSensor : public BbSensorBackend<QPressureReading>
{
Q_OBJECT
@@ -65,7 +54,7 @@ public:
static QString devicePath();
protected:
- bool updateReadingFromEvent(const sensor_event_t &event, BbPressureReading *reading) Q_DECL_OVERRIDE;
+ bool updateReadingFromEvent(const sensor_event_t &event, QPressureReading *reading) Q_DECL_OVERRIDE;
};
#endif
diff --git a/src/plugins/sensors/blackberry/bbproximitysensor.cpp b/src/plugins/sensors/blackberry/bbproximitysensor.cpp
index 79f3834a..1177f744 100644
--- a/src/plugins/sensors/blackberry/bbproximitysensor.cpp
+++ b/src/plugins/sensors/blackberry/bbproximitysensor.cpp
@@ -53,9 +53,6 @@ QString BbProximitySensor::devicePath()
bool BbProximitySensor::updateReadingFromEvent(const sensor_event_t &event, QProximityReading *reading)
{
- // TODO: I was unable to test this since the device I was testing this with did not have
- // a proximity sensor. Verify that this works, check that the units are correct
- // and that the threshold makes sense.
const qreal minProximity = sensor()->outputRanges().first().minimum;
reading->setClose(event.proximity_s.distance <= minProximity);
return true;
diff --git a/src/plugins/sensors/blackberry/bbsensorbackend.cpp b/src/plugins/sensors/blackberry/bbsensorbackend.cpp
index fa8c89be..6b614a8a 100644
--- a/src/plugins/sensors/blackberry/bbsensorbackend.cpp
+++ b/src/plugins/sensors/blackberry/bbsensorbackend.cpp
@@ -81,15 +81,17 @@ static void remapMatrix(const float inputMatrix[3*3],
BbSensorBackendBase::BbSensorBackendBase(const QString &devicePath, sensor_type_e sensorType,
QSensor *sensor)
: QSensorBackend(sensor), m_deviceFile(devicePath), m_sensorType(sensorType), m_guiHelper(0),
- m_started(false)
+ m_started(false), m_applyingBufferSize(false)
{
m_mappingMatrix[0] = m_mappingMatrix[3] = 1;
m_mappingMatrix[1] = m_mappingMatrix[2] = 0;
connect(sensor, SIGNAL(alwaysOnChanged()), this, SLOT(applyAlwaysOnProperty()));
+ connect(sensor, SIGNAL(bufferSizeChanged(int)), this, SLOT(applyBuffering()));
+ connect(sensor, SIGNAL(userOrientationChanged(int)), this, SLOT(updateOrientation()));
// Set some sensible default values
- sensor->setProperty("efficientBufferSize", defaultBufferSize);
- sensor->setProperty("maxBufferSize", defaultBufferSize);
+ sensor->setEfficientBufferSize(defaultBufferSize);
+ sensor->setMaxBufferSize(defaultBufferSize);
}
BbGuiHelper *BbSensorBackendBase::guiHelper() const
@@ -107,12 +109,40 @@ sensor_type_e BbSensorBackendBase::sensorType() const
return m_sensorType;
}
+void BbSensorBackendBase::setDevice(const QString &deviceFile, sensor_type_e sensorType)
+{
+ if (deviceFile != m_deviceFile.fileName()) {
+ setPaused(true);
+ delete m_socketNotifier.take();
+ m_deviceFile.close();
+
+ m_sensorType = sensorType;
+ m_deviceFile.setFileName(deviceFile);
+ initSensorInfo();
+ if (m_started)
+ start(); // restart with new device file
+ }
+}
+
void BbSensorBackendBase::initSensorInfo()
{
if (!m_deviceFile.open(QFile::ReadOnly | QFile::Unbuffered)) {
qDebug() << "Failed to open sensor" << m_deviceFile.fileName()
<< ":" << m_deviceFile.errorString();
} else {
+
+ // Explicitly switch to non-blocking mode, otherwise read() will wait until new sensor
+ // data is available, and we have no way to check if there is more data or not (bytesAvailable()
+ // does not work for unbuffered mode)
+ const int oldFlags = fcntl(m_deviceFile.handle(), F_GETFL);
+ if (fcntl(m_deviceFile.handle(), F_SETFL, oldFlags | O_NONBLOCK) == -1) {
+ perror(QString::fromLatin1("Starting sensor %1 failed, fcntl() returned -1")
+ .arg(m_deviceFile.fileName()).toLocal8Bit());
+ sensorError(errno);
+ stop();
+ return;
+ }
+
sensor_devctl_info_u deviceInfo;
const int result = devctl(m_deviceFile.handle(), DCMD_SENSOR_INFO, &deviceInfo,
sizeof(deviceInfo), NULL);
@@ -139,6 +169,7 @@ void BbSensorBackendBase::initSensorInfo()
setPaused(true);
m_socketNotifier.reset(new QSocketNotifier(m_deviceFile.handle(), QSocketNotifier::Read));
+ m_socketNotifier->setEnabled(false);
connect(m_socketNotifier.data(), SIGNAL(activated(int)), this, SLOT(dataAvailable()));
}
}
@@ -168,12 +199,13 @@ qreal BbSensorBackendBase::convertValue(float bbValue)
bool BbSensorBackendBase::isAutoAxisRemappingEnabled() const
{
- return sensor()->property("automaticAxisRemapping").toBool();
+ return sensor()->isFeatureSupported(QSensor::AxesOrientation) &&
+ sensor()->axesOrientationMode() != QSensor::FixedOrientation;
}
void BbSensorBackendBase::remapMatrix(const float inputMatrix[], float outputMatrix[])
{
- if (!isAutoAxisRemappingEnabled() || m_guiHelper->currentOrientation() == 0) {
+ if (!isAutoAxisRemappingEnabled() || orientationForRemapping() == 0) {
memcpy(outputMatrix, inputMatrix, sizeof(float) * 9);
return;
}
@@ -184,10 +216,10 @@ void BbSensorBackendBase::remapMatrix(const float inputMatrix[], float outputMat
void BbSensorBackendBase::remapAxes(float *x, float *y, float *z)
{
Q_ASSERT(x && y && z);
- if (!isAutoAxisRemappingEnabled() || m_guiHelper->currentOrientation() == 0)
+ if (!isAutoAxisRemappingEnabled() || orientationForRemapping() == 0)
return;
- const int angle = m_guiHelper->currentOrientation();
+ const int angle = orientationForRemapping();
const float oldX = *x;
const float oldY = *y;
@@ -239,36 +271,17 @@ void BbSensorBackendBase::start()
}
}
- // Explicitly switch to non-blocking mode, otherwise read() will wait until new sensor
- // data is available, and we have no way to check if there is more data or not (bytesAvailable()
- // does not work for unbuffered mode)
- const int oldFlags = fcntl(m_deviceFile.handle(), F_GETFL);
- if (fcntl(m_deviceFile.handle(), F_SETFL, oldFlags | O_NONBLOCK) == -1) {
- perror(QString::fromLatin1("Starting sensor %1 failed, fcntl() returned -1")
- .arg(m_deviceFile.fileName()).toLocal8Bit());
- sensorError(errno);
- stop();
- return;
- }
-
- // Activate event queuing if needed
- bool ok = false;
- const int requestedBufferSize = sensor()->property("bufferSize").toInt(&ok);
- if (ok && requestedBufferSize > 1) {
- sensor_devctl_queue_u queueControl;
- queueControl.tx.enable = 1;
- const int result = devctl(m_deviceFile.handle(), DCMD_SENSOR_QUEUE, &queueControl, sizeof(queueControl), NULL);
- if (result != EOK) {
- perror(QString::fromLatin1("Enabling sensor queuing for %1 failed")
- .arg(m_deviceFile.fileName()).toLocal8Bit());
- }
-
- const int actualBufferSize = queueControl.rx.size;
- sensor()->setProperty("bufferSize", actualBufferSize);
- sensor()->setProperty("efficientBufferSize", actualBufferSize);
- sensor()->setProperty("maxBufferSize", actualBufferSize);
+ // Enable/disable duplicate skipping
+ sensor_devctl_skipdupevent_u deviceSkip;
+ deviceSkip.tx.enable = sensor()->skipDuplicates();
+ const int result = devctl(deviceFile().handle(), DCMD_SENSOR_SKIPDUPEVENT, &deviceSkip,
+ sizeof(deviceSkip), NULL);
+ if (result != EOK) {
+ perror(QString::fromLatin1("Setting duplicate skipping for %1 failed")
+ .arg(m_deviceFile.fileName()).toLocal8Bit());
}
+ applyBuffering();
applyAlwaysOnProperty();
}
@@ -281,11 +294,23 @@ void BbSensorBackendBase::stop()
bool BbSensorBackendBase::isFeatureSupported(QSensor::Feature feature) const
{
switch (feature) {
+ case QSensor::AxesOrientation:
+ return (sensorType() == SENSOR_TYPE_ACCELEROMETER || sensorType() == SENSOR_TYPE_MAGNETOMETER ||
+ sensorType() == SENSOR_TYPE_GYROSCOPE || sensorType() == SENSOR_TYPE_GRAVITY ||
+ sensorType() == SENSOR_TYPE_LINEAR_ACCEL || sensorType() == SENSOR_TYPE_ROTATION_VECTOR ||
+ sensorType() == SENSOR_TYPE_ROTATION_MATRIX || sensorType() == SENSOR_TYPE_AZIMUTH_PITCH_ROLL);
case QSensor::AlwaysOn:
case QSensor::Buffering:
+ case QSensor::AccelerationMode:
+ case QSensor::SkipDuplicates:
return true;
- case QSensor::Reserved:
case QSensor::GeoValues:
+#ifndef Q_OS_BLACKBERRY_TABLET
+ return (sensorType() == SENSOR_TYPE_MAGNETOMETER);
+#else
+ return false;
+#endif
+ case QSensor::Reserved:
case QSensor::FieldOfView:
break;
}
@@ -295,8 +320,12 @@ bool BbSensorBackendBase::isFeatureSupported(QSensor::Feature feature) const
void BbSensorBackendBase::dataAvailable()
{
- if (!m_started)
+ if (!m_started) {
+ // Spurious dataAvailable() call, drain the device file of data. We also disable
+ // the socket notifier for this, so this is just added safety here.
+ m_deviceFile.readAll();
return;
+ }
Q_FOREVER {
sensor_event_t event;
@@ -331,6 +360,46 @@ void BbSensorBackendBase::applyAlwaysOnProperty()
updatePauseState();
}
+void BbSensorBackendBase::applyBuffering()
+{
+ if (!m_deviceFile.isOpen() || !m_started || m_applyingBufferSize)
+ return;
+
+ // Flag to prevent recursion. We call setBufferSize() below, and because of the changed signal,
+ // we might end up in this slot again.
+ // The call to setBufferSize() is needed since the requested buffer size is most likely different
+ // from the actual buffer size that will be used.
+ m_applyingBufferSize = true;
+
+ const bool enableBuffering = sensor()->bufferSize() > 1;
+ sensor_devctl_queue_u queueControl;
+ queueControl.tx.enable = enableBuffering ? 1 : 0;
+ const int result = devctl(m_deviceFile.handle(), DCMD_SENSOR_QUEUE, &queueControl, sizeof(queueControl), NULL);
+ if (result != EOK) {
+ perror(QString::fromLatin1("Enabling sensor queuing for %1 failed")
+ .arg(m_deviceFile.fileName()).toLocal8Bit());
+ } else {
+ if (enableBuffering) {
+ int actualBufferSize = queueControl.rx.size;
+
+ // Some firmware versions don't report the buffer size correctly. Simply pretend the
+ // buffer size is the same as the requested buffer size, as setting the buffer size to
+ // 1 here would seem as if buffering were disabled.
+ if (actualBufferSize == 1)
+ actualBufferSize = sensor()->bufferSize();
+
+ sensor()->setBufferSize(actualBufferSize);
+ sensor()->setEfficientBufferSize(actualBufferSize);
+ sensor()->setMaxBufferSize(actualBufferSize);
+ } else {
+ sensor()->setBufferSize(1);
+ sensor()->setEfficientBufferSize(defaultBufferSize);
+ sensor()->setMaxBufferSize(defaultBufferSize);
+ }
+ }
+ m_applyingBufferSize = false;
+}
+
bool BbSensorBackendBase::setPaused(bool paused)
{
if (!m_deviceFile.isOpen())
@@ -339,6 +408,9 @@ bool BbSensorBackendBase::setPaused(bool paused)
sensor_devctl_enable_u enableState;
enableState.tx.enable = paused ? 0 : 1;
+ if (m_socketNotifier)
+ m_socketNotifier->setEnabled(!paused);
+
const int result = devctl(m_deviceFile.handle(), DCMD_SENSOR_ENABLE, &enableState, sizeof(enableState), NULL);
if (result != EOK) {
perror(QString::fromLatin1("Setting sensor enabled (%1) for %2 failed")
@@ -360,12 +432,26 @@ void BbSensorBackendBase::updatePauseState()
void BbSensorBackendBase::updateOrientation()
{
- // ### I can't really test this, the rotation matrix has too many glitches and drifts over time,
- // making any measurement quite hard
- const int rotationAngle = guiHelper()->currentOrientation();
+ const int rotationAngle = orientationForRemapping();
m_mappingMatrix[0] = cos(rotationAngle*M_PI/180);
m_mappingMatrix[1] = sin(rotationAngle*M_PI/180);
m_mappingMatrix[2] = -sin(rotationAngle*M_PI/180);
m_mappingMatrix[3] = cos(rotationAngle*M_PI/180);
+
+ if (sensor()->isFeatureSupported(QSensor::AxesOrientation))
+ sensor()->setCurrentOrientation(rotationAngle);
+}
+
+int BbSensorBackendBase::orientationForRemapping() const
+{
+ if (!sensor()->isFeatureSupported(QSensor::AxesOrientation))
+ return 0;
+
+ switch (sensor()->axesOrientationMode()) {
+ default:
+ case QSensor::FixedOrientation: return 0;
+ case QSensor::AutomaticOrientation: return guiHelper()->currentOrientation();
+ case QSensor::UserOrientation: return sensor()->userOrientation();
+ }
}
diff --git a/src/plugins/sensors/blackberry/bbsensorbackend.h b/src/plugins/sensors/blackberry/bbsensorbackend.h
index 7e2ad0ec..4e7b8101 100644
--- a/src/plugins/sensors/blackberry/bbsensorbackend.h
+++ b/src/plugins/sensors/blackberry/bbsensorbackend.h
@@ -76,6 +76,9 @@ protected:
BbGuiHelper *guiHelper() const;
QFile& deviceFile();
sensor_type_e sensorType() const;
+ int orientationForRemapping() const;
+
+ void setDevice(const QString &deviceFile, sensor_type_e sensorType);
// This is called while the device file is open during initalization and gives a subclass
// an opportunity to do additional initalization.
@@ -104,6 +107,7 @@ protected:
private slots:
void dataAvailable();
void applyAlwaysOnProperty();
+ void applyBuffering();
bool setPaused(bool paused);
void updatePauseState();
void updateOrientation();
@@ -115,6 +119,7 @@ private:
BbGuiHelper *m_guiHelper;
float m_mappingMatrix[4];
bool m_started;
+ bool m_applyingBufferSize;
};
template<class SensorReading>
diff --git a/src/plugins/sensors/blackberry/bbtemperaturesensor.cpp b/src/plugins/sensors/blackberry/bbtemperaturesensor.cpp
index f3ec6342..b38fba4d 100644
--- a/src/plugins/sensors/blackberry/bbtemperaturesensor.cpp
+++ b/src/plugins/sensors/blackberry/bbtemperaturesensor.cpp
@@ -40,31 +40,8 @@
****************************************************************************/
#include "bbtemperaturesensor.h"
-class BbTemperatureReadingPrivate
-{
-public:
- BbTemperatureReadingPrivate()
- : temperature(0)
- {
- }
-
- qreal temperature;
-};
-
-IMPLEMENT_READING(BbTemperatureReading)
-
-qreal BbTemperatureReading::temperature() const
-{
- return d->temperature;
-}
-
-void BbTemperatureReading::setTemperature(qreal temperature)
-{
- d->temperature = temperature;
-}
-
BbTemperatureSensor::BbTemperatureSensor(QSensor *sensor)
- : BbSensorBackend<BbTemperatureReading>(devicePath(), SENSOR_TYPE_TEMPERATURE, sensor)
+ : BbSensorBackend<QAmbientTemperatureReading>(devicePath(), SENSOR_TYPE_TEMPERATURE, sensor)
{
setDescription(QLatin1String("Temperature in degrees Celsius"));
}
@@ -74,7 +51,7 @@ QString BbTemperatureSensor::devicePath()
return QLatin1String("/dev/sensor/temp");
}
-bool BbTemperatureSensor::updateReadingFromEvent(const sensor_event_t &event, BbTemperatureReading *reading)
+bool BbTemperatureSensor::updateReadingFromEvent(const sensor_event_t &event, QAmbientTemperatureReading *reading)
{
// TODO: I was unable to test this since the device I was testing this with did not have
// a temperature sensor. Verify that this works and check that the units are correct.
diff --git a/src/plugins/sensors/blackberry/bbtemperaturesensor.h b/src/plugins/sensors/blackberry/bbtemperaturesensor.h
index 1b9ea1bf..a24c67e7 100644
--- a/src/plugins/sensors/blackberry/bbtemperaturesensor.h
+++ b/src/plugins/sensors/blackberry/bbtemperaturesensor.h
@@ -42,20 +42,9 @@
#define BBTEMPERATURESENSOR_H
#include "bbsensorbackend.h"
+#include <qambienttemperaturesensor.h>
-class BbTemperatureReadingPrivate;
-
-class BbTemperatureReading : public QSensorReading
-{
- Q_OBJECT
- Q_PROPERTY(qreal temperature READ temperature)
- DECLARE_READING(BbTemperatureReading)
-public:
- qreal temperature() const;
- void setTemperature(qreal temperature);
-};
-
-class BbTemperatureSensor : public BbSensorBackend<BbTemperatureReading>
+class BbTemperatureSensor : public BbSensorBackend<QAmbientTemperatureReading>
{
Q_OBJECT
@@ -65,7 +54,7 @@ public:
static QString devicePath();
protected:
- bool updateReadingFromEvent(const sensor_event_t &event, BbTemperatureReading *reading);
+ bool updateReadingFromEvent(const sensor_event_t &event, QAmbientTemperatureReading *reading);
};
#endif
diff --git a/src/plugins/sensors/blackberry/blackberry.pro b/src/plugins/sensors/blackberry/blackberry.pro
index 73027c20..902239c4 100644
--- a/src/plugins/sensors/blackberry/blackberry.pro
+++ b/src/plugins/sensors/blackberry/blackberry.pro
@@ -12,6 +12,10 @@ config_bbsensor_compass {
DEFINES += HAVE_COMPASS_SENSOR
}
+config_bbsensor_holster {
+ DEFINES += HAVE_HOLSTER_SENSOR
+}
+
HEADERS += bbsensorbackend.h \
bbaccelerometer.h \
bbaltimeter.h \
@@ -47,4 +51,9 @@ SOURCES += bbsensorbackend.cpp \
bbutil.cpp \
main.cpp
+config_bbsensor_holster {
+ HEADERS += bbholstersensor.h
+ SOURCES += bbholstersensor.cpp
+}
+
OTHER_FILES = plugin.json
diff --git a/src/plugins/sensors/blackberry/main.cpp b/src/plugins/sensors/blackberry/main.cpp
index 7c2d5dbc..61f9aa08 100644
--- a/src/plugins/sensors/blackberry/main.cpp
+++ b/src/plugins/sensors/blackberry/main.cpp
@@ -43,6 +43,9 @@
#include "bbambientlightsensor.h"
#include "bbcompass.h"
#include "bbgyroscope.h"
+#ifdef HAVE_HOLSTER_SENSOR
+#include "bbholstersensor.h"
+#endif
#include "bbirproximitysensor.h"
#include "bblightsensor.h"
#include "bbmagnetometer.h"
@@ -61,6 +64,9 @@ static const char *bbAltitmeterId = "bbAltimeter";
static const char *bbAmbientLightSensorId = "bbAmbientLightSensor";
static const char *bbCompassId = "bbCompass";
static const char *bbGyroscopeId = "bbGyroscope";
+#ifdef HAVE_HOLSTER_SENSOR
+static const char *bbHolsterSensorId = "bbHolsterSensor";
+#endif
static const char *bbIRProximitySensorId = "bbIRProximitySensor";
static const char *bbLightSensorId = "bbLightSensor";
static const char *bbMagnetometerId = "bbMagnetometer";
@@ -82,13 +88,17 @@ public:
if (sensorSupported(BbAccelerometer::devicePath()))
QSensorManager::registerBackend(QAccelerometer::type, bbAccelerometerId, this);
if (sensorSupported(BbAltimeter::devicePath()))
- QSensorManager::registerBackend("BbAltimeter", bbAltitmeterId, this);
+ QSensorManager::registerBackend(QAltimeter::type, bbAltitmeterId, this);
if (sensorSupported(BbAmbientLightSensor::devicePath()))
QSensorManager::registerBackend(QAmbientLightSensor::type, bbAmbientLightSensorId, this);
if (sensorSupported(BbCompass::devicePath()))
QSensorManager::registerBackend(QCompass::type, bbCompassId, this);
if (sensorSupported(BbGyroscope::devicePath()))
QSensorManager::registerBackend(QGyroscope::type, bbGyroscopeId, this);
+#ifdef HAVE_HOLSTER_SENSOR
+ if (sensorSupported(BbHolsterSensor::devicePath()))
+ QSensorManager::registerBackend(QHolsterSensor::type, bbHolsterSensorId, this);
+#endif
if (sensorSupported(BbIRProximitySensor::devicePath()))
QSensorManager::registerBackend(QIRProximitySensor::type, bbIRProximitySensorId, this);
if (sensorSupported(BbLightSensor::devicePath()))
@@ -98,13 +108,13 @@ public:
if (sensorSupported(BbOrientationSensor::devicePath()))
QSensorManager::registerBackend(QOrientationSensor::type, bbOrientationSensorId, this);
if (sensorSupported(BbPressureSensor::devicePath()))
- QSensorManager::registerBackend("BbPressureSensor", bbPressureSensorId, this);
+ QSensorManager::registerBackend(QPressureSensor::type, bbPressureSensorId, this);
if (sensorSupported(BbProximitySensor::devicePath()))
QSensorManager::registerBackend(QProximitySensor::type, bbProximitySensorId, this);
if (sensorSupported(BbRotationSensor::devicePath()))
QSensorManager::registerBackend(QRotationSensor::type, bbRotationSensorId, this);
if (sensorSupported(BbTemperatureSensor::devicePath()))
- QSensorManager::registerBackend("BbTemperatureSensor", bbTemperatureSensorId, this);
+ QSensorManager::registerBackend(QAmbientTemperatureSensor::type, bbTemperatureSensorId, this);
}
QSensorBackend *createBackend(QSensor *sensor) Q_DECL_OVERRIDE
@@ -120,6 +130,10 @@ public:
backend = new BbCompass(sensor);
if (sensor->identifier() == bbGyroscopeId)
backend = new BbGyroscope(sensor);
+#ifdef HAVE_HOLSTER_SENSOR
+ if (sensor->identifier() == bbHolsterSensorId)
+ backend = new BbHolsterSensor(sensor);
+#endif
if (sensor->identifier() == bbIRProximitySensorId)
backend = new BbIRProximitySensor(sensor);
if (sensor->identifier() == bbLightSensorId)
diff --git a/src/plugins/sensors/dummy/dummy.pro b/src/plugins/sensors/dummy/dummy.pro
index b97bd9ce..f54588af 100644
--- a/src/plugins/sensors/dummy/dummy.pro
+++ b/src/plugins/sensors/dummy/dummy.pro
@@ -15,4 +15,4 @@ SOURCES += dummycommon.cpp\
OTHER_FILES = plugin.json
-unix:!mac:!qnx:LIBS+=-lrt
+unix:!mac:!qnx:!android:LIBS+=-lrt
diff --git a/src/plugins/sensors/generic/generic.pro b/src/plugins/sensors/generic/generic.pro
index 2d4f9f9f..fcc1bfcd 100644
--- a/src/plugins/sensors/generic/generic.pro
+++ b/src/plugins/sensors/generic/generic.pro
@@ -4,15 +4,27 @@ QT = core sensors
PLUGIN_TYPE = sensors
load(qt_plugin)
-HEADERS += genericorientationsensor.h\
- genericrotationsensor.h\
- genericalssensor.h\
- generictiltsensor.h
-
-SOURCES += genericorientationsensor.cpp\
- main.cpp\
- genericrotationsensor.cpp\
- genericalssensor.cpp\
+HEADERS += generictiltsensor.h
+
+SOURCES += main.cpp\
generictiltsensor.cpp
+DEFINES += QTSENSORS_GENERICTILTSENSOR
+
+!blackberry {
+ HEADERS += genericorientationsensor.h\
+ genericalssensor.h
+
+ SOURCES += genericorientationsensor.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/genericrotationsensor.cpp b/src/plugins/sensors/generic/genericrotationsensor.cpp
index b5f80cb3..0548adc0 100644
--- a/src/plugins/sensors/generic/genericrotationsensor.cpp
+++ b/src/plugins/sensors/generic/genericrotationsensor.cpp
@@ -57,7 +57,9 @@ genericrotationsensor::genericrotationsensor(QSensor *sensor)
setReading<QRotationReading>(&m_reading);
setDataRates(accelerometer);
- sensor->setProperty("hasZ", false);
+ QRotationSensor * const rotationSensor = qobject_cast<QRotationSensor *>(sensor);
+ if (rotationSensor)
+ rotationSensor->setHasZ(false);
}
void genericrotationsensor::start()
diff --git a/src/plugins/sensors/generic/genericrotationsensor.h b/src/plugins/sensors/generic/genericrotationsensor.h
index 3475cafe..ffa48ea3 100644
--- a/src/plugins/sensors/generic/genericrotationsensor.h
+++ b/src/plugins/sensors/generic/genericrotationsensor.h
@@ -62,7 +62,6 @@ public:
private:
QRotationReading m_reading;
QAccelerometer *accelerometer;
- QMagnetometer *magnetometer;
};
#endif
diff --git a/src/plugins/sensors/generic/generictiltsensor.cpp b/src/plugins/sensors/generic/generictiltsensor.cpp
index 6aefb576..95c8525b 100644
--- a/src/plugins/sensors/generic/generictiltsensor.cpp
+++ b/src/plugins/sensors/generic/generictiltsensor.cpp
@@ -53,6 +53,8 @@ GenericTiltSensor::GenericTiltSensor(QSensor *sensor)
, roll(0)
, calibratedPitch(0)
, calibratedRoll(0)
+ , xRotation(0)
+ , yRotation(0)
{
accelerometer = new QAccelerometer(this);
accelerometer->addFilter(this);
@@ -106,6 +108,11 @@ void GenericTiltSensor::calibrate()
calibratedRoll = roll;
}
+static qreal rad2deg(qreal rad)
+{
+ return rad / (2 * M_PI) * 360;
+}
+
bool GenericTiltSensor::filter(QAccelerometerReading *reading)
{
/*
@@ -119,16 +126,16 @@ bool GenericTiltSensor::filter(QAccelerometerReading *reading)
qreal az = reading->z();
#ifdef LOGCALIBRATION
qDebug() << "------------ new value -----------";
- qDebug() << "old _pitch: " << _pitch;
- qDebug() << "old _roll: " << _roll;
- qDebug() << "_calibratedPitch: " << _calibratedPitch;
- qDebug() << "_calibratedRoll: " << _calibratedRoll;
+ qDebug() << "old _pitch: " << pitch;
+ qDebug() << "old _roll: " << roll;
+ qDebug() << "_calibratedPitch: " << calibratedPitch;
+ qDebug() << "_calibratedRoll: " << calibratedRoll;
#endif
pitch = calcPitch(ax, ay, az);
roll = calcRoll (ax, ay, az);
#ifdef LOGCALIBRATION
- qDebug() << "_pitch: " << _pitch;
- qDebug() << "_roll: " << _roll;
+ qDebug() << "_pitch: " << pitch;
+ qDebug() << "_roll: " << roll;
#endif
qreal xrot = roll - calibratedRoll;
qreal yrot = pitch - calibratedPitch;
@@ -154,23 +161,22 @@ bool GenericTiltSensor::filter(QAccelerometerReading *reading)
qDebug() << "new yrot: " << yrot;
qDebug() << "----------------------------------";
#endif
- qreal dxrot = xrot - xRotation;
- qreal dyrot = yrot - yRotation;
+ qreal dxrot = rad2deg(xrot) - xRotation;
+ qreal dyrot = rad2deg(yrot) - yRotation;
if (dxrot < 0) dxrot = -dxrot;
if (dyrot < 0) dyrot = -dyrot;
- bool change = false;
- if (dxrot >= radAccuracy) {
- xRotation = xrot;
- change = true;
+ bool setNewReading = false;
+ if (dxrot >= rad2deg(radAccuracy) || !sensor()->skipDuplicates()) {
+ xRotation = rad2deg(xrot);
+ setNewReading = true;
}
- if (dyrot >= radAccuracy) {
- yRotation = yrot;
- change = true;
+ if (dyrot >= rad2deg(radAccuracy) || !sensor()->skipDuplicates()) {
+ yRotation = rad2deg(yrot);
+ setNewReading = true;
}
- if (xRotation != m_reading.xRotation()
- || yRotation != m_reading.yRotation()
- || m_reading.timestamp() == 0) {
+
+ if (setNewReading || m_reading.timestamp() == 0) {
m_reading.setTimestamp(reading->timestamp());
m_reading.setXRotation(xRotation);
m_reading.setYRotation(yRotation);
@@ -179,3 +185,8 @@ bool GenericTiltSensor::filter(QAccelerometerReading *reading)
return false;
}
+
+bool GenericTiltSensor::isFeatureSupported(QSensor::Feature feature) const
+{
+ return (feature == QSensor::SkipDuplicates);
+}
diff --git a/src/plugins/sensors/generic/generictiltsensor.h b/src/plugins/sensors/generic/generictiltsensor.h
index 0633662c..0f84ca6f 100644
--- a/src/plugins/sensors/generic/generictiltsensor.h
+++ b/src/plugins/sensors/generic/generictiltsensor.h
@@ -46,7 +46,6 @@
#include <qtiltsensor.h>
#include <qaccelerometer.h>
-QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
class GenericTiltSensor : public QSensorBackend, public QAccelerometerFilter
@@ -64,6 +63,8 @@ public:
bool filter(QAccelerometerReading *reading);
+ bool isFeatureSupported(QSensor::Feature feature) const Q_DECL_OVERRIDE;
+
private:
QTiltReading m_reading;
QAccelerometer *accelerometer;
@@ -77,7 +78,6 @@ private:
};
QT_END_NAMESPACE
-QT_END_HEADER
#endif
diff --git a/src/plugins/sensors/generic/main.cpp b/src/plugins/sensors/generic/main.cpp
index 15507b63..aa9f58c2 100644
--- a/src/plugins/sensors/generic/main.cpp
+++ b/src/plugins/sensors/generic/main.cpp
@@ -39,9 +39,18 @@
**
****************************************************************************/
+#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>
@@ -56,7 +65,6 @@ class genericSensorPlugin : public QObject, public QSensorPluginInterface, publi
public:
void registerSensors()
{
- qDebug() << "loaded the Generic plugin";
// Nothing to register here
}
@@ -64,34 +72,60 @@ public:
{
if (!QSensor::defaultSensorForType(QAccelerometer::type).isEmpty()) {
// There is an accelerometer available. Register the backends
+#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);
- 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 {
+#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)
{
+#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;
}
diff --git a/src/plugins/sensors/ios/ios.pro b/src/plugins/sensors/ios/ios.pro
new file mode 100644
index 00000000..4242cfca
--- /dev/null
+++ b/src/plugins/sensors/ios/ios.pro
@@ -0,0 +1,17 @@
+TARGET = qtsensors_ios
+QT = core sensors
+
+PLUGIN_TYPE = sensors
+PLUGIN_CLASS_NAME = IOSSensorPlugin
+load(qt_plugin)
+
+OTHER_FILES = plugin.json
+
+HEADERS += iosaccelerometer.h \
+ iosmotionmanager.h
+
+OBJECTIVE_SOURCES += main.mm \
+ iosaccelerometer.mm \
+ iosmotionmanager.mm
+
+LIBS += -framework UIKit -framework CoreMotion
diff --git a/src/plugins/sensors/ios/iosaccelerometer.h b/src/plugins/sensors/ios/iosaccelerometer.h
new file mode 100644
index 00000000..34cc3ebd
--- /dev/null
+++ b/src/plugins/sensors/ios/iosaccelerometer.h
@@ -0,0 +1,71 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Lorn Potter
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtSensors module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef IOSACCELEROMETER_H
+#define IOSACCELEROMETER_H
+
+#include <qsensorbackend.h>
+#include <qaccelerometer.h>
+
+QT_BEGIN_NAMESPACE
+
+@class QtIoAccelListener;
+
+class IOSAccelerometer : public QSensorBackend
+{
+public:
+ static char const * const id;
+
+ explicit IOSAccelerometer(QSensor *sensor);
+ ~IOSAccelerometer();
+
+ void start();
+ void stop();
+ void readingsChanged(quint64,qreal,qreal,qreal);
+
+private:
+ QtIoAccelListener *m_listener;
+ QAccelerometerReading m_reading;
+};
+QT_END_NAMESPACE
+
+#endif // IOSACCELEROMETER_H
+
diff --git a/src/plugins/sensors/ios/iosaccelerometer.mm b/src/plugins/sensors/ios/iosaccelerometer.mm
new file mode 100644
index 00000000..ef7d2a6d
--- /dev/null
+++ b/src/plugins/sensors/ios/iosaccelerometer.mm
@@ -0,0 +1,143 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Lorn Potter
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtSensors module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "iosaccelerometer.h"
+#include "iosmotionmanager.h"
+
+#include <UIKit/UIAccelerometer.h>
+#include <CoreMotion/CMMotionManager.h>
+
+char const * const IOSAccelerometer::id("ios.accelerometer");
+
+@interface QtIoAccelListener : NSObject
+{
+ IOSAccelerometer *m_qiosAccelerometer;
+ NSOperationQueue *m_updateQueue;
+}
+@end
+
+@implementation QtIoAccelListener
+
+-(id)initWithQIOSAccelerometer:(IOSAccelerometer *) qiosAccelerometer
+{
+ self = [super init];
+ if (self) {
+ m_qiosAccelerometer = qiosAccelerometer;
+ m_updateQueue = [[NSOperationQueue alloc] init];
+ }
+ return self;
+}
+
+-(void)dealloc
+{
+ [m_updateQueue release];
+ [super dealloc];
+}
+
+-(void)startAccelerometer
+{
+ CMMotionManager *motionManager = [QIOSMotionManager sharedManager];
+
+ if (motionManager.deviceMotionAvailable) {
+ [motionManager startAccelerometerUpdatesToQueue:m_updateQueue withHandler:^(CMAccelerometerData *data, NSError *error) {
+ dispatch_async(dispatch_get_main_queue(), ^{
+ Q_UNUSED(error);
+ CMAcceleration acc = data.acceleration;
+ // Convert from G to m/s2, and flip axes:
+ const qreal G = 9.8066;
+ qreal x = qreal(acc.x) * G * -1;
+ qreal y = qreal(acc.y) * G * -1;
+ qreal z = qreal(acc.z) * G * -1;
+ m_qiosAccelerometer->readingsChanged(quint64(data.timestamp), x, y, z);
+ });
+ }];
+ }
+}
+
+-(void)stopAccelerometer
+{
+ [[QIOSMotionManager sharedManager] stopAccelerometerUpdates];
+}
+
+-(void)setInterval:(NSTimeInterval) interval
+{
+ [QIOSMotionManager sharedManager].accelerometerUpdateInterval = interval;
+}
+
+@end
+
+QT_BEGIN_NAMESPACE
+
+IOSAccelerometer::IOSAccelerometer(QSensor *sensor)
+ : QSensorBackend(sensor)
+ , m_listener([[QtIoAccelListener alloc] initWithQIOSAccelerometer:this])
+{
+ setReading<QAccelerometerReading>(&m_reading);
+ addDataRate(1, 100); // 100Hz
+ addOutputRange(-22.418, 22.418, 0.17651); // 2G
+}
+
+IOSAccelerometer::~IOSAccelerometer()
+{
+ [m_listener dealloc];
+}
+
+void IOSAccelerometer::start()
+{
+ [m_listener startAccelerometer];
+}
+
+void IOSAccelerometer::stop()
+{
+ [m_listener stopAccelerometer];
+}
+
+void IOSAccelerometer::readingsChanged(quint64 ts, qreal x, qreal y, qreal z)
+{
+ m_reading.setTimestamp(ts);
+ m_reading.setX(x);
+ m_reading.setY(y);
+ m_reading.setZ(z);
+
+ newReadingAvailable();
+}
+
+QT_END_NAMESPACE
diff --git a/src/plugins/sensors/ios/iosmotionmanager.h b/src/plugins/sensors/ios/iosmotionmanager.h
new file mode 100644
index 00000000..7babfc36
--- /dev/null
+++ b/src/plugins/sensors/ios/iosmotionmanager.h
@@ -0,0 +1,55 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Lorn Potter
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtSensors module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef IOSMOTIONMANAGER_H
+#define IOSMOTIONMANAGER_H
+
+#import <UIKit/UIKit.h>
+#import <CoreMotion/CoreMotion.h>
+
+@interface QIOSMotionManager : NSObject {
+}
+
++ (CMMotionManager *)sharedManager;
+@end
+
+#endif //IOSMOTIONMANAGER_H
+
diff --git a/src/plugins/sensors/ios/iosmotionmanager.mm b/src/plugins/sensors/ios/iosmotionmanager.mm
new file mode 100644
index 00000000..a367c49b
--- /dev/null
+++ b/src/plugins/sensors/ios/iosmotionmanager.mm
@@ -0,0 +1,57 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Lorn Potter
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtSensors module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "iosmotionmanager.h"
+
+static CMMotionManager *sharedManager = nil;
+
+@implementation QIOSMotionManager
+
++ (CMMotionManager *)sharedManager
+{
+ static dispatch_once_t staticToken;
+ dispatch_once(&staticToken, ^{
+ sharedManager = [[CMMotionManager alloc] init];
+ });
+ return sharedManager;
+}
+
+@end
diff --git a/src/plugins/sensors/ios/main.mm b/src/plugins/sensors/ios/main.mm
new file mode 100644
index 00000000..3c739393
--- /dev/null
+++ b/src/plugins/sensors/ios/main.mm
@@ -0,0 +1,70 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtSensors module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <qsensorplugin.h>
+#include <qsensorbackend.h>
+#include <qsensormanager.h>
+
+#include "iosaccelerometer.h"
+
+class IOSSensorPlugin : public QObject, public QSensorPluginInterface, public QSensorBackendFactory
+{
+ Q_OBJECT
+ Q_PLUGIN_METADATA(IID "com.qt-project.Qt.QSensorPluginInterface/1.0" FILE "plugin.json")
+ Q_INTERFACES(QSensorPluginInterface)
+public:
+ void registerSensors()
+ {
+ if (!QSensorManager::isBackendRegistered(QAccelerometer::type, IOSAccelerometer::id))
+ QSensorManager::registerBackend(QAccelerometer::type, IOSAccelerometer::id, this);
+ }
+
+ QSensorBackend *createBackend(QSensor *sensor)
+ {
+ if (sensor->identifier() == IOSAccelerometer::id)
+ return new IOSAccelerometer(sensor);
+
+ return 0;
+ }
+};
+
+#include "main.moc"
+
diff --git a/src/plugins/sensors/ios/plugin.json b/src/plugins/sensors/ios/plugin.json
new file mode 100644
index 00000000..8a55b3ae
--- /dev/null
+++ b/src/plugins/sensors/ios/plugin.json
@@ -0,0 +1 @@
+{ "Keys": [ "notused" ] }
diff --git a/src/plugins/sensors/linux/linux.pro b/src/plugins/sensors/linux/linux.pro
index 7546728f..25c4f2d9 100644
--- a/src/plugins/sensors/linux/linux.pro
+++ b/src/plugins/sensors/linux/linux.pro
@@ -6,7 +6,7 @@ load(qt_plugin)
OTHER_FILES = plugin.json
-LIBS += -lrt
+!android:LIBS += -lrt
HEADERS += linuxsysaccelerometer.h
SOURCES += linuxsysaccelerometer.cpp \
main.cpp
diff --git a/src/plugins/sensors/sensorfw/Sensors.conf b/src/plugins/sensors/sensorfw/Sensors.conf
new file mode 100644
index 00000000..a003f12c
--- /dev/null
+++ b/src/plugins/sensors/sensorfw/Sensors.conf
@@ -0,0 +1,11 @@
+[Default]
+QAccelerometer=sensorfw.accelerometer
+QAmbientLightSensor=sensorfw.als
+QCompass=sensorfw.compass
+QMagnetometer=sensorfw.magnetometer
+QOrientationSensor=sensorfw.orientationsensor
+QProximitySensor=sensorfw.proximitysensor
+QRotationSensor=sensorfw.rotationsensor
+QTapSensor=sensorfw.tapsensor
+QLightSensor=sensorfw.lightsensor
+QIRProximitySensor=sensorfw.irproximitysensor
diff --git a/src/plugins/sensors/sensorfw/main.cpp b/src/plugins/sensors/sensorfw/main.cpp
new file mode 100644
index 00000000..f12a193e
--- /dev/null
+++ b/src/plugins/sensors/sensorfw/main.cpp
@@ -0,0 +1,109 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtSensors module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "sensorfwaccelerometer.h"
+#include "sensorfwals.h"
+#include "sensorfwcompass.h"
+#include "sensorfwmagnetometer.h"
+#include "sensorfworientationsensor.h"
+#include "sensorfwproximitysensor.h"
+#include "sensorfwirproximitysensor.h"
+#include "sensorfwrotationsensor.h"
+#include "sensorfwtapsensor.h"
+#include "sensorfwgyroscope.h"
+#include "sensorfwlightsensor.h"
+
+#include <qsensorplugin.h>
+#include <qsensorbackend.h>
+#include <qsensormanager.h>
+#include <QDebug>
+#include <QSettings>
+
+class sensorfwSensorPlugin : public QObject, public QSensorPluginInterface, public QSensorBackendFactory
+{
+ Q_OBJECT
+ Q_PLUGIN_METADATA(IID "com.qt-project.Qt.QSensorPluginInterface/1.0" FILE "plugin.json")
+ Q_INTERFACES(QSensorPluginInterface)
+
+public:
+
+ void registerSensors()
+ {
+ // if no default - no support either, uses Sensors.conf
+ QSettings settings(QSettings::SystemScope, QLatin1String("QtProject"), QLatin1String("Sensors"));
+ settings.beginGroup(QLatin1String("Default"));
+ QStringList keys = settings.allKeys();
+ for (int i=0,l=keys.size(); i<l; i++) {
+ QString type = keys.at(i);
+ QSensorManager::registerBackend(type.toLocal8Bit(), settings.value(type).toByteArray(), this);
+ }
+ }
+
+
+ QSensorBackend *createBackend(QSensor *sensor)
+ {
+ if (sensor->identifier() == sensorfwaccelerometer::id)
+ return new sensorfwaccelerometer(sensor);
+ if (sensor->identifier() == Sensorfwals::id)
+ return new Sensorfwals(sensor);
+ if (sensor->identifier() == SensorfwCompass::id)
+ return new SensorfwCompass(sensor);
+ if (sensor->identifier() == SensorfwMagnetometer::id)
+ return new SensorfwMagnetometer(sensor);
+ if (sensor->identifier() == SensorfwOrientationSensor::id)
+ return new SensorfwOrientationSensor(sensor);
+ if (sensor->identifier() == SensorfwProximitySensor::id)
+ return new SensorfwProximitySensor(sensor);
+ if (sensor->identifier() == SensorfwRotationSensor::id)
+ return new SensorfwRotationSensor(sensor);
+ if (sensor->identifier() == SensorfwTapSensor::id)
+ return new SensorfwTapSensor(sensor);
+ if (sensor->identifier() == SensorfwGyroscope::id)
+ return new SensorfwGyroscope(sensor);
+ if (sensor->identifier() == SensorfwLightSensor::id)
+ return new SensorfwLightSensor(sensor);
+ if (sensor->identifier() == SensorfwIrProximitySensor::id)
+ return new SensorfwIrProximitySensor(sensor);
+ return 0;
+ }
+};
+
+#include "main.moc"
diff --git a/src/plugins/sensors/sensorfw/plugin.json b/src/plugins/sensors/sensorfw/plugin.json
new file mode 100644
index 00000000..8a55b3ae
--- /dev/null
+++ b/src/plugins/sensors/sensorfw/plugin.json
@@ -0,0 +1 @@
+{ "Keys": [ "notused" ] }
diff --git a/src/plugins/sensors/sensorfw/sensorfw.pri b/src/plugins/sensors/sensorfw/sensorfw.pri
new file mode 100644
index 00000000..31d7254c
--- /dev/null
+++ b/src/plugins/sensors/sensorfw/sensorfw.pri
@@ -0,0 +1,26 @@
+HEADERS += sensorfwsensorbase.h \
+ sensorfwaccelerometer.h \
+ sensorfwals.h \
+ sensorfwcompass.h \
+ sensorfwgyroscope.h \
+ sensorfwmagnetometer.h \
+ sensorfworientationsensor.h \
+ sensorfwproximitysensor.h \
+ sensorfwrotationsensor.h \
+ sensorfwtapsensor.h \
+ sensorfwlightsensor.h \
+ sensorfwirproximitysensor.h
+
+SOURCES += sensorfwsensorbase.cpp \
+ sensorfwaccelerometer.cpp \
+ sensorfwals.cpp \
+ sensorfwcompass.cpp \
+ sensorfwgyroscope.cpp \
+ sensorfwmagnetometer.cpp \
+ sensorfworientationsensor.cpp \
+ sensorfwproximitysensor.cpp \
+ sensorfwirproximitysensor.cpp \
+ sensorfwrotationsensor.cpp \
+ sensorfwtapsensor.cpp \
+ sensorfwlightsensor.cpp \
+ main.cpp
diff --git a/src/plugins/sensors/sensorfw/sensorfw.pro b/src/plugins/sensors/sensorfw/sensorfw.pro
new file mode 100644
index 00000000..8d67c81f
--- /dev/null
+++ b/src/plugins/sensors/sensorfw/sensorfw.pro
@@ -0,0 +1,17 @@
+TARGET = qtsensors_sensorfw
+QT = core sensors network
+
+PLUGIN_TYPE = sensors
+load(qt_plugin)
+
+include(sensorfw.pri)
+
+
+CONFIG += link_pkgconfig
+PKGCONFIG += sensord
+
+CONFIGFILES.files = Sensors.conf
+CONFIGFILES.path = /etc/xdg/QtProject/
+INSTALLS += CONFIGFILES
+
+OTHER_FILES = plugin.json
diff --git a/src/plugins/sensors/sensorfw/sensorfwaccelerometer.cpp b/src/plugins/sensors/sensorfw/sensorfwaccelerometer.cpp
new file mode 100644
index 00000000..ddbaa9c6
--- /dev/null
+++ b/src/plugins/sensors/sensorfw/sensorfwaccelerometer.cpp
@@ -0,0 +1,91 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtSensors module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "sensorfwaccelerometer.h"
+
+char const * const sensorfwaccelerometer::id("sensorfw.accelerometer");
+bool sensorfwaccelerometer::m_initDone = false;
+
+sensorfwaccelerometer::sensorfwaccelerometer(QSensor *sensor)
+ : SensorfwSensorBase(sensor)
+{
+ initSensor<AccelerometerSensorChannelInterface>(m_initDone);
+ setDescription(QLatin1String("x, y, and z axes accelerations in m/s^2"));
+ setRanges(GRAVITY_EARTH_THOUSANDTH);
+ setReading<QAccelerometerReading>(&m_reading);
+}
+
+void sensorfwaccelerometer::slotDataAvailable(const XYZ& data)
+{
+ // Convert from milli-Gs to meters per second per second
+ // Using 1 G = 9.80665 m/s^2
+ m_reading.setX(-data.x() * GRAVITY_EARTH_THOUSANDTH);
+ m_reading.setY(-data.y() * GRAVITY_EARTH_THOUSANDTH);
+ m_reading.setZ(-data.z() * GRAVITY_EARTH_THOUSANDTH);
+ m_reading.setTimestamp(data.XYZData().timestamp_);
+ newReadingAvailable();
+}
+
+void sensorfwaccelerometer::slotFrameAvailable(const QVector<XYZ>& frame)
+{
+ for (int i=0, l=frame.size(); i<l; i++) {
+ slotDataAvailable(frame.at(i));
+ }
+}
+
+bool sensorfwaccelerometer::doConnect()
+{
+ if (m_bufferSize==1)
+ return QObject::connect(m_sensorInterface, SIGNAL(dataAvailable(const XYZ&)), this, SLOT(slotDataAvailable(const XYZ&)));
+ return QObject::connect(m_sensorInterface, SIGNAL(frameAvailable(const QVector<XYZ>& )),this, SLOT(slotFrameAvailable(const QVector<XYZ>& )));
+}
+
+
+QString sensorfwaccelerometer::sensorName() const
+{
+ return "accelerometersensor";
+}
+
+
+qreal sensorfwaccelerometer::correctionFactor() const
+{
+ return GRAVITY_EARTH_THOUSANDTH;
+}
diff --git a/src/plugins/sensors/sensorfw/sensorfwaccelerometer.h b/src/plugins/sensors/sensorfw/sensorfwaccelerometer.h
new file mode 100644
index 00000000..1c94aae3
--- /dev/null
+++ b/src/plugins/sensors/sensorfw/sensorfwaccelerometer.h
@@ -0,0 +1,74 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtSensors module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#ifndef SENSORFWACCELEROMETER_H
+#define SENSORFWACCELEROMETER_H
+
+#include "sensorfwsensorbase.h"
+#include <qaccelerometer.h>
+
+#include <accelerometersensor_i.h>
+#include <datatypes/xyz.h>
+
+
+
+class sensorfwaccelerometer : public SensorfwSensorBase
+{
+ Q_OBJECT
+
+public:
+ static char const * const id;
+ sensorfwaccelerometer(QSensor *sensor);
+protected:
+ virtual bool doConnect();
+ virtual QString sensorName() const;
+ virtual qreal correctionFactor() const;
+
+
+private:
+ QAccelerometerReading m_reading;
+ static bool m_initDone;
+
+private slots:
+ void slotDataAvailable(const XYZ& data);
+ void slotFrameAvailable(const QVector<XYZ>&);
+};
+
+#endif
diff --git a/src/plugins/sensors/sensorfw/sensorfwals.cpp b/src/plugins/sensors/sensorfw/sensorfwals.cpp
new file mode 100644
index 00000000..811da77f
--- /dev/null
+++ b/src/plugins/sensors/sensorfw/sensorfwals.cpp
@@ -0,0 +1,111 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtSensors module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+#include "sensorfwals.h"
+
+char const * const Sensorfwals::id("sensorfw.als");
+bool Sensorfwals::m_initDone = false;
+
+Sensorfwals::Sensorfwals(QSensor *sensor)
+ : SensorfwSensorBase(sensor)
+{
+ initSensor<ALSSensorChannelInterface>(m_initDone);
+ setReading<QAmbientLightReading>(&m_reading);
+ // metadata
+ setDescription(QLatin1String("ambient light intensity given as 5 pre-defined levels"));
+ addOutputRange(0, 5, 1);
+ addDataRate(10,10);
+}
+
+void Sensorfwals::start()
+{
+ if (m_sensorInterface) {
+ Unsigned data(((ALSSensorChannelInterface*)m_sensorInterface)->lux());
+ m_reading.setLightLevel(getLightLevel(data.x()));
+ m_reading.setTimestamp(data.UnsignedData().timestamp_);
+ newReadingAvailable();
+ }
+ SensorfwSensorBase::start();
+}
+
+
+void Sensorfwals::slotDataAvailable(const Unsigned& data)
+{
+ QAmbientLightReading::LightLevel level = getLightLevel(data.x());
+ if (level != m_reading.lightLevel()) {
+ m_reading.setLightLevel(level);
+ m_reading.setTimestamp(data.UnsignedData().timestamp_);
+ newReadingAvailable();
+ }
+}
+
+bool Sensorfwals::doConnect()
+{
+ return QObject::connect(m_sensorInterface, SIGNAL(ALSChanged(const Unsigned&)),
+ this, SLOT(slotDataAvailable(const Unsigned&)));
+}
+
+
+QString Sensorfwals::sensorName() const
+{
+ return "alssensor";
+}
+
+
+QAmbientLightReading::LightLevel Sensorfwals::getLightLevel(int lux)
+{
+ // Convert from integer to fixed levels
+ if (lux < 0) {
+ return QAmbientLightReading::Undefined;
+ } else if (lux < 10) {
+ return QAmbientLightReading::Dark;
+ } else if (lux < 50) {
+ return QAmbientLightReading::Twilight;
+ } else if (lux < 100) {
+ return QAmbientLightReading::Light;
+ } else if (lux < 150) {
+ return QAmbientLightReading::Bright;
+ } else {
+ return QAmbientLightReading::Sunny;
+ }
+
+}
diff --git a/src/plugins/sensors/sensorfw/sensorfwals.h b/src/plugins/sensors/sensorfw/sensorfwals.h
new file mode 100644
index 00000000..ba7c9af1
--- /dev/null
+++ b/src/plugins/sensors/sensorfw/sensorfwals.h
@@ -0,0 +1,75 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtSensors module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef SENSORFWALS_H
+#define SENSORFWALS_H
+
+#include "sensorfwsensorbase.h"
+#include <qambientlightsensor.h>
+
+#include <alssensor_i.h>
+#include <unsigned.h>
+
+
+
+class Sensorfwals : public SensorfwSensorBase
+{
+ Q_OBJECT
+
+public:
+ static char const * const id;
+ Sensorfwals(QSensor *sensor);
+protected:
+ virtual bool doConnect();
+ virtual QString sensorName() const;
+ virtual void start();
+
+
+private:
+ QAmbientLightReading m_reading;
+ static bool m_initDone;
+private slots:
+ void slotDataAvailable(const Unsigned& data);
+ static QAmbientLightReading::LightLevel getLightLevel(int lux);
+
+};
+
+#endif
diff --git a/src/plugins/sensors/sensorfw/sensorfwcompass.cpp b/src/plugins/sensors/sensorfw/sensorfwcompass.cpp
new file mode 100644
index 00000000..00741a1f
--- /dev/null
+++ b/src/plugins/sensors/sensorfw/sensorfwcompass.cpp
@@ -0,0 +1,80 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtSensors module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+#include "sensorfwcompass.h"
+
+char const * const SensorfwCompass::id("sensorfw.compass");
+bool SensorfwCompass::m_initDone = false;
+
+SensorfwCompass::SensorfwCompass(QSensor *sensor)
+ : SensorfwSensorBase(sensor)
+{
+ initSensor<CompassSensorChannelInterface>(m_initDone);
+ setReading<QCompassReading>(&m_reading);
+}
+
+void SensorfwCompass::slotDataAvailable(const Compass& data)
+{
+ // The scale for level is [0,3], where 3 is the best
+ // Qt: Measured as a value from 0 to 1 with higher values being better.
+ m_reading.setCalibrationLevel(((float) data.level()) / 3.0);
+
+ // The scale for degrees from sensord is [0,359]
+ // Value can be directly used as azimuth
+ m_reading.setAzimuth(data.degrees());
+
+ m_reading.setTimestamp(data.data().timestamp_);
+ newReadingAvailable();
+}
+
+
+bool SensorfwCompass::doConnect()
+{
+ return QObject::connect(m_sensorInterface, SIGNAL(dataAvailable(const Compass&)),
+ this, SLOT(slotDataAvailable(const Compass&)));
+}
+
+QString SensorfwCompass::sensorName() const
+{
+ return "compasssensor";
+}
+
diff --git a/src/plugins/sensors/sensorfw/sensorfwcompass.h b/src/plugins/sensors/sensorfw/sensorfwcompass.h
new file mode 100644
index 00000000..e54c348e
--- /dev/null
+++ b/src/plugins/sensors/sensorfw/sensorfwcompass.h
@@ -0,0 +1,70 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtSensors module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#ifndef SENSORFWCOMPASS_H
+#define SENSORFWCOMPASS_H
+
+#include "sensorfwsensorbase.h"
+#include <qcompass.h>
+
+#include <compasssensor_i.h>
+#include <compass.h>
+
+
+
+class SensorfwCompass : public SensorfwSensorBase
+{
+ Q_OBJECT
+
+public:
+ static char const * const id;
+ SensorfwCompass(QSensor *sensor);
+protected:
+ virtual bool doConnect();
+ virtual QString sensorName() const;
+
+private:
+ QCompassReading m_reading;
+ static bool m_initDone;
+private slots:
+ void slotDataAvailable(const Compass& data);
+};
+
+#endif
diff --git a/src/plugins/sensors/sensorfw/sensorfwgyroscope.cpp b/src/plugins/sensors/sensorfw/sensorfwgyroscope.cpp
new file mode 100644
index 00000000..238993ac
--- /dev/null
+++ b/src/plugins/sensors/sensorfw/sensorfwgyroscope.cpp
@@ -0,0 +1,90 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtSensors module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "sensorfwgyroscope.h"
+
+char const * const SensorfwGyroscope::id("sensorfw.gyroscope");
+const float SensorfwGyroscope::MILLI = 0.001;
+bool SensorfwGyroscope::m_initDone = false;
+
+SensorfwGyroscope::SensorfwGyroscope(QSensor *sensor)
+ : SensorfwSensorBase(sensor)
+{
+ initSensor<GyroscopeSensorChannelInterface>(m_initDone);
+ setDescription(QLatin1String("angular velocities around x, y, and z axis in degrees per second"));
+ setRanges(MILLI);
+ setReading<QGyroscopeReading>(&m_reading);
+ addDataRate(10, 10);
+ addDataRate(50, 50);
+}
+
+void SensorfwGyroscope::slotDataAvailable(const XYZ& data)
+{
+ m_reading.setX((qreal)(data.x()*MILLI));
+ m_reading.setY((qreal)(data.y()*MILLI));
+ m_reading.setZ((qreal)(data.z()*MILLI));
+ m_reading.setTimestamp(data.XYZData().timestamp_);
+ newReadingAvailable();
+}
+
+void SensorfwGyroscope::slotFrameAvailable(const QVector<XYZ>& frame)
+{
+ for (int i=0, l=frame.size(); i<l; i++) {
+ slotDataAvailable(frame.at(i));
+ }
+}
+
+bool SensorfwGyroscope::doConnect()
+{
+ if (m_bufferSize==1)
+ return QObject::connect(m_sensorInterface, SIGNAL(dataAvailable(const XYZ&)), this, SLOT(slotDataAvailable(const XYZ&)));
+ return QObject::connect(m_sensorInterface, SIGNAL(frameAvailable(const QVector<XYZ>& )),this, SLOT(slotFrameAvailable(const QVector<XYZ>& )));
+}
+
+QString SensorfwGyroscope::sensorName() const
+{
+ return "gyroscopesensor";
+}
+
+qreal SensorfwGyroscope::correctionFactor() const
+{
+ return MILLI;
+}
diff --git a/src/plugins/sensors/sensorfw/sensorfwgyroscope.h b/src/plugins/sensors/sensorfw/sensorfwgyroscope.h
new file mode 100644
index 00000000..e982c809
--- /dev/null
+++ b/src/plugins/sensors/sensorfw/sensorfwgyroscope.h
@@ -0,0 +1,78 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtSensors module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+#ifndef SENSORFWGYROSCOPE_H
+#define SENSORFWGYROSCOPE_H
+
+#include "sensorfwsensorbase.h"
+#include <qgyroscope.h>
+#include <datatypes/xyz.h>
+#include <gyroscopesensor_i.h>
+
+
+
+
+class SensorfwGyroscope : public SensorfwSensorBase
+{
+ Q_OBJECT
+
+public:
+ static char const * const id;
+ SensorfwGyroscope(QSensor *sensor);
+protected:
+ virtual bool doConnect();
+ virtual QString sensorName() const;
+ virtual qreal correctionFactor() const;
+
+
+private:
+ QGyroscopeReading m_reading;
+ static bool m_initDone;
+ static const float MILLI;
+private slots:
+ void slotDataAvailable(const XYZ& data);
+ void slotFrameAvailable(const QVector<XYZ>&);
+
+};
+
+
+#endif // sensorfwGYROSCOPE_H
diff --git a/src/plugins/sensors/sensorfw/sensorfwirproximitysensor.cpp b/src/plugins/sensors/sensorfw/sensorfwirproximitysensor.cpp
new file mode 100644
index 00000000..865d3760
--- /dev/null
+++ b/src/plugins/sensors/sensorfw/sensorfwirproximitysensor.cpp
@@ -0,0 +1,81 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtSensors module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "sensorfwirproximitysensor.h"
+#define RM680_PS "/dev/bh1770glc_ps"
+
+char const * const SensorfwIrProximitySensor::id("sensorfw.irproximitysensor");
+bool SensorfwIrProximitySensor::m_initDone = false;
+
+
+
+SensorfwIrProximitySensor::SensorfwIrProximitySensor(QSensor *sensor)
+ : SensorfwSensorBase(sensor)
+{
+ initSensor<ProximitySensorChannelInterface>(m_initDone);
+ setReading<QIRProximityReading>(&m_reading);
+ setDescription(QLatin1String("reflectance as percentage (%) of maximum"));
+ addOutputRange(0, 100, 1);
+ addDataRate(10,10);
+ rangeMax = QFile::exists(RM680_PS)?255:1023;
+}
+
+void SensorfwIrProximitySensor::slotDataAvailable(const Proximity& proximity)
+{
+ m_reading.setReflectance((float)proximity.reflectance()*100 / rangeMax);
+ m_reading.setTimestamp(proximity.UnsignedData().timestamp_);
+ newReadingAvailable();
+}
+
+
+bool SensorfwIrProximitySensor::doConnect()
+{
+ return QObject::connect(m_sensorInterface, SIGNAL(reflectanceDataAvailable(const Proximity&)),
+ this, SLOT(slotDataAvailable(const Proximity&)));
+}
+
+
+QString SensorfwIrProximitySensor::sensorName() const
+{
+ return "proximitysensor";
+}
+
+
diff --git a/src/plugins/sensors/sensorfw/sensorfwirproximitysensor.h b/src/plugins/sensors/sensorfw/sensorfwirproximitysensor.h
new file mode 100644
index 00000000..c729f595
--- /dev/null
+++ b/src/plugins/sensors/sensorfw/sensorfwirproximitysensor.h
@@ -0,0 +1,71 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtSensors module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef SENSORFWIRPROXIMITYSENSOR_H
+#define SENSORFWIRPROXIMITYSENSOR_H
+
+#include "sensorfwsensorbase.h"
+#include <qirproximitysensor.h>
+#include <proximitysensor_i.h>
+
+
+class SensorfwIrProximitySensor : public SensorfwSensorBase
+{
+ Q_OBJECT
+
+public:
+ static char const * const id;
+
+ SensorfwIrProximitySensor(QSensor *sensor);
+protected:
+ virtual bool doConnect();
+ virtual QString sensorName() const;
+
+private:
+ QIRProximityReading m_reading;
+ static bool m_initDone;
+ int rangeMax;
+
+private slots:
+ void slotDataAvailable(const Proximity& proximity);
+};
+
+#endif
diff --git a/src/plugins/sensors/sensorfw/sensorfwlightsensor.cpp b/src/plugins/sensors/sensorfw/sensorfwlightsensor.cpp
new file mode 100644
index 00000000..b49e7b2d
--- /dev/null
+++ b/src/plugins/sensors/sensorfw/sensorfwlightsensor.cpp
@@ -0,0 +1,71 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtSensors module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "sensorfwlightsensor.h"
+
+char const * const SensorfwLightSensor::id("sensorfw.lightsensor");
+bool SensorfwLightSensor::m_initDone = false;
+
+SensorfwLightSensor::SensorfwLightSensor(QSensor *sensor)
+ : SensorfwSensorBase(sensor)
+{
+ initSensor<ALSSensorChannelInterface>(m_initDone);
+ setReading<QLightReading>(&m_reading);
+}
+
+void SensorfwLightSensor::slotDataAvailable(const Unsigned& data)
+{
+ m_reading.setLux(data.x());
+ m_reading.setTimestamp(data.UnsignedData().timestamp_);
+ newReadingAvailable();
+}
+
+bool SensorfwLightSensor::doConnect()
+{
+ return QObject::connect(m_sensorInterface, SIGNAL(ALSChanged(const Unsigned&)),
+ this, SLOT(slotDataAvailable(const Unsigned&)));
+}
+
+
+QString SensorfwLightSensor::sensorName() const
+{
+ return "alssensor";
+}
diff --git a/src/plugins/sensors/sensorfw/sensorfwlightsensor.h b/src/plugins/sensors/sensorfw/sensorfwlightsensor.h
new file mode 100644
index 00000000..83591fae
--- /dev/null
+++ b/src/plugins/sensors/sensorfw/sensorfwlightsensor.h
@@ -0,0 +1,72 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtSensors module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+#ifndef SENSORFWLIGHTSENSOR_H
+#define SENSORFWLIGHTSENSOR_H
+
+#include "sensorfwsensorbase.h"
+#include <qlightsensor.h>
+
+#include <alssensor_i.h>
+#include <unsigned.h>
+
+
+
+class SensorfwLightSensor : public SensorfwSensorBase
+{
+ Q_OBJECT
+
+public:
+ static char const * const id;
+ SensorfwLightSensor(QSensor *sensor);
+protected:
+ virtual bool doConnect();
+ virtual QString sensorName() const;
+
+private:
+ QLightReading m_reading;
+ static bool m_initDone;
+private slots:
+ void slotDataAvailable(const Unsigned& data);
+};
+
+#endif
diff --git a/src/plugins/sensors/sensorfw/sensorfwmagnetometer.cpp b/src/plugins/sensors/sensorfw/sensorfwmagnetometer.cpp
new file mode 100644
index 00000000..9778b95c
--- /dev/null
+++ b/src/plugins/sensors/sensorfw/sensorfwmagnetometer.cpp
@@ -0,0 +1,98 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtSensors module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "sensorfwmagnetometer.h"
+
+char const * const SensorfwMagnetometer::id("sensorfw.magnetometer");
+bool SensorfwMagnetometer::m_initDone = false;
+const float SensorfwMagnetometer::NANO = 0.000000001;
+
+
+SensorfwMagnetometer::SensorfwMagnetometer(QSensor *sensor)
+ : SensorfwSensorBase(sensor)
+{
+ initSensor<MagnetometerSensorChannelInterface>(m_initDone);
+ setDescription(QLatin1String("magnetic flux density in teslas (T)"));
+ setRanges(NANO);
+ setReading<QMagnetometerReading>(&m_reading);
+}
+
+void SensorfwMagnetometer::start()
+{
+ m_isGeoMagnetometer = sensor()->returnGeoValues();
+ SensorfwSensorBase::start();
+}
+
+void SensorfwMagnetometer::slotDataAvailable(const MagneticField& data)
+{
+ //nanoTeslas given, divide with 10^9 to get Teslas
+ m_reading.setX( NANO * (m_isGeoMagnetometer?data.x():data.rx()));
+ m_reading.setY( NANO * (m_isGeoMagnetometer?data.y():data.ry()));
+ m_reading.setZ( NANO * (m_isGeoMagnetometer?data.z():data.rz()));
+ m_reading.setCalibrationLevel( m_isGeoMagnetometer?((float) data.level()) / 3.0 :1);
+ m_reading.setTimestamp(data.timestamp());
+ newReadingAvailable();
+}
+
+
+void SensorfwMagnetometer::slotFrameAvailable(const QVector<MagneticField>& frame)
+{
+ for (int i=0, l=frame.size(); i<l; i++) {
+ slotDataAvailable(frame.at(i));
+ }
+}
+
+bool SensorfwMagnetometer::doConnect()
+{
+ if (m_bufferSize==1)
+ return QObject::connect(m_sensorInterface, SIGNAL(dataAvailable(const MagneticField&)), this, SLOT(slotDataAvailable(const MagneticField&)));
+ return QObject::connect(m_sensorInterface, SIGNAL(frameAvailable(const QVector<MagneticField>& )),this, SLOT(slotFrameAvailable(const QVector<MagneticField>& )));
+}
+
+QString SensorfwMagnetometer::sensorName() const
+{
+ return "magnetometersensor";
+}
+
+qreal SensorfwMagnetometer::correctionFactor() const
+{
+ return SensorfwMagnetometer::NANO;
+}
diff --git a/src/plugins/sensors/sensorfw/sensorfwmagnetometer.h b/src/plugins/sensors/sensorfw/sensorfwmagnetometer.h
new file mode 100644
index 00000000..dff70c09
--- /dev/null
+++ b/src/plugins/sensors/sensorfw/sensorfwmagnetometer.h
@@ -0,0 +1,79 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtSensors module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef SENSORFWMAGNETOMETER_H
+#define SENSORFWMAGNETOMETER_H
+
+#include "sensorfwsensorbase.h"
+#include <qmagnetometer.h>
+
+#include <magnetometersensor_i.h>
+#include <magneticfield.h>
+
+
+
+class SensorfwMagnetometer : public SensorfwSensorBase
+{
+ Q_OBJECT
+
+public:
+ static char const * const id;
+ SensorfwMagnetometer(QSensor *sensor);
+protected:
+ virtual bool doConnect();
+ virtual void start();
+ virtual QString sensorName() const;
+ virtual qreal correctionFactor() const;
+
+
+private:
+ static const float NANO;
+ QMagnetometerReading m_reading;
+ static bool m_initDone;
+ bool m_isGeoMagnetometer;
+
+private slots:
+ void slotDataAvailable(const MagneticField& data);
+ void slotFrameAvailable(const QVector<MagneticField>&);
+
+};
+
+#endif
diff --git a/src/plugins/sensors/sensorfw/sensorfworientationsensor.cpp b/src/plugins/sensors/sensorfw/sensorfworientationsensor.cpp
new file mode 100644
index 00000000..09dfb0eb
--- /dev/null
+++ b/src/plugins/sensors/sensorfw/sensorfworientationsensor.cpp
@@ -0,0 +1,98 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtSensors module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "sensorfworientationsensor.h"
+
+#include <posedata.h>
+
+char const * const SensorfwOrientationSensor::id("sensorfw.orientationsensor");
+bool SensorfwOrientationSensor::m_initDone = false;
+
+SensorfwOrientationSensor::SensorfwOrientationSensor(QSensor *sensor)
+ : SensorfwSensorBase(sensor)
+{
+ initSensor<OrientationSensorChannelInterface>(m_initDone);
+ setReading<QOrientationReading>(&m_reading);
+}
+
+
+void SensorfwOrientationSensor::start()
+{
+ if (m_sensorInterface) {
+ Unsigned data(((OrientationSensorChannelInterface*)m_sensorInterface)->orientation());
+ m_reading.setOrientation(SensorfwOrientationSensor::getOrientation(data.x()));
+ m_reading.setTimestamp(data.UnsignedData().timestamp_);
+ newReadingAvailable();
+ }
+ SensorfwSensorBase::start();
+}
+
+
+void SensorfwOrientationSensor::slotDataAvailable(const Unsigned& data)
+{
+ m_reading.setOrientation(SensorfwOrientationSensor::getOrientation(data.x()));
+ m_reading.setTimestamp(data.UnsignedData().timestamp_);
+ newReadingAvailable();
+}
+
+bool SensorfwOrientationSensor::doConnect()
+{
+ return QObject::connect(m_sensorInterface, SIGNAL(orientationChanged(const Unsigned&)),
+ this, SLOT(slotDataAvailable(const Unsigned&)));
+}
+
+QString SensorfwOrientationSensor::sensorName() const
+{
+ return "orientationsensor";
+}
+
+QOrientationReading::Orientation SensorfwOrientationSensor::getOrientation(int orientation)
+{
+ switch (orientation) {
+ case PoseData::BottomDown: return QOrientationReading::TopUp;
+ case PoseData::BottomUp: return QOrientationReading::TopDown;
+ case PoseData::LeftUp: return QOrientationReading::LeftUp;
+ case PoseData::RightUp: return QOrientationReading::RightUp;
+ case PoseData::FaceUp: return QOrientationReading::FaceUp;
+ case PoseData::FaceDown: return QOrientationReading::FaceDown;
+ }
+ return QOrientationReading::Undefined;
+}
diff --git a/src/plugins/sensors/sensorfw/sensorfworientationsensor.h b/src/plugins/sensors/sensorfw/sensorfworientationsensor.h
new file mode 100644
index 00000000..496939ce
--- /dev/null
+++ b/src/plugins/sensors/sensorfw/sensorfworientationsensor.h
@@ -0,0 +1,74 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtSensors module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef SENSORFWORIENTATIONSENSOR_H
+#define SENSORFWORIENTATIONSENSOR_H
+
+#include "sensorfwsensorbase.h"
+#include <qorientationsensor.h>
+
+#include <orientationsensor_i.h>
+#include <unsigned.h>
+
+
+
+class SensorfwOrientationSensor : public SensorfwSensorBase
+{
+ Q_OBJECT
+
+public:
+ static char const * const id;
+ SensorfwOrientationSensor(QSensor *sensor);
+protected:
+ virtual bool doConnect();
+ virtual QString sensorName() const;
+ virtual void start();
+
+private:
+ QOrientationReading m_reading;
+ static QOrientationReading::Orientation getOrientation(int orientation);
+ static bool m_initDone;
+
+private slots:
+ void slotDataAvailable(const Unsigned& orientation);
+};
+
+#endif
diff --git a/src/plugins/sensors/sensorfw/sensorfwproximitysensor.cpp b/src/plugins/sensors/sensorfw/sensorfwproximitysensor.cpp
new file mode 100644
index 00000000..4602a9a1
--- /dev/null
+++ b/src/plugins/sensors/sensorfw/sensorfwproximitysensor.cpp
@@ -0,0 +1,87 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtSensors module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "sensorfwproximitysensor.h"
+
+char const * const SensorfwProximitySensor::id("sensorfw.proximitysensor");
+bool SensorfwProximitySensor::m_initDone = false;
+
+SensorfwProximitySensor::SensorfwProximitySensor(QSensor *sensor)
+ : SensorfwSensorBase(sensor), m_exClose(false)
+{
+ initSensor<ProximitySensorChannelInterface>(m_initDone);
+ setReading<QProximityReading>(&m_reading);
+ addDataRate(10,10); //TODO: fix this when we know better
+}
+
+void SensorfwProximitySensor::start()
+{
+ if (m_sensorInterface) {
+ Unsigned data(((ProximitySensorChannelInterface*)m_sensorInterface)->proximity());
+ m_reading.setClose(data.x()? true: false);
+ m_reading.setTimestamp(data.UnsignedData().timestamp_);
+ newReadingAvailable();
+ }
+ SensorfwSensorBase::start();
+}
+
+
+void SensorfwProximitySensor::slotDataAvailable(const Unsigned& data)
+{
+ bool close = data.x()? true: false;
+ if (close == m_exClose) return;
+ m_reading.setClose(close);
+ m_reading.setTimestamp(data.UnsignedData().timestamp_);
+ newReadingAvailable();
+ m_exClose = close;
+}
+
+bool SensorfwProximitySensor::doConnect()
+{
+ return (QObject::connect(m_sensorInterface, SIGNAL(dataAvailable(const Unsigned&)),
+ this, SLOT(slotDataAvailable(const Unsigned&))));
+}
+
+
+QString SensorfwProximitySensor::sensorName() const
+{
+ return "proximitysensor";
+}
diff --git a/src/plugins/sensors/sensorfw/sensorfwproximitysensor.h b/src/plugins/sensors/sensorfw/sensorfwproximitysensor.h
new file mode 100644
index 00000000..91800c2e
--- /dev/null
+++ b/src/plugins/sensors/sensorfw/sensorfwproximitysensor.h
@@ -0,0 +1,75 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtSensors module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef SENSORFWPROXIMITYSENSOR_H
+#define SENSORFWPROXIMITYSENSOR_H
+
+#include "sensorfwsensorbase.h"
+#include <qproximitysensor.h>
+
+#include <proximitysensor_i.h>
+#include <unsigned.h>
+
+
+
+class SensorfwProximitySensor : public SensorfwSensorBase
+{
+ Q_OBJECT
+
+public:
+ static char const * const id;
+ SensorfwProximitySensor(QSensor *sensor);
+protected:
+ virtual bool doConnect();
+ virtual QString sensorName() const;
+ virtual void start();
+
+
+private:
+ QProximityReading m_reading;
+ static bool m_initDone;
+ bool m_exClose;
+
+private slots:
+ void slotDataAvailable(const Unsigned& data);
+};
+
+#endif
diff --git a/src/plugins/sensors/sensorfw/sensorfwrotationsensor.cpp b/src/plugins/sensors/sensorfw/sensorfwrotationsensor.cpp
new file mode 100644
index 00000000..d5774022
--- /dev/null
+++ b/src/plugins/sensors/sensorfw/sensorfwrotationsensor.cpp
@@ -0,0 +1,79 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtSensors module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "sensorfwrotationsensor.h"
+
+char const * const SensorfwRotationSensor::id("sensorfw.rotationsensor");
+bool SensorfwRotationSensor::m_initDone = false;
+
+SensorfwRotationSensor::SensorfwRotationSensor(QSensor *sensor)
+ : SensorfwSensorBase(sensor)
+{
+ initSensor<RotationSensorChannelInterface>(m_initDone);
+ setReading<QRotationReading>(&m_reading);
+ sensor()->setHasZ(true);
+}
+
+void SensorfwRotationSensor::slotDataAvailable(const XYZ& data)
+{
+ m_reading.setFromEuler(data.x(),data.y(),data.z());
+ m_reading.setTimestamp(data.XYZData().timestamp_);
+ newReadingAvailable();
+}
+
+void SensorfwRotationSensor::slotFrameAvailable(const QVector<XYZ>& frame)
+{
+ for (int i=0, l=frame.size(); i<l; i++) {
+ slotDataAvailable(frame.at(i));
+ }
+}
+
+bool SensorfwRotationSensor::doConnect()
+{
+ if (m_bufferSize==1)
+ return QObject::connect(m_sensorInterface, SIGNAL(dataAvailable(const XYZ&)), this, SLOT(slotDataAvailable(const XYZ&)));
+ return QObject::connect(m_sensorInterface, SIGNAL(frameAvailable(const QVector<XYZ>& )),this, SLOT(slotFrameAvailable(const QVector<XYZ>& )));
+}
+
+QString SensorfwRotationSensor::sensorName() const
+{
+ return "rotationsensor";
+}
diff --git a/src/plugins/sensors/sensorfw/sensorfwrotationsensor.h b/src/plugins/sensors/sensorfw/sensorfwrotationsensor.h
new file mode 100644
index 00000000..5b5556df
--- /dev/null
+++ b/src/plugins/sensors/sensorfw/sensorfwrotationsensor.h
@@ -0,0 +1,75 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtSensors module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+#ifndef SENSORFWROTATION_H
+#define SENSORFWROTATION_H
+
+#include "sensorfwsensorbase.h"
+#include <qrotationsensor.h>
+
+#include <rotationsensor_i.h>
+#include <xyz.h>
+
+
+
+class SensorfwRotationSensor : public SensorfwSensorBase
+{
+ Q_OBJECT
+
+public:
+ static char const * const id;
+ SensorfwRotationSensor(QSensor *sensor);
+protected:
+ virtual bool doConnect();
+ virtual QString sensorName() const;
+
+private:
+ QRotationReading m_reading;
+ static bool m_initDone;
+
+private slots:
+ void slotDataAvailable(const XYZ& data);
+ void slotFrameAvailable(const QVector<XYZ>&);
+
+};
+
+#endif
diff --git a/src/plugins/sensors/sensorfw/sensorfwsensorbase.cpp b/src/plugins/sensors/sensorfw/sensorfwsensorbase.cpp
new file mode 100644
index 00000000..85968e22
--- /dev/null
+++ b/src/plugins/sensors/sensorfw/sensorfwsensorbase.cpp
@@ -0,0 +1,189 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtSensors module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "sensorfwsensorbase.h"
+
+
+SensorManagerInterface* SensorfwSensorBase::m_remoteSensorManager = 0;
+
+//According to wikipedia link http://en.wikipedia.org/wiki/Standard_gravity
+//const float sensorfwsensorbase::GRAVITY_EARTH = 9.812865328;
+const float SensorfwSensorBase::GRAVITY_EARTH_THOUSANDTH = 0.009812865328;
+const int SensorfwSensorBase::KErrNotFound=-1;
+const int SensorfwSensorBase::KErrInUse=-14;
+QStringList SensorfwSensorBase::m_bufferingSensors = QStringList()
+ <<"sensorfw.accelerometer"<<"sensorfw.magnetometer"
+ <<"sensorfw.gyroscope"<<"sensorfw.rotationsensor";
+
+SensorfwSensorBase::SensorfwSensorBase(QSensor *sensor)
+ : QSensorBackend(sensor), m_sensorInterface(0), m_bufferSize(-1), m_prevOutputRange(0), m_efficientBufferSize(1), m_maxBufferSize(1)
+{
+ if (!m_remoteSensorManager)
+ m_remoteSensorManager = &SensorManagerInterface::instance();
+}
+
+SensorfwSensorBase::~SensorfwSensorBase()
+{
+ if (m_sensorInterface) {
+ stop();
+ delete m_sensorInterface, m_sensorInterface = 0;
+ }
+}
+
+void SensorfwSensorBase::start()
+{
+ if (m_sensorInterface) {
+ // dataRate
+ QByteArray type = sensor()->type();
+ if (type != QTapSensor::type() && type != QProximitySensor::type()) {
+ int dataRate = sensor()->dataRate();
+ int interval = dataRate > 0 ? 1000 / dataRate : 0;
+ // for testing maximum speed
+ //interval = 1;
+ //dataRate = 1000;
+ m_sensorInterface->setInterval(interval);
+ }
+
+ // outputRange
+ int currentRange = sensor()->outputRange();
+ int l = sensor()->outputRanges().size();
+ if (l > 1) {
+ if (currentRange != m_prevOutputRange) {
+//#ifdef Q_WS_MAEMO_6
+ bool isOk = m_sensorInterface->setDataRangeIndex(currentRange); //NOTE THAT THE CHANGE MIGHT NOT SUCCEED, FIRST COME FIRST SERVED
+ if (!isOk) sensorError(KErrInUse);
+ else m_prevOutputRange = currentRange;
+//#else
+// // TODO: remove when sensord integrated, in sensorfw env there is a delay
+// qoutputrange range = sensor()->outputRanges().at(currentRange);
+// qreal correction = 1/correctionFactor();
+// DataRange range1(range.minimum*correction, range.maximum*correction, range.accuracy*correction);
+// m_sensorInterface->requestDataRange(range1);
+// m_prevOutputRange = currentRange;
+//#endif
+ }
+ }
+
+ // always on
+ bool alwaysOn = sensor()->isAlwaysOn();
+ m_sensorInterface->setStandbyOverride(alwaysOn);
+
+ // connects after buffering checks
+ doConnectAfterCheck();
+
+ int returnCode = m_sensorInterface->start().error().type();
+ if (returnCode == 0) return;
+ qWarning() << "m_sensorInterface did not start, error code:" << returnCode;
+ }
+ sensorStopped();
+}
+
+void SensorfwSensorBase::stop()
+{
+ if (m_sensorInterface) m_sensorInterface->stop();
+}
+
+void SensorfwSensorBase::setRanges(qreal correctionFactor)
+{
+ if (!m_sensorInterface) return;
+
+ QList<DataRange> ranges = m_sensorInterface->getAvailableDataRanges();
+
+ for (int i = 0, l = ranges.size(); i < l; i++) {
+ DataRange range = ranges.at(i);
+ qreal rangeMin = range.min * correctionFactor;
+ qreal rangeMax = range.max * correctionFactor;
+ qreal resolution = range.resolution * correctionFactor;
+ addOutputRange(rangeMin, rangeMax, resolution);
+ }
+}
+
+
+bool SensorfwSensorBase::doConnectAfterCheck()
+{
+ if (!m_sensorInterface) return false;
+
+ // buffer size
+ int size = bufferSize();
+ if (size == m_bufferSize) return true;
+
+ if (m_bufferingSensors.contains(sensor()->identifier()))
+ m_sensorInterface->setBufferSize(size);
+ else
+ size = 1;
+
+ // if multiple->single or single->multiple or if uninitialized
+ if ((m_bufferSize > 1 && size == 1) || (m_bufferSize == 1 && size > 1) || m_bufferSize == -1) {
+ m_bufferSize = size;
+ disconnect(this);
+ if (!doConnect()) {
+ qWarning() << "Unable to connect "<< sensorName();
+ return false;
+ }
+ return true;
+ }
+ m_bufferSize = size;
+ return true;
+}
+
+int SensorfwSensorBase::bufferSize() const
+{
+ int bufferSize = sensor()->bufferSize();
+ if (bufferSize == 1)
+ return 1;
+
+ // otherwise check validit
+ if (bufferSize < 1) {
+ qWarning() << "bufferSize cannot be " << bufferSize << ", must be a positive number >= 1";
+ return 1;
+ }
+ if (bufferSize > m_maxBufferSize) {
+ qWarning() << "bufferSize cannot be " << bufferSize << ", MAX value is " << m_maxBufferSize;
+ return m_maxBufferSize;
+ }
+ return bufferSize;
+}
+
+qreal SensorfwSensorBase::correctionFactor() const
+{
+ return 1;
+}
+
diff --git a/src/plugins/sensors/sensorfw/sensorfwsensorbase.h b/src/plugins/sensors/sensorfw/sensorfwsensorbase.h
new file mode 100644
index 00000000..78a6c14f
--- /dev/null
+++ b/src/plugins/sensors/sensorfw/sensorfwsensorbase.h
@@ -0,0 +1,170 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtSensors module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+#ifndef SENSORFWSENSORBASE_H
+#define SENSORFWSENSORBASE_H
+
+#include <qsensorbackend.h>
+#include <sensormanagerinterface.h>
+#include <abstractsensor_i.h>
+
+class SensorfwSensorBase : public QSensorBackend
+{
+public:
+ SensorfwSensorBase(QSensor *sensor);
+ virtual ~SensorfwSensorBase();
+
+
+protected:
+ virtual bool doConnect()=0;
+ virtual void start();
+ virtual void stop();
+
+ static const float GRAVITY_EARTH;
+ static const float GRAVITY_EARTH_THOUSANDTH; //for speed
+ static const int KErrNotFound;
+ static const int KErrInUse;
+ static QStringList m_bufferingSensors;
+
+ void setRanges(qreal correctionFactor=1);
+ virtual QString sensorName() const=0;
+
+ template<typename T>
+ void initSensor(bool &initDone)
+ {
+
+ const QString name = sensorName();
+
+ if (!initDone) {
+ if (!m_remoteSensorManager->loadPlugin(name)) {
+ sensorError(KErrNotFound);
+ return;
+ }
+ m_remoteSensorManager->registerSensorInterface<T>(name);
+ }
+ m_sensorInterface = T::controlInterface(name);
+ if (!m_sensorInterface) {
+ m_sensorInterface = const_cast<T*>(T::listenInterface(name));
+ }
+ if (!m_sensorInterface) {
+ sensorError(KErrNotFound);
+ return;
+ }
+ if (!m_sensorInterface) {
+ sensorError(KErrNotFound);
+ return;
+ }
+
+ initDone = true;
+
+ //metadata
+ QList<DataRange> intervals = m_sensorInterface->getAvailableIntervals();
+
+ for (int i = 0, l = intervals.size(); i < l; i++) {
+ qreal intervalMax = ((DataRange)(intervals.at(i))).max;
+ qreal intervalMin =((DataRange)(intervals.at(i))).min;
+
+ if (intervalMin == 0 && intervalMax == 0) {
+ // 0 interval has different meanings in e.g. magge/acce
+ // magge -> best-effort
+ // acce -> lowest possible
+ // in Qt API setting 0 means default
+ continue;
+ }
+
+ qreal rateMin = intervalMax < 1 ? 1 : 1 / intervalMax * 1000;
+ rateMin = rateMin < 1 ? 1 : rateMin;
+
+ intervalMin = intervalMin < 1 ? 10: intervalMin; // do not divide with 0
+ qreal rateMax = 1 / intervalMin * 1000;
+ addDataRate(rateMin, rateMax);
+ }
+
+ //bufferSizes
+ if (m_bufferingSensors.contains(sensor()->identifier())) {
+
+ IntegerRangeList sizes = m_sensorInterface->getAvailableBufferSizes();
+ int l = sizes.size();
+ for (int i = 0; i < l; i++) {
+ int second = sizes.at(i).second;
+ m_maxBufferSize = second > m_bufferSize ? second : m_maxBufferSize;
+ }
+ m_maxBufferSize = m_maxBufferSize < 0 ? 1 : m_maxBufferSize;
+ //SensorFW guarantees to provide the most efficient size first
+ //TODO: remove from comments
+ //m_efficientBufferSize = m_sensorInterface->hwBuffering()? (l>0?sizes.at(0).first:1) : 1;
+ }
+ else
+ m_maxBufferSize = 1;
+
+ sensor()->setMaxBufferSize(m_maxBufferSize);
+ sensor()->efficientBufferSize(m_efficientBufferSize);
+
+ QByteArray type = sensor()->type();
+ if (type == QAmbientLightSensor::type()) return; // SensorFW returns lux values, plugin enumerated values
+ if (type == QIRProximitySensor::type()) return; // SensorFW returns raw reflectance values, plugin % of max reflectance
+ if (name == "accelerometersensor") return; // SensorFW returns milliGs, plugin m/s^2
+ if (name == "magnetometersensor") return; // SensorFW returns nanoTeslas, plugin Teslas
+ if (name == "gyroscopesensor") return; // SensorFW returns DSPs, plugin milliDSPs
+
+ setDescription(m_sensorInterface->description());
+
+ if (name == "tapsensor") return;
+ setRanges();
+ };
+
+
+ AbstractSensorChannelInterface* m_sensorInterface;
+ int m_bufferSize;
+ int bufferSize() const;
+ virtual qreal correctionFactor() const;
+
+private:
+
+ static SensorManagerInterface* m_remoteSensorManager;
+ int m_prevOutputRange;
+ bool doConnectAfterCheck();
+ int m_efficientBufferSize, m_maxBufferSize;
+
+};
+
+#endif
diff --git a/src/plugins/sensors/sensorfw/sensorfwtapsensor.cpp b/src/plugins/sensors/sensorfw/sensorfwtapsensor.cpp
new file mode 100644
index 00000000..c945ac11
--- /dev/null
+++ b/src/plugins/sensors/sensorfw/sensorfwtapsensor.cpp
@@ -0,0 +1,110 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtSensors module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "sensorfwtapsensor.h"
+
+char const * const SensorfwTapSensor::id("sensorfw.tapsensor");
+bool SensorfwTapSensor::m_initDone = false;
+
+SensorfwTapSensor::SensorfwTapSensor(QSensor *sensor)
+ : SensorfwSensorBase(sensor), m_isOnceStarted(false)
+{
+ initSensor<TapSensorChannelInterface>(m_initDone);
+ setReading<QTapReading>(&m_reading);
+ addOutputRange(QTapReading::Undefined, QTapReading::Z_Both, 1);
+ addDataRate(10,10); //TODO: fix this when we know better
+}
+
+
+void SensorfwTapSensor::start()
+{
+ bool b = sensor()->returnDoubleTapEvents();
+ bool isDoubleTapSensor = m_isDoubleTapSensor;
+ if (!b) {
+ sensor()->setReturnDoubleTapEvents(true); //by default doubles
+ m_isDoubleTapSensor = true;
+ }
+ else m_isDoubleTapSensor = b;
+
+ if (!m_isOnceStarted || (m_isOnceStarted && isDoubleTapSensor != m_isDoubleTapSensor))
+ ((TapSensorChannelInterface*)m_sensorInterface)->
+ setTapType(m_isDoubleTapSensor?TapSensorChannelInterface::Double:TapSensorChannelInterface::Single);
+
+ SensorfwSensorBase::start();
+ // Set tap type (single/double)
+ m_reading.setDoubleTap(m_isDoubleTapSensor);
+ m_isOnceStarted = true;
+}
+
+
+void SensorfwTapSensor::slotDataAvailable(const Tap& data)
+{
+ // Set tap direction
+ QTapReading::TapDirection o;
+ switch (data.direction()) {
+ case TapData::X: o = QTapReading::X_Both; break;
+ case TapData::Y: o = QTapReading::Y_Both; break;
+ case TapData::Z: o = QTapReading::Z_Both; break;
+ case TapData::LeftRight: o = QTapReading::X_Pos; break;
+ case TapData::RightLeft: o = QTapReading::X_Neg; break;
+ case TapData::TopBottom: o = QTapReading::Z_Neg; break;
+ case TapData::BottomTop: o = QTapReading::Z_Pos; break;
+ case TapData::FaceBack: o = QTapReading::Y_Pos; break;
+ case TapData::BackFace: o = QTapReading::Y_Neg; break;
+ default: o = QTapReading::Undefined;
+ }
+ m_reading.setTapDirection(o);
+ m_reading.setTimestamp(data.tapData().timestamp_);
+ newReadingAvailable();
+}
+
+
+bool SensorfwTapSensor::doConnect()
+{
+ return QObject::connect(m_sensorInterface, SIGNAL(dataAvailable(const Tap&)),
+ this, SLOT(slotDataAvailable(const Tap&)));
+}
+
+
+QString SensorfwTapSensor::sensorName() const
+{
+ return "tapsensor";
+}
diff --git a/src/plugins/sensors/sensorfw/sensorfwtapsensor.h b/src/plugins/sensors/sensorfw/sensorfwtapsensor.h
new file mode 100644
index 00000000..6df3bcfb
--- /dev/null
+++ b/src/plugins/sensors/sensorfw/sensorfwtapsensor.h
@@ -0,0 +1,73 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtSensors module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#ifndef SENSORFWTAPSENSOR_H
+#define SENSORFWTAPSENSOR_H
+
+#include "sensorfwsensorbase.h"
+#include <qtapsensor.h>
+
+#include <tapsensor_i.h>
+#include <tap.h>
+
+
+
+class SensorfwTapSensor : public SensorfwSensorBase
+{
+ Q_OBJECT
+
+public:
+ static char const * const id;
+ SensorfwTapSensor(QSensor *sensor);
+protected:
+ virtual bool doConnect();
+ virtual void start();
+ virtual QString sensorName() const;
+
+private:
+ QTapReading m_reading;
+ static bool m_initDone;
+ bool m_isDoubleTapSensor;
+ bool m_isOnceStarted;
+private slots:
+ void slotDataAvailable(const Tap&);
+};
+
+#endif
diff --git a/src/plugins/sensors/sensors.pro b/src/plugins/sensors/sensors.pro
index df63f36d..73f42672 100644
--- a/src/plugins/sensors/sensors.pro
+++ b/src/plugins/sensors/sensors.pro
@@ -1,12 +1,24 @@
TEMPLATE = subdirs
-# Don't build dummy and generic plugins by default, the Blackberry backend has real implementations
+# Don't build dummy plugins, the Blackberry backend has real implementations
# of these. This reduces compile time and plugin loading time.
blackberry {
- isEmpty(SENSORS_PLUGINS): SENSORS_PLUGINS = blackberry
+ isEmpty(SENSORS_PLUGINS): SENSORS_PLUGINS = blackberry generic
}
+
+android {
+ isEmpty(SENSORS_PLUGINS): SENSORS_PLUGINS = android generic
+}
+
+sensorfw {
+ isEmpty(SENSORS_PLUGINS): SENSORS_PLUGINS = sensorfw generic
+}
+
isEmpty(SENSORS_PLUGINS)|contains(SENSORS_PLUGINS, dummy):SUBDIRS += dummy
isEmpty(SENSORS_PLUGINS)|contains(SENSORS_PLUGINS, generic):SUBDIRS += generic
isEmpty(SENSORS_PLUGINS)|contains(SENSORS_PLUGINS, simulator):simulator:SUBDIRS += simulator
isEmpty(SENSORS_PLUGINS)|contains(SENSORS_PLUGINS, blackberry):blackberry:SUBDIRS += blackberry
isEmpty(SENSORS_PLUGINS)|contains(SENSORS_PLUGINS, linux):linux:SUBDIRS += linux
+isEmpty(SENSORS_PLUGINS)|contains(SENSORS_PLUGINS, android):android:SUBDIRS += android
+isEmpty(SENSORS_PLUGINS)|contains(SENSORS_PLUGINS, sensorfw):sensorfw:SUBDIRS += sensorfw
+isEmpty(SENSORS_PLUGINS)|contains(SENSORS_PLUGINS, ios):ios:SUBDIRS += ios
diff --git a/src/sensors/doc/qtsensors.qdocconf b/src/sensors/doc/qtsensors.qdocconf
index 7c53c02b..2ede8cf4 100644
--- a/src/sensors/doc/qtsensors.qdocconf
+++ b/src/sensors/doc/qtsensors.qdocconf
@@ -3,33 +3,36 @@ include($QT_INSTALL_DOCS/global/qt-module-defaults.qdocconf)
project = QtSensors
description = Qt Sensors Reference Documentation
-url = http://qt-project.org/doc/qt-5.0/qtsensors-index.html
-version = 5.0.0
+url = http://qt-project.org/doc/qt-$QT_VER/qtsensors
+version = $QT_VERSION
qhp.projects = QtSensors
qhp.QtSensors.file = qtsensors.qhp
-qhp.QtSensors.namespace = org.qt-project.qtsensors.500
-qhp.QtSensors.virtualFolder = qdoc
-qhp.QtSensors.indexTitle = Qt Sensors Reference Documentation
+qhp.QtSensors.namespace = org.qt-project.qtsensors.$QT_VERSION_TAG
+qhp.QtSensors.virtualFolder = qtsensors
+qhp.QtSensors.indexTitle = Qt Sensors
qhp.QtSensors.indexRoot =
-qhp.QtSensors.filterAttributes = qtsensors 5.0.0 qtrefdoc
-qhp.QtSensors.customFilters.Qt.name = QtSensors 5.0.0
-qhp.QtSensors.customFilters.Qt.filterAttributes = qtsensors 5.0.0
-qhp.QtSensors.subprojects = classes overviews examples
-qhp.QtSensors.subprojects.classes.title = Classes
-qhp.QtSensors.subprojects.classes.indexTitle = Qt Sensors's Classes
+qhp.QtSensors.filterAttributes = qtsensors $QT_VERSION qtrefdoc
+qhp.QtSensors.customFilters.Qt.name = QtSensors $QT_VERSION
+qhp.QtSensors.customFilters.Qt.filterAttributes = qtsensors $QT_VERSION
+qhp.QtSensors.subprojects = overviews classes qmltypes examples
+qhp.QtSensors.subprojects.overviews.title = Overview
+qhp.QtSensors.subprojects.overviews.indexTitle = Qt Sensors
+qhp.QtSensors.subprojects.overviews.selectors = fake:page,group,module
+qhp.QtSensors.subprojects.classes.title = C++ Classes
+qhp.QtSensors.subprojects.classes.indexTitle = Qt Sensors C++ Classes
qhp.QtSensors.subprojects.classes.selectors = class fake:headerfile
qhp.QtSensors.subprojects.classes.sortPages = true
-qhp.QtSensors.subprojects.overviews.title = Overviews
-qhp.QtSensors.subprojects.overviews.indexTitle = All Overviews and HOWTOs
-qhp.QtSensors.subprojects.overviews.selectors = fake:page,group,module
-qhp.QtSensors.subprojects.examples.title = Qt Sensors Examples
+qhp.QtSensors.subprojects.qmltypes.title = QML Types
+qhp.QtSensors.subprojects.qmltypes.indexTitle = Qt Sensors QML Types
+qhp.QtSensors.subprojects.qmltypes.selectors = fake:qmlclass
+qhp.QtSensors.subprojects.qmltypes.sortPages = true
+qhp.QtSensors.subprojects.examples.title = Examples
qhp.QtSensors.subprojects.examples.indexTitle = Qt Sensors Examples
qhp.QtSensors.subprojects.examples.selectors = fake:example
-outputdir = ../../../doc/qtsensors
tagfile = ../../../doc/qtsensors/qtsensors.tags
headerdirs += .. \
@@ -45,3 +48,5 @@ exampledirs += ../../../examples/sensors \
imagedirs += images
+
+depends += qtcore qtdoc qtgui
diff --git a/src/sensors/doc/src/compatmap.qdoc b/src/sensors/doc/src/compatmap.qdoc
index 0fd4951c..62f94de0 100644
--- a/src/sensors/doc/src/compatmap.qdoc
+++ b/src/sensors/doc/src/compatmap.qdoc
@@ -54,30 +54,72 @@
<tr>
<td><b>Feature</b></td>
<td><b>Blackberry</b></td>
+ <td><b>Android</b></td>
<td><b>Linux</b></td>
+ <td><b>iOS</b></td>
<td><b>Generic</b></td>
+ <td><b>Sensorfw</b></td>
</tr>
<tr>
<td nowrap="nowrap">Accelerometer</td>
<td bgcolor="green"></td>
<td bgcolor="green"></td>
+ <td bgcolor="green"></td>
+ <td bgcolor="green"></td>
+ <td bgcolor="gray"></td>
+ <td bgcolor="green"></td>
+ </tr>
+ <tr>
+ <td nowrap="nowrap">Altimeter</td>
+ <td bgcolor="green"></td>
+ <td bgcolor="gray"></td>
+ <td bgcolor="gray"></td>
+ <td bgcolor="gray"></td>
+ <td bgcolor="gray"></td>
<td bgcolor="gray"></td>
</tr>
<tr>
<td nowrap="nowrap">Ambient Light Sensor</td>
<td bgcolor="green"></td>
<td bgcolor="gray"></td>
+ <td bgcolor="gray"></td>
+ <td bgcolor="gray"></td>
+ <td bgcolor="gray"></td>
<td bgcolor="green"></td>
</tr>
<tr>
+ <td nowrap="nowrap">Ambient Temperature Sensor</td>
+ <td bgcolor="gray"></td>
+ <td bgcolor="gray"></td>
+ <td bgcolor="gray"></td>
+ <td bgcolor="gray"></td>
+ <td bgcolor="gray"></td>
+ <td bgcolor="gray"></td>
+ </tr>
+ <tr>
<td nowrap="nowrap">Compass</td>
<td bgcolor="green"></td>
<td bgcolor="gray"></td>
<td bgcolor="gray"></td>
+ <td bgcolor="gray"></td>
+ <td bgcolor="gray"></td>
+ <td bgcolor="green"></td>
</tr>
<tr>
<td nowrap="nowrap">Gyroscope</td>
<td bgcolor="green"></td>
+ <td bgcolor="green"></td>
+ <td bgcolor="gray"></td>
+ <td bgcolor="gray"></td>
+ <td bgcolor="gray"></td>
+ <td bgcolor="green"></td>
+ </tr>
+ <tr>
+ <td nowrap="nowrap">Holster Sensor</td>
+ <td bgcolor="green"></td>
+ <td bgcolor="gray"></td>
+ <td bgcolor="gray"></td>
+ <td bgcolor="gray"></td>
<td bgcolor="gray"></td>
<td bgcolor="gray"></td>
</tr>
@@ -86,48 +128,90 @@
<td bgcolor="green"></td>
<td bgcolor="gray"></td>
<td bgcolor="gray"></td>
+ <td bgcolor="gray"></td>
+ <td bgcolor="gray"></td>
+ <td bgcolor="green"></td>
</tr>
<tr>
<td nowrap="nowrap">Light Sensor</td>
<td bgcolor="green"></td>
+ <td bgcolor="green"></td>
+ <td bgcolor="gray"></td>
<td bgcolor="gray"></td>
<td bgcolor="gray"></td>
+ <td bgcolor="green"></td>
</tr>
<tr>
<td nowrap="nowrap">Magnetometer</td>
<td bgcolor="green"></td>
+ <td bgcolor="green"></td>
+ <td bgcolor="gray"></td>
<td bgcolor="gray"></td>
<td bgcolor="gray"></td>
+ <td bgcolor="green"></td>
</tr>
<tr>
<td nowrap="nowrap">Orientation Sensor</td>
<td bgcolor="green"></td>
<td bgcolor="gray"></td>
+ <td bgcolor="gray"></td>
+ <td bgcolor="gray"></td>
+ <td bgcolor="green"></td>
+ <td bgcolor="green"></td>
+ </tr>
+ <tr>
+ <td nowrap="nowrap">Pressure Sensor</td>
<td bgcolor="green"></td>
+ <td bgcolor="gray"></td>
+ <td bgcolor="gray"></td>
+ <td bgcolor="gray"></td>
+ <td bgcolor="gray"></td>
+ <td bgcolor="gray"></td>
</tr>
<tr>
<td nowrap="nowrap">Proximity Sensor</td>
<td bgcolor="green"></td>
<td bgcolor="gray"></td>
<td bgcolor="gray"></td>
+ <td bgcolor="gray"></td>
+ <td bgcolor="gray"></td>
+ <td bgcolor="green"></td>
</tr>
<tr>
<td nowrap="nowrap">Rotation Sensor</td>
<td bgcolor="green"></td>
+ <td bgcolor="green"></td>
+ <td bgcolor="gray"></td>
<td bgcolor="gray"></td>
<td bgcolor="green"></td>
+ <td bgcolor="green"></td>
</tr>
<tr>
<td nowrap="nowrap">Tap Sensor</td>
<td bgcolor="gray"></td>
<td bgcolor="gray"></td>
<td bgcolor="gray"></td>
+ <td bgcolor="gray"></td>
+ <td bgcolor="gray"></td>
+ <td bgcolor="gray"></td>
+ </tr>
+ <tr>
+ <td nowrap="nowrap">Tilt Sensor</td>
+ <td bgcolor="gray"></td>
+ <td bgcolor="gray"></td>
+ <td bgcolor="gray"></td>
+ <td bgcolor="gray"></td>
+ <td bgcolor="green"></td>
+ <td bgcolor="gray"></td>
</tr>
<tr>
<td nowrap="nowrap">Sensor Gestures</td>
<td bgcolor="gray"></td>
<td bgcolor="gray"></td>
- <td bgcolor="green">1)</td>
+ <td bgcolor="gray"></td>
+ <td bgcolor="gray"></td>
+ <td bgcolor="gray"></td>
+ <td bgcolor="green"></td>
</tr>
</table>
@@ -138,5 +222,8 @@
In addition to the table above, each sensor type might support specific features. For example
a magnetometer might support returning geo values. See QSensor::isFeatureSupported() for
additional details.
+
+ Sensor Gestures are mostly platform independent, and will run if the platform has the needed sensors.
+ Whether they are supported and work well or not depends on the platform.
*/
diff --git a/src/sensors/doc/src/genericbackend.qdoc b/src/sensors/doc/src/genericbackend.qdoc
index 689b4124..a273352b 100644
--- a/src/sensors/doc/src/genericbackend.qdoc
+++ b/src/sensors/doc/src/genericbackend.qdoc
@@ -49,6 +49,9 @@
\row
\li Rotation Sensor
\li Accelerometer
+ \row
+ \li Tilt Sensor
+ \li Accelerometer
\endtable
If a platform doesn't support the source sensor, then the sensor can not be emulated.
*/
diff --git a/src/sensors/doc/src/porting.qdoc b/src/sensors/doc/src/porting.qdoc
index fa2b3fb2..0d5b5723 100644
--- a/src/sensors/doc/src/porting.qdoc
+++ b/src/sensors/doc/src/porting.qdoc
@@ -39,21 +39,26 @@
\section1 QML
- Compatibility for QML applications is provided by shipping the legacy \c QtMobility.sensors
- QML import. QML applications should not require any changes to continue operating.
+ In QtMobility, the C++ classes like QAccelerometer were directly used as QML types.
+ In Qt Sensors, there are now separate classes for the QML types, which have no public
+ C++ API.
- Applications using the legacy QML import may not be able to trivially port over
- to the new QML import because the new QML import does not provide types for
- every sensor like the legacy QML import does.
+ The new QML types in Qt Sensors fix some issues the former QtMobility QML types had,
+ for example:
+ \list
+ \li The reading types now have proper change notifications
+ \li \c availableDataRates and \c outputRanges of the \c Sensor type are now proper list types
+ \li The \c identifier and \c type properties of \c Sensor can now be used
+ \li The \c lux property of \c LightSensorReading has been renamed to \c illuminance
+ \li The \c QmlSensors singleton now allows to query for sensor types
+ \endlist
- \table
- \row
- \li \l {Qt Sensors QML Types}{QML API}
- \li Information about the Qt Sensors QML API
- \endtable
+ For more information, see the \l {Qt Sensors QML Types}{QML API} documentation.
\section1 C++
+ The C++ API mainly remained the same as in QtMobility.
+
\section2 Includes
QtMobility Sensors installed headers into a \c Qt Sensors directory. This is
diff --git a/src/sensors/doc/src/qtsensors.qdoc b/src/sensors/doc/src/qtsensors.qdoc
index 61286733..9213371d 100644
--- a/src/sensors/doc/src/qtsensors.qdoc
+++ b/src/sensors/doc/src/qtsensors.qdoc
@@ -112,6 +112,9 @@
\row
\li \l {Generic Backend}{Generic Backend}
\li Information about the generic sensor backend.
+ \row
+ \li \l {Sensorfw Backend}{Sensorfw Backend}
+ \li Information about the Sensorfw sensor backend.
\endtable
*/
diff --git a/src/sensors/doc/src/sensorfwbackend.qdoc b/src/sensors/doc/src/sensorfwbackend.qdoc
new file mode 100644
index 00000000..fcfbb5d8
--- /dev/null
+++ b/src/sensors/doc/src/sensorfwbackend.qdoc
@@ -0,0 +1,39 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Jolla Mobile
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:FDL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Free Documentation License Usage
+** Alternatively, this file may be used under the terms of the GNU Free
+** Documentation License version 1.3 as published by the Free Software
+** Foundation and appearing in the file included in the packaging of
+** this file. Please review the following information to ensure
+** the GNU Free Documentation License version 1.3 requirements
+** will be met: http://www.gnu.org/copyleft/fdl.html.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+/*!
+ \page senorfwbackend.html
+ \title Sensorfw Backend
+ \brief Information about the Sensorfw sensor backend
+
+ The Sensorfw sensor backend requires the Sensorfw and sensor daemon. Sensorfw was originally used in MeeGo, and is available
+ from http://meego.gitorious.org/meego-middleware/sensorfw
+
+ To compile the sensorfw backend, you need sensorfw installed and run qmake with CONFIG+=sensorfw
+
+*/
+
diff --git a/src/sensors/gestures/qsensorgesture.h b/src/sensors/gestures/qsensorgesture.h
index 2d7e9018..5ae7bb22 100644
--- a/src/sensors/gestures/qsensorgesture.h
+++ b/src/sensors/gestures/qsensorgesture.h
@@ -52,11 +52,8 @@
#include <QtCore/qmetatype.h>
-QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
-QT_MODULE(QtSensors)
-
class QSensorGesturePrivate;
class Q_SENSORS_EXPORT QSensorGesture : public QObject
@@ -93,7 +90,6 @@ Q_SIGNALS:
};
QT_END_NAMESPACE
-QT_END_HEADER
#endif // QSENSORGESTURE_H
diff --git a/src/sensors/gestures/qsensorgesture_p.h b/src/sensors/gestures/qsensorgesture_p.h
index 5bad75b5..4ee19b9c 100644
--- a/src/sensors/gestures/qsensorgesture_p.h
+++ b/src/sensors/gestures/qsensorgesture_p.h
@@ -61,7 +61,6 @@
#include "qsensorgesturemanager.h"
#include <QtCore/private/qmetaobjectbuilder_p.h>
-QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
class QSensorGesturePrivate : public QObject
@@ -84,6 +83,5 @@ public:
QT_END_NAMESPACE
-QT_END_HEADER
#endif // QSENSORGESTURE_P_H
diff --git a/src/sensors/gestures/qsensorgesturemanager.h b/src/sensors/gestures/qsensorgesturemanager.h
index da5048a0..96ea9718 100644
--- a/src/sensors/gestures/qsensorgesturemanager.h
+++ b/src/sensors/gestures/qsensorgesturemanager.h
@@ -48,11 +48,8 @@
#include <QtSensors/qsensorgesture.h>
#include <QtSensors/qsensorgesturerecognizer.h>
-QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
-QT_MODULE(QtSensors)
-
class QSensorGestureManagerPrivate;
class Q_SENSORS_EXPORT QSensorGestureManager : public QObject
{
@@ -78,6 +75,5 @@ Q_SIGNALS:
QT_END_NAMESPACE
-QT_END_HEADER
#endif // QSENSORGESTUREMANAGER_P_H
diff --git a/src/sensors/gestures/qsensorgesturemanagerprivate_p.h b/src/sensors/gestures/qsensorgesturemanagerprivate_p.h
index 50770c77..0994b2ab 100644
--- a/src/sensors/gestures/qsensorgesturemanagerprivate_p.h
+++ b/src/sensors/gestures/qsensorgesturemanagerprivate_p.h
@@ -52,7 +52,6 @@
#include "qsensorgesture.h"
#include "qsensorgesturerecognizer.h"
-QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
class QFactoryLoader;
@@ -99,6 +98,5 @@ private slots:
};
QT_END_NAMESPACE
-QT_END_HEADER
#endif // QSENSORGESTUREMANAGERPRIVATE_P_H
diff --git a/src/sensors/gestures/qsensorgestureplugininterface.cpp b/src/sensors/gestures/qsensorgestureplugininterface.cpp
index add34c0e..de02f890 100644
--- a/src/sensors/gestures/qsensorgestureplugininterface.cpp
+++ b/src/sensors/gestures/qsensorgestureplugininterface.cpp
@@ -51,7 +51,7 @@ QT_BEGIN_NAMESPACE
\brief The QSensorGesturePluginInterface class is the pure virtual interface to sensor gesture
plugins.
- \since QtSensors 5.0
+ \since 5.0
The QSensorGesturePluginInterface class is implemented in sensor gesture plugins to register
sensor gesture recognizers with QSensorGestureManager.
diff --git a/src/sensors/gestures/qsensorgestureplugininterface.h b/src/sensors/gestures/qsensorgestureplugininterface.h
index da933c92..330d880c 100644
--- a/src/sensors/gestures/qsensorgestureplugininterface.h
+++ b/src/sensors/gestures/qsensorgestureplugininterface.h
@@ -48,11 +48,8 @@
#include <QtSensors/qsensorgesture.h>
#include <QtSensors/qsensorgesturerecognizer.h>
-QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
-QT_MODULE(QtSensors)
-
class QSensorGestureRecognizer;
class Q_SENSORS_EXPORT QSensorGesturePluginInterface
@@ -68,6 +65,5 @@ public:
Q_DECLARE_INTERFACE(QSensorGesturePluginInterface, "org.qt-project.QSensorGesturePluginInterface")
QT_END_NAMESPACE
-QT_END_HEADER
#endif // QSENSORGESTUREPLUGININTERFACE_H
diff --git a/src/sensors/gestures/qsensorgesturerecognizer.h b/src/sensors/gestures/qsensorgesturerecognizer.h
index bebc5ce6..c35c25be 100644
--- a/src/sensors/gestures/qsensorgesturerecognizer.h
+++ b/src/sensors/gestures/qsensorgesturerecognizer.h
@@ -48,11 +48,8 @@
#include <QtSensors/qsensorgesture.h>
-QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
-QT_MODULE(QtSensors)
-
class QSensorGestureRecognizerPrivate;
class Q_SENSORS_EXPORT QSensorGestureRecognizer : public QObject
{
@@ -84,6 +81,5 @@ private:
};
QT_END_NAMESPACE
-QT_END_HEADER
#endif // QSENSORGESTURERECOGNIZER_H
diff --git a/src/sensors/make_sensor.pl b/src/sensors/make_sensor.pl
index 4d78a312..27322517 100755
--- a/src/sensors/make_sensor.pl
+++ b/src/sensors/make_sensor.pl
@@ -52,6 +52,15 @@ $sensorbase =~ s/Sensor$//;
my $reading = $sensorbase.'Reading';
my $reading_private = $reading.'Private';
my $filter = $sensorbase.'Filter';
+my $no_q_sensor = $sensor;
+$no_q_sensor =~ s/^.//;
+my $qmlsensor = "Qml".$no_q_sensor;
+my $qmlsensorbase = $qmlsensor;
+$qmlsensorbase =~ s/Sensor$//;
+my $qmlreading = $qmlsensorbase."Reading";
+my $no_q_reading = $no_q_sensor;
+$no_q_reading =~ s/Sensor$//;
+$no_q_reading = $no_q_reading."Reading";
my $filebase;
eval {
@@ -61,9 +70,15 @@ if ($@) {
$filebase = lc($sensor);
}
+my $qmlfilebase = $filebase;
+$qmlfilebase =~ s/^.//;
+$qmlfilebase = "qml".$qmlfilebase;
+
my $pheader = $filebase."_p.h";
my $header = $filebase.".h";
my $source = $filebase.".cpp";
+my $qmlsource = "../imports/sensors/".$qmlfilebase.".cpp";
+my $qmlheader = "../imports/sensors/".$qmlfilebase.".h";
my $pguard = uc($pheader);
$pguard =~ s/\./_/g;
@@ -71,6 +86,163 @@ $pguard =~ s/\./_/g;
my $guard = uc($header);
$guard =~ s/\./_/g;
+my $qmlguard = "QML".uc($no_q_sensor)."_H";
+
+if (! -e $qmlheader) {
+ print "Creating $qmlheader\n";
+ open OUT, ">$qmlheader" or die $!;
+ print OUT '
+#ifndef '.$qmlguard.'
+#define '.$qmlguard.'
+
+#include "qmlsensor.h"
+
+QT_BEGIN_NAMESPACE
+
+class '.$sensor.';
+
+class '.$qmlsensor.' : public QmlSensor
+{
+ Q_OBJECT
+public:
+ explicit '.$qmlsensor.'(QObject *parent = 0);
+ ~'.$qmlsensor.'();
+
+private:
+ QSensor *sensor() const Q_DECL_OVERRIDE;
+ QmlSensorReading *createReading() const Q_DECL_OVERRIDE;
+
+ '.$sensor.' *m_sensor;
+};
+
+class '.$qmlreading.' : public QmlSensorReading
+{
+ Q_OBJECT
+ Q_PROPERTY(qreal prop1 READ prop1 NOTIFY prop1Changed)
+public:
+ explicit '.$qmlreading.'('.$sensor.' *sensor);
+ ~'.$qmlreading.'();
+
+ qreal prop1() const;
+
+Q_SIGNALS:
+ void prop1Changed();
+
+private:
+ QSensorReading *reading() const Q_DECL_OVERRIDE;
+ void readingUpdate() Q_DECL_OVERRIDE;
+
+ '.$sensor.' *m_sensor;
+ qreal m_prop1;
+};
+
+QT_END_NAMESPACE
+#endif
+';
+ close OUT;
+}
+
+if (! -e $qmlsource) {
+ print "Creating $qmlsource\n";
+ open OUT, ">$qmlsource" or die $!;
+ print OUT '
+#include "qml'.lc($no_q_sensor).'.h"
+#include <'.$sensor.'>
+
+/*!
+ \qmltype '.$no_q_sensor.'
+ \instantiates '.$qmlsensor.'
+ \ingroup qml-sensors_type
+ \inqmlmodule QtSensors 5.0
+ \since QtSensors 5.[INSERT VERSION HERE]
+ \inherits Sensor
+ \brief The '.$no_q_sensor.' element reports on fubbleness.
+
+ The '.$no_q_sensor.' element reports on fubbleness.
+
+ This element wraps the '.$sensor.' class. Please see the documentation for
+ '.$sensor.' for details.
+
+ \sa '.$no_q_reading.'
+*/
+
+'.$qmlsensor.'::'.$qmlsensor.'(QObject *parent)
+ : QmlSensor(parent)
+ , m_sensor(new '.$sensor.'(this))
+{
+}
+
+'.$qmlsensor.'::~'.$qmlsensor.'()
+{
+}
+
+QmlSensorReading *'.$qmlsensor.'::createReading() const
+{
+ return new '.$qmlreading.'(m_sensor);
+}
+
+QSensor *'.$qmlsensor.'::sensor() const
+{
+ return m_sensor;
+}
+
+/*!
+ \qmltype '.$no_q_reading.'
+ \instantiates '.$qmlreading.'
+ \ingroup qml-sensors_reading
+ \inqmlmodule QtSensors 5.0
+ \since QtSensors 5.[INSERT VERSION HERE]
+ \inherits SensorReading
+ \brief The '.$no_q_reading.' element holds the most recent '.$no_q_sensor.' reading.
+
+ The '.$no_q_reading.' element holds the most recent '.$no_q_sensor.' reading.
+
+ This element wraps the '.$reading.' class. Please see the documentation for
+ '.$reading.' for details.
+
+ This element cannot be directly created.
+*/
+
+'.$qmlreading.'::'.$qmlreading.'('.$sensor.' *sensor)
+ : QmlSensorReading(sensor)
+ , m_sensor(sensor)
+ , m_prop1(0)
+{
+}
+
+'.$qmlreading.'::~'.$qmlreading.'()
+{
+}
+
+/*!
+ \qmlproperty qreal '.$no_q_reading.'::prop1
+ This property holds the fubble of the device.
+
+ Please see '.$reading.'::prop1 for information about this property.
+*/
+
+qreal '.$qmlreading.'::prop1() const
+{
+ return m_prop1;
+}
+
+QSensorReading *'.$qmlreading.'::reading() const
+{
+ return m_sensor->reading();
+}
+
+void '.$qmlreading.'::readingUpdate()
+{
+ qreal prop1 = m_sensor->reading()->prop1();
+ if (m_prop1 != prop1) {
+ m_prop1 = prop1;
+ Q_EMIT prop1Changed();
+ }
+}
+';
+ close OUT;
+}
+
if (! -e $pheader) {
print "Creating $pheader\n";
open OUT, ">$pheader" or die $!;
@@ -89,7 +261,6 @@ if (! -e $pheader) {
// We mean it.
//
-QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
class '.$reading_private.'
@@ -110,7 +281,6 @@ public:
};
QT_END_NAMESPACE
-QT_END_HEADER
#endif
';
@@ -126,11 +296,8 @@ if (! -e $header) {
#include <QtSensors/qsensor.h>
-QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
-QT_MODULE(QtSensors)
-
class '.$reading_private.';
class Q_SENSORS_EXPORT '.$reading.' : public QSensorReading
@@ -166,7 +333,6 @@ private:
};
QT_END_NAMESPACE
-QT_END_HEADER
#endif
';
@@ -188,7 +354,7 @@ IMPLEMENT_READING('.$reading.')
\class '.$reading.'
\ingroup sensors_reading
\inmodule QtSensors
- \since QtSensors 5.[INSERT VERSION HERE]
+ \since 5.[INSERT VERSION HERE]
\brief The '.$reading.' class holds readings from the [X] sensor.
@@ -226,7 +392,7 @@ void '.$reading.'::setMyprop(qreal myprop)
\class '.$filter.'
\ingroup sensors_filter
\inmodule QtSensors
- \since QtSensors 5.[INSERT VERSION HERE]
+ \since 5.[INSERT VERSION HERE]
\brief The '.$filter.' class is a convenience wrapper around QSensorFilter.
@@ -248,7 +414,7 @@ char const * const '.$sensor.'::type("'.$sensor.'");
\class '.$sensor.'
\ingroup sensors_type
\inmodule QtSensors
- \since QtSensors 5.[INSERT VERSION HERE]
+ \since 5.[INSERT VERSION HERE]
\brief The '.$sensor.' class is a convenience wrapper around QSensor.
diff --git a/src/sensors/qaccelerometer.cpp b/src/sensors/qaccelerometer.cpp
index 4aeedf42..9b9bd346 100644
--- a/src/sensors/qaccelerometer.cpp
+++ b/src/sensors/qaccelerometer.cpp
@@ -153,6 +153,29 @@ void QAccelerometerReading::setZ(qreal z)
char const * const QAccelerometer::type("QAccelerometer");
/*!
+ \enum QAccelerometer::AccelerationMode
+
+ \brief This enum represents the acceleration mode of an acceleration sensor.
+
+ The acceleration mode controls how the sensor reports acceleration. QAccelerometer::Combined
+ is the only mode in which the values can be directly physically measured, the others are an
+ approximation.
+
+ \value Combined Both the acceleration caused by gravity and the acceleration caused by the
+ user moving the device is reported combined.
+ \value Gravity Only the acceleration caused by gravity is reported. Movements of the device
+ caused by the user have no effect other than changing the direction when the
+ device is rotated.
+ \value User Only the acceleration caused by the user moving the device is reported, the
+ effect of gravity is canceled out. A device at rest therefore should report
+ values of, or close to, zero.
+ In other APIs, this mode might be known as \e {linear acceleration}.
+
+ \sa QAccelerometer::accelerationMode
+ \since 5.1
+*/
+
+/*!
\class QAccelerometer
\ingroup sensors_type
\inmodule QtSensors
@@ -161,7 +184,11 @@ char const * const QAccelerometer::type("QAccelerometer");
The only behavioural difference is that this class sets the type properly.
- This class also features a reading() function that returns a QAccelerometerReading instead of a QSensorReading.
+ It also supports changing the acceleration mode, which controls whether the force of gravity
+ is included in the accelerometer values or not.
+
+ Furthermore, this class features a reading() function that returns a QAccelerometerReading
+ instead of a QSensorReading.
For details about how the sensor works, see \l QAccelerometerReading.
@@ -172,7 +199,7 @@ char const * const QAccelerometer::type("QAccelerometer");
Construct the sensor as a child of \a parent.
*/
QAccelerometer::QAccelerometer(QObject *parent)
- : QSensor(QAccelerometer::type, parent)
+ : QSensor(QAccelerometer::type, *new QAccelerometerPrivate, parent)
{
}
@@ -184,6 +211,45 @@ QAccelerometer::~QAccelerometer()
}
/*!
+ \property QAccelerometer::accelerationMode
+ \brief The acceleration mode controls how acceleration values are reported.
+ \since 5.1
+
+ The acceleration mode controls how the acceleration sensor reports its values.
+ The default mode is QAccelerometer::Combined, which means the acceleration caused
+ by gravity is included in the reported values.
+
+ Acceleration caused by gravity and acceleration caused by the user moving the device
+ are physically impossible to distinguish because of general relativity. Most devices use
+ sensor fusion to figure out which parts of the acceleration is caused by gravity, for example
+ by using a rotation sensor to calculate the gravity direction and assuming a fixed magnitude
+ for gravity. Therefore the result is only an approximation and may be inaccurate.
+ The QAccelerometer::Combined mode is the most accurate one, as it does not involve approximating
+ the gravity.
+
+ Not all backends and devices might support setting the acceleration mode. For those cases, the
+ default mode QAccelerometer::Combined is used, changing it has no effect.
+*/
+QAccelerometer::AccelerationMode QAccelerometer::accelerationMode() const
+{
+ Q_D(const QAccelerometer);
+ return d->accelerationMode;
+}
+
+/*!
+ Sets the acceleration mode to \a accelerationMode.
+ \since 5.1
+*/
+void QAccelerometer::setAccelerationMode(QAccelerometer::AccelerationMode accelerationMode)
+{
+ Q_D(QAccelerometer);
+ if (d->accelerationMode != accelerationMode) {
+ d->accelerationMode = accelerationMode;
+ emit accelerationModeChanged(d->accelerationMode);
+ }
+}
+
+/*!
\fn QAccelerometer::reading() const
Returns the reading class for this sensor.
@@ -191,6 +257,14 @@ QAccelerometer::~QAccelerometer()
\sa QSensor::reading()
*/
+/*!
+ \fn QAccelerometer::accelerationModeChanged(AccelerationMode accelerationMode)
+
+ Emitted when the acceleration mode was changed.
+
+ \since 5.1
+*/
+
#include "moc_qaccelerometer.cpp"
QT_END_NAMESPACE
diff --git a/src/sensors/qaccelerometer.h b/src/sensors/qaccelerometer.h
index 734ce97e..4478235c 100644
--- a/src/sensors/qaccelerometer.h
+++ b/src/sensors/qaccelerometer.h
@@ -44,11 +44,8 @@
#include <QtSensors/qsensor.h>
-QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
-QT_MODULE(QtSensors)
-
class QAccelerometerReadingPrivate;
class Q_SENSORS_EXPORT QAccelerometerReading : public QSensorReading
@@ -77,21 +74,40 @@ private:
bool filter(QSensorReading *reading) { return filter(static_cast<QAccelerometerReading*>(reading)); }
};
+class QAccelerometerPrivate;
+
class Q_SENSORS_EXPORT QAccelerometer : public QSensor
{
Q_OBJECT
+ Q_ENUMS(AccelerationMode)
+ Q_PROPERTY(AccelerationMode accelerationMode READ accelerationMode WRITE setAccelerationMode
+ NOTIFY accelerationModeChanged)
public:
explicit QAccelerometer(QObject *parent = 0);
virtual ~QAccelerometer();
+
+ // Keep this enum in sync with QmlAccelerometer::AccelerationMode
+ enum AccelerationMode {
+ Combined,
+ Gravity,
+ User
+ };
+
+ AccelerationMode accelerationMode() const;
+ void setAccelerationMode(AccelerationMode accelerationMode);
+
QAccelerometerReading *reading() const { return static_cast<QAccelerometerReading*>(QSensor::reading()); }
static char const * const type;
+Q_SIGNALS:
+ void accelerationModeChanged(AccelerationMode accelerationMode);
+
private:
+ Q_DECLARE_PRIVATE(QAccelerometer)
Q_DISABLE_COPY(QAccelerometer)
};
QT_END_NAMESPACE
-QT_END_HEADER
#endif
diff --git a/src/sensors/qaccelerometer_p.h b/src/sensors/qaccelerometer_p.h
index dd60fd19..e8023db2 100644
--- a/src/sensors/qaccelerometer_p.h
+++ b/src/sensors/qaccelerometer_p.h
@@ -53,7 +53,8 @@
// We mean it.
//
-QT_BEGIN_HEADER
+#include "qsensor_p.h"
+
QT_BEGIN_NAMESPACE
class QAccelerometerReadingPrivate
@@ -71,8 +72,18 @@ public:
qreal z;
};
+class QAccelerometerPrivate : public QSensorPrivate
+{
+public:
+ QAccelerometerPrivate()
+ : accelerationMode(QAccelerometer::Combined)
+ {
+ }
+
+ QAccelerometer::AccelerationMode accelerationMode;
+};
+
QT_END_NAMESPACE
-QT_END_HEADER
#endif
diff --git a/src/sensors/qaltimeter.cpp b/src/sensors/qaltimeter.cpp
new file mode 100644
index 00000000..6a7caa7b
--- /dev/null
+++ b/src/sensors/qaltimeter.cpp
@@ -0,0 +1,148 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Research In Motion
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtSensors module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <qaltimeter.h>
+#include "qaltimeter_p.h"
+
+QT_BEGIN_NAMESPACE
+
+IMPLEMENT_READING(QAltimeterReading)
+
+/*!
+ \class QAltimeterReading
+ \ingroup sensors_reading
+ \inmodule QtSensors
+ \since 5.1
+
+ \brief The QAltimeterReading class holds readings from the altimeter sensor.
+
+ The altitude is reported in meters relative to mean sea level.
+
+ On BlackBerry, the altimeter uses a combination of pressure and location to determine
+ the altitude, as using pressure alone would yield to inaccurate results due to changes
+ in air pressure caused by the weather. The location information is used to compensate for
+ the weather. This requires that the user has enabled location services in the global
+ settings.
+*/
+
+/*!
+ \property QAltimeterReading::altitude
+ \brief The altitude in meters relative to mean sea level.
+*/
+
+qreal QAltimeterReading::altitude() const
+{
+ return d->altitude;
+}
+
+/*!
+ Sets the altitude to \a altitude.
+*/
+void QAltimeterReading::setAltitude(qreal altitude)
+{
+ d->altitude = altitude;
+}
+
+// =====================================================================
+
+/*!
+ \class QAltimeterFilter
+ \ingroup sensors_filter
+ \inmodule QtSensors
+ \since 5.1
+
+ \brief The QAltimeterFilter class is a convenience wrapper around QSensorFilter.
+
+ The only difference is that the filter() method features a pointer to QAltimeterReading
+ instead of QSensorReading.
+*/
+
+/*!
+ \fn QAltimeterFilter::filter(QAltimeterReading *reading)
+
+ Called when \a reading changes. Returns false to prevent the reading from propagating.
+
+ \sa QSensorFilter::filter()
+*/
+
+char const * const QAltimeter::type("QAltimeter");
+
+/*!
+ \class QAltimeter
+ \ingroup sensors_type
+ \inmodule QtSensors
+ \since 5.1
+
+ \brief The QAltimeter class is a convenience wrapper around QSensor.
+
+ The only behavioural difference is that this class sets the type properly.
+
+ This class also features a reading() function that returns a QAltimeterReading instead of a QSensorReading.
+
+ For details about how the sensor works, see \l QAltimeterReading.
+
+ \sa QAltimeterReading
+*/
+
+/*!
+ Construct the sensor as a child of \a parent.
+*/
+QAltimeter::QAltimeter(QObject *parent)
+ : QSensor(QAltimeter::type, parent)
+{
+}
+
+/*!
+ Destroy the sensor. Stops the sensor if it has not already been stopped.
+*/
+QAltimeter::~QAltimeter()
+{
+}
+
+/*!
+ \fn QAltimeter::reading() const
+
+ Returns the reading class for this sensor.
+
+ \sa QSensor::reading()
+*/
+
+#include "moc_qaltimeter.cpp"
+QT_END_NAMESPACE
diff --git a/src/sensors/qaltimeter.h b/src/sensors/qaltimeter.h
new file mode 100644
index 00000000..6b7d2232
--- /dev/null
+++ b/src/sensors/qaltimeter.h
@@ -0,0 +1,84 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Research In Motion
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtSensors module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#ifndef QALTIMETER_H
+#define QALTIMETER_H
+
+#include <QtSensors/qsensor.h>
+
+QT_BEGIN_NAMESPACE
+
+class QAltimeterReadingPrivate;
+
+class Q_SENSORS_EXPORT QAltimeterReading : public QSensorReading
+{
+ Q_OBJECT
+ Q_PROPERTY(qreal altitude READ altitude)
+ DECLARE_READING(QAltimeterReading)
+public:
+ qreal altitude() const;
+ void setAltitude(qreal altitude);
+};
+
+class Q_SENSORS_EXPORT QAltimeterFilter : public QSensorFilter
+{
+public:
+ virtual bool filter(QAltimeterReading *reading) = 0;
+private:
+ bool filter(QSensorReading *reading) Q_DECL_OVERRIDE
+ { return filter(static_cast<QAltimeterReading*>(reading)); }
+};
+
+class Q_SENSORS_EXPORT QAltimeter : public QSensor
+{
+ Q_OBJECT
+public:
+ explicit QAltimeter(QObject *parent = 0);
+ ~QAltimeter();
+ QAltimeterReading *reading() const { return static_cast<QAltimeterReading*>(QSensor::reading()); }
+ static char const * const type;
+
+private:
+ Q_DISABLE_COPY(QAltimeter)
+};
+
+QT_END_NAMESPACE
+
+#endif
diff --git a/src/sensors/qaltimeter_p.h b/src/sensors/qaltimeter_p.h
new file mode 100644
index 00000000..dfc3ebd3
--- /dev/null
+++ b/src/sensors/qaltimeter_p.h
@@ -0,0 +1,70 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Research In Motion
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtSensors module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#ifndef QALTIMETER_P_H
+#define QALTIMETER_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+QT_BEGIN_NAMESPACE
+
+class QAltimeterReadingPrivate
+{
+public:
+ QAltimeterReadingPrivate()
+ : altitude(0)
+ {
+ }
+
+ qreal altitude;
+};
+
+QT_END_NAMESPACE
+
+#endif
diff --git a/src/sensors/qambientlightsensor.h b/src/sensors/qambientlightsensor.h
index 8b69fc2c..3dae639c 100644
--- a/src/sensors/qambientlightsensor.h
+++ b/src/sensors/qambientlightsensor.h
@@ -44,11 +44,8 @@
#include <QtSensors/qsensor.h>
-QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
-QT_MODULE(QtSensors)
-
class QAmbientLightReadingPrivate;
class Q_SENSORS_EXPORT QAmbientLightReading : public QSensorReading
@@ -93,7 +90,6 @@ private:
};
QT_END_NAMESPACE
-QT_END_HEADER
#endif
diff --git a/src/sensors/qambientlightsensor_p.h b/src/sensors/qambientlightsensor_p.h
index 5faf8530..c921c6bf 100644
--- a/src/sensors/qambientlightsensor_p.h
+++ b/src/sensors/qambientlightsensor_p.h
@@ -53,7 +53,6 @@
// We mean it.
//
-QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
class QAmbientLightReadingPrivate
@@ -68,7 +67,6 @@ public:
};
QT_END_NAMESPACE
-QT_END_HEADER
#endif
diff --git a/src/sensors/qambienttemperaturesensor.cpp b/src/sensors/qambienttemperaturesensor.cpp
new file mode 100644
index 00000000..9ecde6df
--- /dev/null
+++ b/src/sensors/qambienttemperaturesensor.cpp
@@ -0,0 +1,144 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Research In Motion
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtSensors module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <qambienttemperaturesensor.h>
+#include "qambienttemperaturesensor_p.h"
+
+QT_BEGIN_NAMESPACE
+
+IMPLEMENT_READING(QAmbientTemperatureReading)
+
+/*!
+ \class QAmbientTemperatureReading
+ \ingroup sensors_reading
+ \inmodule QtSensors
+ \since 5.1
+
+ \brief The QAmbientTemperatureReading class holds readings of the ambient temperature.
+
+ The ambient (room) temperature is the temperature in degree Celsius.
+*/
+
+/*!
+ \property QAmbientTemperatureReading::temperature
+ \brief The ambient temperature
+
+ Measured in degree Celsius.
+*/
+
+qreal QAmbientTemperatureReading::temperature() const
+{
+ return d->temperature;
+}
+
+/*!
+ Sets ambient temperature to \a temperature.
+*/
+void QAmbientTemperatureReading::setTemperature(qreal temperature)
+{
+ d->temperature = temperature;
+}
+
+// =====================================================================
+
+/*!
+ \class QAmbientTemperatureFilter
+ \ingroup sensors_filter
+ \inmodule QtSensors
+ \since 5.1
+
+ \brief The QAmbientTemperatureFilter class is a convenience wrapper around QSensorFilter.
+
+ The only difference is that the filter() method features a pointer to QAmbientTemperatureReading
+ instead of QSensorReading.
+*/
+
+/*!
+ \fn QAmbientTemperatureFilter::filter(QAmbientTemperatureReading *reading)
+
+ Called when \a reading changes. Returns false to prevent the reading from propagating.
+
+ \sa QSensorFilter::filter()
+*/
+
+char const * const QAmbientTemperatureSensor::type("QAmbientTemperatureSensor");
+
+/*!
+ \class QAmbientTemperatureSensor
+ \ingroup sensors_type
+ \inmodule QtSensors
+ \since 5.1
+
+ \brief The QAmbientTemperatureSensor class is a convenience wrapper around QSensor.
+
+ The only behavioural difference is that this class sets the type properly.
+
+ This class also features a reading() function that returns a QAmbientTemperatureReading instead of a QSensorReading.
+
+ For details about how the sensor works, see \l QAmbientTemperatureReading.
+
+ \sa QAmbientTemperatureReading
+*/
+
+/*!
+ Construct the sensor as a child of \a parent.
+*/
+QAmbientTemperatureSensor::QAmbientTemperatureSensor(QObject *parent)
+ : QSensor(QAmbientTemperatureSensor::type, parent)
+{
+}
+
+/*!
+ Destroy the sensor. Stops the sensor if it has not already been stopped.
+*/
+QAmbientTemperatureSensor::~QAmbientTemperatureSensor()
+{
+}
+
+/*!
+ \fn QAmbientTemperatureSensor::reading() const
+
+ Returns the reading class for this sensor.
+
+ \sa QSensor::reading()
+*/
+
+#include "moc_qambienttemperaturesensor.cpp"
+QT_END_NAMESPACE
diff --git a/src/sensors/qambienttemperaturesensor.h b/src/sensors/qambienttemperaturesensor.h
new file mode 100644
index 00000000..134e5a92
--- /dev/null
+++ b/src/sensors/qambienttemperaturesensor.h
@@ -0,0 +1,84 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Research In Motion
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtSensors module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#ifndef QAMBIENTTEMPERATURESENSOR_H
+#define QAMBIENTTEMPERATURESENSOR_H
+
+#include <QtSensors/qsensor.h>
+
+QT_BEGIN_NAMESPACE
+
+class QAmbientTemperatureReadingPrivate;
+
+class Q_SENSORS_EXPORT QAmbientTemperatureReading : public QSensorReading
+{
+ Q_OBJECT
+ Q_PROPERTY(qreal temperature READ temperature)
+ DECLARE_READING(QAmbientTemperatureReading)
+public:
+ qreal temperature() const;
+ void setTemperature(qreal temperature);
+};
+
+class Q_SENSORS_EXPORT QAmbientTemperatureFilter : public QSensorFilter
+{
+public:
+ virtual bool filter(QAmbientTemperatureReading *reading) = 0;
+private:
+ bool filter(QSensorReading *reading) Q_DECL_OVERRIDE
+ { return filter(static_cast<QAmbientTemperatureReading*>(reading)); }
+};
+
+class Q_SENSORS_EXPORT QAmbientTemperatureSensor : public QSensor
+{
+ Q_OBJECT
+public:
+ explicit QAmbientTemperatureSensor(QObject *parent = 0);
+ ~QAmbientTemperatureSensor();
+ QAmbientTemperatureReading *reading() const { return static_cast<QAmbientTemperatureReading*>(QSensor::reading()); }
+ static char const * const type;
+
+private:
+ Q_DISABLE_COPY(QAmbientTemperatureSensor)
+};
+
+QT_END_NAMESPACE
+
+#endif
diff --git a/src/sensors/qambienttemperaturesensor_p.h b/src/sensors/qambienttemperaturesensor_p.h
new file mode 100644
index 00000000..63fe1452
--- /dev/null
+++ b/src/sensors/qambienttemperaturesensor_p.h
@@ -0,0 +1,70 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Research In Motion
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtSensors module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#ifndef QAMBIENTTEMPERATURESENSOR_P_H
+#define QAMBIENTTEMPERATURESENSOR_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+QT_BEGIN_NAMESPACE
+
+class QAmbientTemperatureReadingPrivate
+{
+public:
+ QAmbientTemperatureReadingPrivate()
+ : temperature(0)
+ {
+ }
+
+ qreal temperature;
+};
+
+QT_END_NAMESPACE
+
+#endif
diff --git a/src/sensors/qcompass.h b/src/sensors/qcompass.h
index 17b06584..8b858ff7 100644
--- a/src/sensors/qcompass.h
+++ b/src/sensors/qcompass.h
@@ -44,11 +44,8 @@
#include <QtSensors/qsensor.h>
-QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
-QT_MODULE(QtSensors)
-
class QCompassReadingPrivate;
class Q_SENSORS_EXPORT QCompassReading : public QSensorReading
@@ -87,7 +84,6 @@ private:
};
QT_END_NAMESPACE
-QT_END_HEADER
#endif
diff --git a/src/sensors/qcompass_p.h b/src/sensors/qcompass_p.h
index 04a3b798..49da19b2 100644
--- a/src/sensors/qcompass_p.h
+++ b/src/sensors/qcompass_p.h
@@ -53,7 +53,6 @@
// We mean it.
//
-QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
class QCompassReadingPrivate
@@ -70,7 +69,6 @@ public:
};
QT_END_NAMESPACE
-QT_END_HEADER
#endif
diff --git a/src/sensors/qgyroscope.h b/src/sensors/qgyroscope.h
index 7589c6ce..32c01da8 100644
--- a/src/sensors/qgyroscope.h
+++ b/src/sensors/qgyroscope.h
@@ -44,11 +44,8 @@
#include <QtSensors/qsensor.h>
-QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
-QT_MODULE(QtSensors)
-
class QGyroscopeReadingPrivate;
class Q_SENSORS_EXPORT QGyroscopeReading : public QSensorReading
@@ -91,7 +88,6 @@ private:
};
QT_END_NAMESPACE
-QT_END_HEADER
#endif
diff --git a/src/sensors/qgyroscope_p.h b/src/sensors/qgyroscope_p.h
index 21bcde41..a5e42766 100644
--- a/src/sensors/qgyroscope_p.h
+++ b/src/sensors/qgyroscope_p.h
@@ -53,7 +53,6 @@
// We mean it.
//
-QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
class QGyroscopeReadingPrivate
@@ -72,7 +71,6 @@ public:
};
QT_END_NAMESPACE
-QT_END_HEADER
#endif
diff --git a/src/sensors/qholstersensor.cpp b/src/sensors/qholstersensor.cpp
new file mode 100644
index 00000000..761910f2
--- /dev/null
+++ b/src/sensors/qholstersensor.cpp
@@ -0,0 +1,148 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Research In Motion
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtSensors module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <qholstersensor.h>
+#include "qholstersensor_p.h"
+
+QT_BEGIN_NAMESPACE
+
+IMPLEMENT_READING(QHolsterReading)
+
+/*!
+ \class QHolsterReading
+ \ingroup sensors_reading
+ \inmodule QtSensors
+ \since 5.1
+
+ \brief The QHolsterReading class holds readings from the holster sensor.
+
+ \section2 QHolsterReading Units
+ The holster sensor can detect if a device is holstered or not. A holster is a pocket,
+ similar to a gun holster, specifically made for the device. If the device is inside of this
+ pocket, it is holstered. The holster supports the device in detecting whether the device is
+ holstered or not.
+*/
+
+/*!
+ \property QHolsterReading::holstered
+ \brief A value indicating whether the device is holstered.
+
+ \sa {QHolsterReading Units}
+*/
+
+bool QHolsterReading::holstered() const
+{
+ return d->holstered;
+}
+
+/*!
+ Sets the holstered value to \a holstered.
+*/
+void QHolsterReading::setHolstered(bool holstered)
+{
+ d->holstered = holstered;
+}
+
+// =====================================================================
+
+/*!
+ \class QHolsterFilter
+ \ingroup sensors_filter
+ \inmodule QtSensors
+ \since 5.1
+
+ \brief The QHolsterFilter class is a convenience wrapper around QSensorFilter.
+
+ The only difference is that the filter() method features a pointer to QHolsterReading
+ instead of QSensorReading.
+*/
+
+/*!
+ \fn QHolsterFilter::filter(QHolsterReading *reading)
+
+ Called when \a reading changes. Returns false to prevent the reading from propagating.
+
+ \sa QSensorFilter::filter()
+*/
+
+char const * const QHolsterSensor::type("QHolsterSensor");
+
+/*!
+ \class QHolsterSensor
+ \ingroup sensors_type
+ \inmodule QtSensors
+ \since 5.1
+
+ \brief The QHolsterSensor class is a convenience wrapper around QSensor.
+
+ The only behavioural difference is that this class sets the type properly.
+
+ This class also features a reading() function that returns a QHolsterReading instead of a QSensorReading.
+
+ For details about how the sensor works, see \l QHolsterReading.
+
+ \sa QHolsterReading
+*/
+
+/*!
+ Construct the sensor as a child of \a parent.
+*/
+QHolsterSensor::QHolsterSensor(QObject *parent)
+ : QSensor(QHolsterSensor::type, parent)
+{
+}
+
+/*!
+ Destroy the sensor. Stops the sensor if it has not already been stopped.
+*/
+QHolsterSensor::~QHolsterSensor()
+{
+}
+
+/*!
+ \fn QHolsterSensor::reading() const
+
+ Returns the reading class for this sensor.
+
+ \sa QSensor::reading()
+*/
+
+#include "moc_qholstersensor.cpp"
+QT_END_NAMESPACE
diff --git a/src/sensors/qholstersensor.h b/src/sensors/qholstersensor.h
new file mode 100644
index 00000000..f44b381e
--- /dev/null
+++ b/src/sensors/qholstersensor.h
@@ -0,0 +1,84 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Research In Motion
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtSensors module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#ifndef QHOLSTERSENSOR_H
+#define QHOLSTERSENSOR_H
+
+#include <QtSensors/qsensor.h>
+
+QT_BEGIN_NAMESPACE
+
+class QHolsterReadingPrivate;
+
+class Q_SENSORS_EXPORT QHolsterReading : public QSensorReading
+{
+ Q_OBJECT
+ Q_PROPERTY(bool holstered READ holstered)
+ DECLARE_READING(QHolsterReading)
+public:
+ bool holstered() const;
+ void setHolstered(bool holstered);
+};
+
+class Q_SENSORS_EXPORT QHolsterFilter : public QSensorFilter
+{
+public:
+ virtual bool filter(QHolsterReading *reading) = 0;
+private:
+ bool filter(QSensorReading *reading) Q_DECL_OVERRIDE
+ { return filter(static_cast<QHolsterReading*>(reading)); }
+};
+
+class Q_SENSORS_EXPORT QHolsterSensor : public QSensor
+{
+ Q_OBJECT
+public:
+ explicit QHolsterSensor(QObject *parent = 0);
+ ~QHolsterSensor();
+ QHolsterReading *reading() const { return static_cast<QHolsterReading*>(QSensor::reading()); }
+ static char const * const type;
+
+private:
+ Q_DISABLE_COPY(QHolsterSensor)
+};
+
+QT_END_NAMESPACE
+
+#endif
diff --git a/src/sensors/qholstersensor_p.h b/src/sensors/qholstersensor_p.h
new file mode 100644
index 00000000..a90613f0
--- /dev/null
+++ b/src/sensors/qholstersensor_p.h
@@ -0,0 +1,70 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Research In Motion
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtSensors module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#ifndef QHOLSTERSENSOR_P_H
+#define QHOLSTERSENSOR_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+QT_BEGIN_NAMESPACE
+
+class QHolsterReadingPrivate
+{
+public:
+ QHolsterReadingPrivate()
+ : holstered(false)
+ {
+ }
+
+ bool holstered;
+};
+
+QT_END_NAMESPACE
+
+#endif
diff --git a/src/sensors/qirproximitysensor.cpp b/src/sensors/qirproximitysensor.cpp
index 4b7eeec3..6197bb96 100644
--- a/src/sensors/qirproximitysensor.cpp
+++ b/src/sensors/qirproximitysensor.cpp
@@ -63,6 +63,12 @@ IMPLEMENT_READING(QIRProximityReading)
The sensor reports reflectance as a decimal fraction in the range of 0 - 1. That is, 0 indicates
nothing was detected within the range of the sensor and 1 indicates the infra-red signal
returned at the full power level that it was sent at.
+
+ With some IR sensors, it is quite uncommon to reach the top and the bottom of the
+ value range, and some parts of the range ends might not be obtainable at all. This is due to the
+ behavior of the sensor hardware. With these sensors, the absolute value of reflectance should never
+ be used directly. Instead, applications should react to the relative change of the reading values. Use
+ QProximitySensor if it is only necessary to check if something is close to the device or not.
*/
/*!
diff --git a/src/sensors/qirproximitysensor.h b/src/sensors/qirproximitysensor.h
index c6b8925b..29eb49cd 100644
--- a/src/sensors/qirproximitysensor.h
+++ b/src/sensors/qirproximitysensor.h
@@ -44,11 +44,8 @@
#include <QtSensors/qsensor.h>
-QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
-QT_MODULE(QtSensors)
-
class QIRProximityReadingPrivate;
class Q_SENSORS_EXPORT QIRProximityReading : public QSensorReading
@@ -83,7 +80,6 @@ private:
};
QT_END_NAMESPACE
-QT_END_HEADER
#endif
diff --git a/src/sensors/qirproximitysensor_p.h b/src/sensors/qirproximitysensor_p.h
index 6241b629..9b16af56 100644
--- a/src/sensors/qirproximitysensor_p.h
+++ b/src/sensors/qirproximitysensor_p.h
@@ -53,7 +53,6 @@
// We mean it.
//
-QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
class QIRProximityReadingPrivate
@@ -68,6 +67,5 @@ public:
};
QT_END_NAMESPACE
-QT_END_HEADER
#endif
diff --git a/src/sensors/qlightsensor.cpp b/src/sensors/qlightsensor.cpp
index b712bb6e..1e80ef09 100644
--- a/src/sensors/qlightsensor.cpp
+++ b/src/sensors/qlightsensor.cpp
@@ -84,6 +84,7 @@ void QLightReading::setLux(qreal lux)
/*!
\class QLightFilter
\ingroup sensors_filter
+ \inmodule QtSensors
\brief The QLightFilter class is a convenience wrapper around QSensorFilter.
@@ -104,6 +105,7 @@ char const * const QLightSensor::type("QLightSensor");
/*!
\class QLightSensor
\ingroup sensors_type
+ \inmodule QtSensors
\brief The QLightSensor class is a convenience wrapper around QSensor.
@@ -120,7 +122,7 @@ char const * const QLightSensor::type("QLightSensor");
Construct the sensor as a child of \a parent.
*/
QLightSensor::QLightSensor(QObject *parent)
- : QSensor(QLightSensor::type, parent)
+ : QSensor(QLightSensor::type, *new QLightSensorPrivate, parent)
{
}
@@ -144,7 +146,33 @@ QLightSensor::~QLightSensor()
\brief a value indicating the field of view.
This is an angle that represents the field of view of the sensor.
+
+ Not all light sensor support retrieving their field of view. For sensors
+ that don't support this property, the value will be 0. Whether the field of
+ view is supported can be checked with QSensor::isFeatureSupported() and the
+ QSensor::FieldOfView flag.
+*/
+
+qreal QLightSensor::fieldOfView() const
+{
+ Q_D(const QLightSensor);
+ return d->fieldOfView;
+}
+
+/*!
+ \since 5.1
+
+ Sets the field of view to \a fieldOfView. This is to be called from the
+ backend.
*/
+void QLightSensor::setFieldOfView(qreal fieldOfView)
+{
+ Q_D(QLightSensor);
+ if (d->fieldOfView != fieldOfView) {
+ d->fieldOfView = fieldOfView;
+ emit fieldOfViewChanged(fieldOfView);
+ }
+}
#include "moc_qlightsensor.cpp"
QT_END_NAMESPACE
diff --git a/src/sensors/qlightsensor.h b/src/sensors/qlightsensor.h
index 096df931..1da84498 100644
--- a/src/sensors/qlightsensor.h
+++ b/src/sensors/qlightsensor.h
@@ -44,11 +44,8 @@
#include <QtSensors/qsensor.h>
-QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
-QT_MODULE(QtSensors)
-
class QLightReadingPrivate;
class Q_SENSORS_EXPORT QLightReading : public QSensorReading
@@ -69,24 +66,30 @@ private:
bool filter(QSensorReading *reading) { return filter(static_cast<QLightReading*>(reading)); }
};
+class QLightSensorPrivate;
+
class Q_SENSORS_EXPORT QLightSensor : public QSensor
{
Q_OBJECT
-#ifdef Q_QDOC
- Q_PROPERTY(qreal fieldOfView)
-#endif
+ Q_PROPERTY(qreal fieldOfView READ fieldOfView NOTIFY fieldOfViewChanged)
public:
explicit QLightSensor(QObject *parent = 0);
virtual ~QLightSensor();
QLightReading *reading() const { return static_cast<QLightReading*>(QSensor::reading()); }
static char const * const type;
+ qreal fieldOfView() const;
+ void setFieldOfView(qreal fieldOfView);
+
+Q_SIGNALS:
+ void fieldOfViewChanged(qreal fieldOfView);
+
private:
+ Q_DECLARE_PRIVATE(QLightSensor)
Q_DISABLE_COPY(QLightSensor)
};
QT_END_NAMESPACE
-QT_END_HEADER
#endif
diff --git a/src/sensors/qlightsensor_p.h b/src/sensors/qlightsensor_p.h
index da84463e..a9df63e4 100644
--- a/src/sensors/qlightsensor_p.h
+++ b/src/sensors/qlightsensor_p.h
@@ -55,7 +55,6 @@
#include "qsensor_p.h"
-QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
class QLightReadingPrivate : public QSensorReadingPrivate
@@ -69,8 +68,18 @@ public:
qreal lux;
};
+class QLightSensorPrivate : public QSensorPrivate
+{
+public:
+ QLightSensorPrivate()
+ : fieldOfView(0)
+ {
+ }
+
+ qreal fieldOfView;
+};
+
QT_END_NAMESPACE
-QT_END_HEADER
#endif
diff --git a/src/sensors/qmagnetometer.cpp b/src/sensors/qmagnetometer.cpp
index 60b2df83..7c5c9657 100644
--- a/src/sensors/qmagnetometer.cpp
+++ b/src/sensors/qmagnetometer.cpp
@@ -84,7 +84,7 @@ IMPLEMENT_READING(QMagnetometerReading)
\property QMagnetometerReading::x
\brief the raw magnetic flux density on the X axis.
- Measured as telsas.
+ Measured as teslas.
\sa {QMagnetometerReading Units}
*/
@@ -105,7 +105,7 @@ void QMagnetometerReading::setX(qreal x)
\property QMagnetometerReading::y
\brief the raw magnetic flux density on the Y axis.
- Measured as telsas.
+ Measured as teslas.
\sa {QMagnetometerReading Units}
*/
@@ -126,7 +126,7 @@ void QMagnetometerReading::setY(qreal y)
\property QMagnetometerReading::z
\brief the raw magnetic flux density on the Z axis.
- Measured as telsas.
+ Measured as teslas.
\sa {QMagnetometerReading Units}
*/
@@ -210,7 +210,7 @@ char const * const QMagnetometer::type("QMagnetometer");
Construct the sensor as a child of \a parent.
*/
QMagnetometer::QMagnetometer(QObject *parent)
- : QSensor(QMagnetometer::type, parent)
+ : QSensor(QMagnetometer::type, *new QMagnetometerPrivate, parent)
{
}
@@ -236,10 +236,24 @@ QMagnetometer::~QMagnetometer()
Set to true to return geomagnetic flux density.
Set to false (the default) to return raw magnetic flux density.
- Note that you must access this property via QObject::property() and QObject::setProperty().
The property must be set before calling start().
*/
+bool QMagnetometer::returnGeoValues() const
+{
+ Q_D(const QMagnetometer);
+ return d->returnGeoValues;
+}
+
+void QMagnetometer::setReturnGeoValues(bool returnGeoValues)
+{
+ Q_D(QMagnetometer);
+ if (d->returnGeoValues != returnGeoValues) {
+ d->returnGeoValues = returnGeoValues;
+ emit returnGeoValuesChanged(returnGeoValues);
+ }
+}
+
#include "moc_qmagnetometer.cpp"
QT_END_NAMESPACE
diff --git a/src/sensors/qmagnetometer.h b/src/sensors/qmagnetometer.h
index 60e142d4..93b6157f 100644
--- a/src/sensors/qmagnetometer.h
+++ b/src/sensors/qmagnetometer.h
@@ -44,11 +44,8 @@
#include <QtSensors/qsensor.h>
-QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
-QT_MODULE(QtSensors)
-
class QMagnetometerReadingPrivate;
class Q_SENSORS_EXPORT QMagnetometerReading : public QSensorReading
@@ -81,24 +78,30 @@ private:
bool filter(QSensorReading *reading) { return filter(static_cast<QMagnetometerReading*>(reading)); }
};
+class QMagnetometerPrivate;
+
class Q_SENSORS_EXPORT QMagnetometer : public QSensor
{
Q_OBJECT
-#ifdef Q_QDOC
- Q_PROPERTY(bool returnGeoValues)
-#endif
+ Q_PROPERTY(bool returnGeoValues READ returnGeoValues WRITE setReturnGeoValues NOTIFY returnGeoValuesChanged)
public:
explicit QMagnetometer(QObject *parent = 0);
virtual ~QMagnetometer();
QMagnetometerReading *reading() const { return static_cast<QMagnetometerReading*>(QSensor::reading()); }
static char const * const type;
+ bool returnGeoValues() const;
+ void setReturnGeoValues(bool returnGeoValues);
+
+Q_SIGNALS:
+ void returnGeoValuesChanged(bool returnGeoValues);
+
private:
+ Q_DECLARE_PRIVATE(QMagnetometer)
Q_DISABLE_COPY(QMagnetometer)
};
QT_END_NAMESPACE
-QT_END_HEADER
#endif
diff --git a/src/sensors/qmagnetometer_p.h b/src/sensors/qmagnetometer_p.h
index 2b42cfd7..3c38e6c8 100644
--- a/src/sensors/qmagnetometer_p.h
+++ b/src/sensors/qmagnetometer_p.h
@@ -53,9 +53,21 @@
// We mean it.
//
-QT_BEGIN_HEADER
+#include "qsensor_p.h"
+
QT_BEGIN_NAMESPACE
+class QMagnetometerPrivate : public QSensorPrivate
+{
+public:
+ QMagnetometerPrivate()
+ : returnGeoValues(false)
+ {
+ }
+
+ bool returnGeoValues;
+};
+
class QMagnetometerReadingPrivate
{
public:
@@ -74,7 +86,6 @@ public:
};
QT_END_NAMESPACE
-QT_END_HEADER
#endif
diff --git a/src/sensors/qorientationsensor.h b/src/sensors/qorientationsensor.h
index f577df7a..082598fb 100644
--- a/src/sensors/qorientationsensor.h
+++ b/src/sensors/qorientationsensor.h
@@ -44,11 +44,8 @@
#include <QtSensors/qsensor.h>
-QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
-QT_MODULE(QtSensors)
-
class QOrientationReadingPrivate;
class Q_SENSORS_EXPORT QOrientationReading : public QSensorReading
@@ -94,7 +91,6 @@ private:
};
QT_END_NAMESPACE
-QT_END_HEADER
#endif
diff --git a/src/sensors/qorientationsensor_p.h b/src/sensors/qorientationsensor_p.h
index 09a65a71..433f3dd9 100644
--- a/src/sensors/qorientationsensor_p.h
+++ b/src/sensors/qorientationsensor_p.h
@@ -53,7 +53,6 @@
// We mean it.
//
-QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
class QOrientationReadingPrivate
@@ -68,7 +67,6 @@ public:
};
QT_END_NAMESPACE
-QT_END_HEADER
#endif
diff --git a/src/sensors/qpressuresensor.cpp b/src/sensors/qpressuresensor.cpp
new file mode 100644
index 00000000..ea8a79bb
--- /dev/null
+++ b/src/sensors/qpressuresensor.cpp
@@ -0,0 +1,147 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Research In Motion
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtSensors module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <qpressuresensor.h>
+#include "qpressuresensor_p.h"
+
+QT_BEGIN_NAMESPACE
+
+IMPLEMENT_READING(QPressureReading)
+
+/*!
+ \class QPressureReading
+ \ingroup sensors_reading
+ \inmodule QtSensors
+ \since 5.1
+
+ \brief The QPressureReading class holds readings from the pressure sensor.
+
+ \section2 QPressureReading Units
+
+ The pressure sensor returns atmospheric pressure values in Pascals.
+*/
+
+/*!
+ \property QPressureReading::pressure
+ \brief The measured atmospheric pressure.
+
+ Returned as Pascals.
+ \sa {QPressureReading Units}
+*/
+
+qreal QPressureReading::pressure() const
+{
+ return d->pressure;
+}
+
+/*!
+ Sets the pressure to \a pressure.
+*/
+void QPressureReading::setPressure(qreal pressure)
+{
+ d->pressure = pressure;
+}
+
+// =====================================================================
+
+/*!
+ \class QPressureFilter
+ \ingroup sensors_filter
+ \inmodule QtSensors
+ \since 5.1
+
+ \brief The QPressureFilter class is a convenience wrapper around QSensorFilter.
+
+ The only difference is that the filter() method features a pointer to QPressureReading
+ instead of QSensorReading.
+*/
+
+/*!
+ \fn QPressureFilter::filter(QPressureReading *reading)
+
+ Called when \a reading changes. Returns false to prevent the reading from propagating.
+
+ \sa QSensorFilter::filter()
+*/
+
+char const * const QPressureSensor::type("QPressureSensor");
+
+/*!
+ \class QPressureSensor
+ \ingroup sensors_type
+ \inmodule QtSensors
+ \since 5.1
+
+ \brief The QPressureSensor class is a convenience wrapper around QSensor.
+
+ The only behavioural difference is that this class sets the type properly.
+
+ This class also features a reading() function that returns a QPressureReading instead of a QSensorReading.
+
+ For details about how the sensor works, see \l QPressureReading.
+
+ \sa QPressureReading
+*/
+
+/*!
+ Construct the sensor as a child of \a parent.
+*/
+QPressureSensor::QPressureSensor(QObject *parent)
+ : QSensor(QPressureSensor::type, parent)
+{
+}
+
+/*!
+ Destroy the sensor. Stops the sensor if it has not already been stopped.
+*/
+QPressureSensor::~QPressureSensor()
+{
+}
+
+/*!
+ \fn QPressureSensor::reading() const
+
+ Returns the reading class for this sensor.
+
+ \sa QSensor::reading()
+*/
+
+#include "moc_qpressuresensor.cpp"
+QT_END_NAMESPACE
diff --git a/src/sensors/qpressuresensor.h b/src/sensors/qpressuresensor.h
new file mode 100644
index 00000000..50379b52
--- /dev/null
+++ b/src/sensors/qpressuresensor.h
@@ -0,0 +1,84 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Research In Motion
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtSensors module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#ifndef QPRESSURESENSOR_H
+#define QPRESSURESENSOR_H
+
+#include <QtSensors/qsensor.h>
+
+QT_BEGIN_NAMESPACE
+
+class QPressureReadingPrivate;
+
+class Q_SENSORS_EXPORT QPressureReading : public QSensorReading
+{
+ Q_OBJECT
+ Q_PROPERTY(qreal pressure READ pressure)
+ DECLARE_READING(QPressureReading)
+public:
+ qreal pressure() const;
+ void setPressure(qreal pressure);
+};
+
+class Q_SENSORS_EXPORT QPressureFilter : public QSensorFilter
+{
+public:
+ virtual bool filter(QPressureReading *reading) = 0;
+private:
+ bool filter(QSensorReading *reading) Q_DECL_OVERRIDE
+ { return filter(static_cast<QPressureReading*>(reading)); }
+};
+
+class Q_SENSORS_EXPORT QPressureSensor : public QSensor
+{
+ Q_OBJECT
+public:
+ explicit QPressureSensor(QObject *parent = 0);
+ ~QPressureSensor();
+ QPressureReading *reading() const { return static_cast<QPressureReading*>(QSensor::reading()); }
+ static char const * const type;
+
+private:
+ Q_DISABLE_COPY(QPressureSensor)
+};
+
+QT_END_NAMESPACE
+
+#endif
diff --git a/src/sensors/qpressuresensor_p.h b/src/sensors/qpressuresensor_p.h
new file mode 100644
index 00000000..1c74e7f1
--- /dev/null
+++ b/src/sensors/qpressuresensor_p.h
@@ -0,0 +1,70 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Research In Motion
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtSensors module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#ifndef QPRESSURESENSOR_P_H
+#define QPRESSURESENSOR_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+QT_BEGIN_NAMESPACE
+
+class QPressureReadingPrivate
+{
+public:
+ QPressureReadingPrivate()
+ : pressure(0)
+ {
+ }
+
+ qreal pressure;
+};
+
+QT_END_NAMESPACE
+
+#endif
diff --git a/src/sensors/qproximitysensor.h b/src/sensors/qproximitysensor.h
index efabead9..cc8eb78b 100644
--- a/src/sensors/qproximitysensor.h
+++ b/src/sensors/qproximitysensor.h
@@ -44,11 +44,8 @@
#include <QtSensors/qsensor.h>
-QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
-QT_MODULE(QtSensors)
-
class QProximityReadingPrivate;
class Q_SENSORS_EXPORT QProximityReading : public QSensorReading
@@ -83,7 +80,6 @@ private:
};
QT_END_NAMESPACE
-QT_END_HEADER
#endif
diff --git a/src/sensors/qproximitysensor_p.h b/src/sensors/qproximitysensor_p.h
index 57125d50..8f951e6a 100644
--- a/src/sensors/qproximitysensor_p.h
+++ b/src/sensors/qproximitysensor_p.h
@@ -53,7 +53,6 @@
// We mean it.
//
-QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
class QProximityReadingPrivate
@@ -68,7 +67,6 @@ public:
};
QT_END_NAMESPACE
-QT_END_HEADER
#endif
diff --git a/src/sensors/qrotationsensor.cpp b/src/sensors/qrotationsensor.cpp
index 9acc1cd8..06ee4064 100644
--- a/src/sensors/qrotationsensor.cpp
+++ b/src/sensors/qrotationsensor.cpp
@@ -201,7 +201,7 @@ char const * const QRotationSensor::type("QRotationSensor");
Construct the sensor as a child of \a parent.
*/
QRotationSensor::QRotationSensor(QObject *parent)
- : QSensor(QRotationSensor::type, parent)
+ : QSensor(QRotationSensor::type, *new QRotationSensorPrivate, parent)
{
}
@@ -228,6 +228,28 @@ QRotationSensor::~QRotationSensor()
Returns false if z is not available.
*/
+bool QRotationSensor::hasZ() const
+{
+ Q_D(const QRotationSensor);
+ return (d->hasZ);
+}
+
+/*!
+ \since 5.1
+
+ Sets whether the z angle is available to \a hasZ. This is to be called from the
+ backend. By default the hasZ property is true, so a backend only has to
+ call this if its rotation sensor can not report z angles.
+*/
+void QRotationSensor::setHasZ(bool hasZ)
+{
+ Q_D(QRotationSensor);
+ if (d->hasZ != hasZ) {
+ d->hasZ = hasZ;
+ emit hasZChanged(hasZ);
+ }
+}
+
#include "moc_qrotationsensor.cpp"
QT_END_NAMESPACE
diff --git a/src/sensors/qrotationsensor.h b/src/sensors/qrotationsensor.h
index c049238c..68a0d1d3 100644
--- a/src/sensors/qrotationsensor.h
+++ b/src/sensors/qrotationsensor.h
@@ -44,11 +44,8 @@
#include <QtSensors/qsensor.h>
-QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
-QT_MODULE(QtSensors)
-
class QRotationReadingPrivate;
class Q_SENSORS_EXPORT QRotationReading : public QSensorReading
@@ -74,24 +71,30 @@ private:
bool filter(QSensorReading *reading) { return filter(static_cast<QRotationReading*>(reading)); }
};
+class QRotationSensorPrivate;
+
class Q_SENSORS_EXPORT QRotationSensor : public QSensor
{
Q_OBJECT
-#ifdef Q_QDOC
- Q_PROPERTY(bool hasZ)
-#endif
+ Q_PROPERTY(bool hasZ READ hasZ NOTIFY hasZChanged)
public:
explicit QRotationSensor(QObject *parent = 0);
virtual ~QRotationSensor();
QRotationReading *reading() const { return static_cast<QRotationReading*>(QSensor::reading()); }
static char const * const type;
+ bool hasZ() const;
+ void setHasZ(bool hasZ);
+
+Q_SIGNALS:
+ void hasZChanged(bool hasZ);
+
private:
+ Q_DECLARE_PRIVATE(QRotationSensor)
Q_DISABLE_COPY(QRotationSensor)
};
QT_END_NAMESPACE
-QT_END_HEADER
#endif
diff --git a/src/sensors/qrotationsensor_p.h b/src/sensors/qrotationsensor_p.h
index f6ce13ff..401c2143 100644
--- a/src/sensors/qrotationsensor_p.h
+++ b/src/sensors/qrotationsensor_p.h
@@ -53,7 +53,8 @@
// We mean it.
//
-QT_BEGIN_HEADER
+#include "qsensor_p.h"
+
QT_BEGIN_NAMESPACE
class QRotationReadingPrivate
@@ -71,8 +72,18 @@ public:
qreal z;
};
+class QRotationSensorPrivate : public QSensorPrivate
+{
+public:
+ QRotationSensorPrivate()
+ : hasZ(true)
+ {
+ }
+
+ bool hasZ;
+};
+
QT_END_NAMESPACE
-QT_END_HEADER
#endif
diff --git a/src/sensors/qsensor.cpp b/src/sensors/qsensor.cpp
index 81cb6530..01a4f7b7 100644
--- a/src/sensors/qsensor.cpp
+++ b/src/sensors/qsensor.cpp
@@ -176,6 +176,40 @@ void QSensorPrivate::init(const QByteArray &sensorType)
The sensor data is delivered via QSensorReading and its sub-classes.
+ \section1 Orientation
+
+ Some sensors react to screen orientation changes, such as QAccelerometer, QMagnetometer and
+ QRotationSensor. These are so called \e orientable sensors. For orientable sensors,
+ QSensor supports changing the reporting of the reading values based on the orientation of the
+ screen.
+
+ For orientable sensors, the axesOrientationMode property controls how the orientation affects
+ the reading values.
+
+ In the default mode, QSensor::FixedOrientation, the reading values remain
+ unaffected by the orientation. In the QSensor::AutomaticOrientation mode, the reading
+ values are automatically rotated by taking the current screen orientation into account. And
+ finally, in the QSensor::UserOrientation mode, the reading values are rotated
+ according to a user-specified orientation.
+
+ The functionality of this is only available if it is supported by the backend and if the sensor
+ is orientable, which can be checked by calling QSensor::isFeatureSupported()
+ with the QSensor::AxesOrientation flag.
+
+ The orientation values here are always of the screen orientation, not the device orientation.
+ The screen orientation is the orientation of the GUI. For example when rotating a device by 90
+ degrees counter-clockwise, the screen orientation compensates for that by rotating 90 degrees
+ clockwise, to the effect that the GUI is still facing upright after the device has been rotated.
+ Note that applications can lock the screen orientation, for example to force portrait or landscape
+ mode. For locked orientations, orientable sensors will not react with reading changes if the device
+ orientation is changed, as orientable sensors react to screen orientation changes only. This makes
+ sense, as the purpose of orientable sensors is to keep the sensor orientation in sync with the screen
+ orientation.
+
+ The orientation values range from 0 to 270 degrees. The orientation is applied in clockwise direction,
+ e.g. an orientation value of 90 degrees means that the screen has been rotated 90 degress to the right
+ from its origin position, to compensate a device rotation of 90 degrees to the left.
+
\sa QSensorReading
*/
@@ -189,6 +223,9 @@ void QSensorPrivate::init(const QByteArray &sensorType)
QSensor::bufferSize property.
\value AlwaysOn The backend supports changing the policy on whether to suspend when idle,
controlled by the QSensor::alwaysOn property.
+ \value SkipDuplicates The backend supports skipping of same or very similar successive
+ readings. This can be enabled by setting the QSensor::skipDuplicates
+ property to true.
The features of QMagnetometer are:
@@ -200,6 +237,16 @@ void QSensorPrivate::init(const QByteArray &sensorType)
\value FieldOfView The backend specifies its field of view, which can be
read from the QLightSensor::fieldOfView property.
+ The features of QAccelerometer are:
+
+ \value AccelerationMode The backend supports switching the acceleration mode
+ of the acceleromter with the QAccelerometer::accelerationMode property.
+
+ The features of all orientable sensors are:
+
+ \value AxesOrientation The backend supports changing the axes orientation from the default of
+ QSensor::FixedOrientation to something else.
+
\omitvalue Reserved
\sa QSensor::isFeatureSupported()
@@ -429,6 +476,54 @@ bool QSensor::isAlwaysOn() const
}
/*!
+ \property QSensor::skipDuplicates
+ \brief Indicates whether duplicate reading values should be omitted.
+ \since 5.1
+
+ When duplicate skipping is enabled, successive readings with the same or very
+ similar values are omitted. This helps reducing the amount of processing done, as less sensor
+ readings are made available. As a consequence, readings arrive at an irregular interval.
+
+ Duplicate skipping is not just enabled for readings that are exactly the same, but also for
+ readings that are quite similar, as each sensor has a bit of jitter even if the device is
+ not moved.
+
+ Support for this property depends on the backend. Use isFeatureSupported() to check if it is
+ supported on the current platform.
+
+ Duplicate skipping is disabled by default.
+
+ Duplicate skipping takes effect when the sensor is started, changing the property while the
+ sensor is active has no immediate effect.
+*/
+bool QSensor::skipDuplicates() const
+{
+ Q_D(const QSensor);
+ return d->skipDuplicates;
+}
+
+/*!
+ Sets the duplicate skipping to \a skipDuplicates.
+
+ \since 5.1
+*/
+void QSensor::setSkipDuplicates(bool skipDuplicates)
+{
+ Q_D(QSensor);
+ if (d->skipDuplicates != skipDuplicates) {
+ d->skipDuplicates = skipDuplicates;
+ emit skipDuplicatesChanged(skipDuplicates);
+ }
+}
+
+/*!
+ \fn QSensor::skipDuplicatesChanged(bool skipDuplicates)
+ \since 5.1
+
+ This signal is emitted when the skipDuplicates property changes.
+*/
+
+/*!
\property QSensor::availableDataRates
\brief the data rates that the sensor supports.
@@ -760,6 +855,142 @@ int QSensor::error() const
}
/*!
+ \enum QSensor::AxesOrientationMode
+ \since 5.1
+
+ Describes how reading values are affected by the screen orientation.
+
+ \value FixedOrientation No automatic rotation is applied to the reading values.
+
+ \value AutomaticOrientation The reading values are automatically rotated based on the screen
+ orientation.
+
+ \value UserOrientation The reading values are rotated based on the angle of the userOrientation property.
+
+ \sa QSensor::axesOrientationMode
+*/
+
+/*!
+ \property QSensor::axesOrientationMode
+ \since 5.1
+ \brief The mode that affects how the screen orientation changes reading values.
+
+ When set to FixedOrientation, which is the default mode, no automatic rotation is applied to
+ the reading. This is the only mode available for backends that do not support the
+ QSensor::AxesOrientation feature.
+
+ When set to AutomaticOrientation, the reading values are automatically rotated when the
+ screen orientation changes. In effect, the screen orientation is canceled out.
+
+ As an example, assume the device is rotated by 180 degrees and therefore the screen orientation
+ also is rotated by 180 degrees from the native orientation. Without automatic axes orientation,
+ the reading values would now be changed: Both the X and the Y values would be negated, forcing
+ an application developer to manually cancel out the negation in application code. Automatic
+ axes orientation does this automatically, in this mode the X and Y values would be the same as
+ with the default screen orientation.
+
+ This automatic rotation of the axes is handy is some usecases, for example in a bubble level
+ application that measures how level a surface is by looking at the X axis value of an
+ accelerometer. When the device and screen orientation change by 90 degrees, an application
+ developer does not need to change anything, he can continue using the X axis value even though
+ the device is rotated. Without automatic axes orientation, the application developer would need
+ to look at the Y values instead, thereby adding code to the application that reads from a
+ different axis depending on the screen orientation.
+
+ The UserOrientation mode is quite similar to AutomaticOrientation, only that the screen orientation
+ is manually controlled instead of automatically determined. The angle of the userOrientation
+ property is then used for rotating the reading values.
+
+ Since the rotation of the reading values is based on the screen orientation, Z values will never
+ change, as the Z axis is perpendicular to the screen.
+ As screen orientation changes in 90 degree steps, rotating the reading values is also done in
+ steps of 90 degrees.
+
+ This property is only used for orientable sensors.
+*/
+
+QSensor::AxesOrientationMode QSensor::axesOrientationMode() const
+{
+ Q_D(const QSensor);
+ return d->axesOrientationMode;
+}
+
+void QSensor::setAxesOrientationMode(QSensor::AxesOrientationMode axesOrientationMode)
+{
+ Q_D(QSensor);
+ if (d->axesOrientationMode != axesOrientationMode) {
+ d->axesOrientationMode = axesOrientationMode;
+ emit axesOrientationModeChanged(axesOrientationMode);
+ }
+}
+
+/*!
+ \property QSensor::currentOrientation
+ \since 5.1
+ \brief The current orientation that is used for rotating the reading values.
+
+ This might not be the same as the screen orientation. For example, in the FixedOrientation mode,
+ the reading values are not rotated, and therefore the property is 0.
+
+ In the UserOrientation mode, the readings are rotated based on the userOrientation property,
+ and therefore this property is equal to the userOrientation property.
+
+ In the AutomaticOrientation mode, the readings are rotated based on the screen orientation,
+ and therefore this property will be equal to the current screen orientation.
+
+ This property is set by the backend and only valid for orientable sensors.
+*/
+
+int QSensor::currentOrientation() const
+{
+ Q_D(const QSensor);
+ return d->currentOrientation;
+}
+
+/*!
+ \since 5.1
+ Sets the current screen orientation to \a currentOrientation. This is to be called from the
+ backend whenever the screen orientation or the userOrientation property changes.
+*/
+void QSensor::setCurrentOrientation(int currentOrientation)
+{
+ Q_D(QSensor);
+ if (d->currentOrientation != currentOrientation) {
+ d->currentOrientation = currentOrientation;
+ emit currentOrientationChanged(currentOrientation);
+ }
+}
+
+/*!
+ \property QSensor::userOrientation
+ \since 5.1
+ \brief The angle used for rotating the reading values in the UserOrientation mode.
+
+ When the axesOrientationMode property is set to UserOrientation, the angle for rotating the
+ reading values is taken from this property. In other modes, the property has no effect.
+
+ The default is 0. The only valid values are 0, 90, 180 and 270, as those are the only possible
+ screen orientations.
+
+ This property is only valid for orientable sensors.
+*/
+
+int QSensor::userOrientation() const
+{
+ Q_D(const QSensor);
+ return d->userOrientation;
+}
+
+void QSensor::setUserOrientation(int userOrientation)
+{
+ Q_D(QSensor);
+ if (d->userOrientation != userOrientation) {
+ d->userOrientation = userOrientation;
+ emit userOrientationChanged(userOrientation);
+ }
+}
+
+/*!
\fn QSensor::sensorError(int error)
This signal is emitted when an \a error code is set on the sensor.
@@ -785,11 +1016,33 @@ int QSensor::error() const
The property holds the maximum buffer size.
- Note that this may be undefined, in which case the sensor does not support any form of buffering.
+ Note that this may be 1, in which case the sensor does not support any form of buffering.
+ In that case, isFeatureSupported(QSensor::Buffering) will also return false.
\sa QSensor::bufferSize, QSensor::efficientBufferSize
*/
+int QSensor::maxBufferSize() const
+{
+ Q_D(const QSensor);
+ return d->maxBufferSize;
+}
+
+/*!
+ \since 5.1
+ Sets the maximum buffer size to \a maxBufferSize. This is to be called from the
+ backend.
+*/
+void QSensor::setMaxBufferSize(int maxBufferSize)
+{
+ // ### Qt 6: Remove the entire maxBufferSize property, no backend really uses it
+ Q_D(QSensor);
+ if (d->maxBufferSize != maxBufferSize) {
+ d->maxBufferSize = maxBufferSize;
+ emit maxBufferSizeChanged(maxBufferSize);
+ }
+}
+
/*!
\property QSensor::efficientBufferSize
@@ -797,17 +1050,36 @@ int QSensor::error() const
no particular size is most efficient). Some sensor drivers have a FIFO buffer which
makes it more efficient to deliver the FIFO's size worth of readings at one time.
- Note that this may be undefined, in which case the sensor does not support any form of buffering.
-
\sa QSensor::bufferSize, QSensor::maxBufferSize
*/
+int QSensor::efficientBufferSize() const
+{
+ Q_D(const QSensor);
+ return d->efficientBufferSize;
+}
+
+/*!
+ \since 5.1
+ Sets the efficient buffer size to \a efficientBufferSize. This is to be called from the
+ backend.
+*/
+void QSensor::setEfficientBufferSize(int efficientBufferSize)
+{
+ // ### Qt 6: Remove the entire efficientBufferSize property, no backend really uses it
+ Q_D(QSensor);
+ if (d->efficientBufferSize != efficientBufferSize) {
+ d->efficientBufferSize = efficientBufferSize;
+ emit efficientBufferSizeChanged(efficientBufferSize);
+ }
+}
+
/*!
\property QSensor::bufferSize
- This property holds the size of the buffer. By default (and if the property
- is left undefined), the buffer size is 1, which means no buffering.
- If the maximum buffer size is 1 (or undefined), then buffering is not supported
+ This property holds the size of the buffer. By default, the buffer size is 1,
+ which means no buffering.
+ If the maximum buffer size is 1, then buffering is not supported
by the sensor.
Setting bufferSize greater than maxBufferSize will cause maxBufferSize to be used.
@@ -834,11 +1106,26 @@ int QSensor::error() const
in time, for example when the event loop is blocked for too long. Without a buffer, these readings
would simply be dropped.
- The buffer size can only be changed while the sensor is not active.
-
\sa QSensor::maxBufferSize, QSensor::efficientBufferSize
*/
+int QSensor::bufferSize() const
+{
+ Q_D(const QSensor);
+ return d->bufferSize;
+}
+
+void QSensor::setBufferSize(int bufferSize)
+{
+ // ### Qt 6: Currently only the Blackberry backend supports this, but only as an on/off switch.
+ // We should consider changing this to a more appropriate API.
+ Q_D(QSensor);
+ if (d->bufferSize != bufferSize) {
+ d->bufferSize = bufferSize;
+ emit bufferSizeChanged(bufferSize);
+ }
+}
+
// =====================================================================
/*!
diff --git a/src/sensors/qsensor.h b/src/sensors/qsensor.h
index 46d011d3..2314fb94 100644
--- a/src/sensors/qsensor.h
+++ b/src/sensors/qsensor.h
@@ -50,11 +50,8 @@
#include <QtCore/QVariant>
#include <QtCore/QPair>
-QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
-QT_MODULE(QtSensors)
-
class QSensorPrivate;
class QSensorBackend;
class QSensorReading;
@@ -80,6 +77,7 @@ class Q_SENSORS_EXPORT QSensor : public QObject
Q_OBJECT
Q_ENUMS(Feature)
+ Q_ENUMS(AxesOrientationMode)
Q_PROPERTY(QByteArray identifier READ identifier WRITE setIdentifier)
Q_PROPERTY(QByteArray type READ type)
Q_PROPERTY(bool connectedToBackend READ isConnectedToBackend)
@@ -93,20 +91,32 @@ class Q_SENSORS_EXPORT QSensor : public QObject
Q_PROPERTY(QString description READ description)
Q_PROPERTY(int error READ error NOTIFY sensorError)
Q_PROPERTY(bool alwaysOn READ isAlwaysOn WRITE setAlwaysOn NOTIFY alwaysOnChanged REVISION 1)
-#ifdef Q_QDOC
- Q_PROPERTY(int maxBufferSize)
- Q_PROPERTY(int efficientBufferSize)
- Q_PROPERTY(int bufferSize)
-#endif
+ Q_PROPERTY(bool skipDuplicates READ skipDuplicates WRITE setSkipDuplicates NOTIFY skipDuplicatesChanged)
+ Q_PROPERTY(AxesOrientationMode axesOrientationMode READ axesOrientationMode WRITE setAxesOrientationMode NOTIFY axesOrientationModeChanged)
+ Q_PROPERTY(int currentOrientation READ currentOrientation NOTIFY currentOrientationChanged)
+ Q_PROPERTY(int userOrientation READ userOrientation WRITE setUserOrientation NOTIFY userOrientationChanged)
+ Q_PROPERTY(int maxBufferSize READ maxBufferSize NOTIFY maxBufferSizeChanged)
+ Q_PROPERTY(int efficientBufferSize READ efficientBufferSize NOTIFY efficientBufferSizeChanged)
+ Q_PROPERTY(int bufferSize READ bufferSize WRITE setBufferSize NOTIFY bufferSizeChanged)
public:
enum Feature {
Buffering,
AlwaysOn,
GeoValues,
FieldOfView,
+ AccelerationMode,
+ SkipDuplicates,
+ AxesOrientation,
Reserved = 257 // Make sure at least 2 bytes are used for the enum to avoid breaking BC later
};
+ // Keep in sync with QmlSensor::AxesOrientationMode
+ enum AxesOrientationMode {
+ FixedOrientation,
+ AutomaticOrientation,
+ UserOrientation
+ };
+
explicit QSensor(const QByteArray &type, QObject *parent = 0);
virtual ~QSensor();
@@ -126,6 +136,9 @@ public:
bool isAlwaysOn() const;
void setAlwaysOn(bool alwaysOn);
+ bool skipDuplicates() const;
+ void setSkipDuplicates(bool skipDuplicates);
+
qrangelist availableDataRates() const;
int dataRate() const;
void setDataRate(int rate);
@@ -153,6 +166,24 @@ public:
Q_INVOKABLE bool isFeatureSupported(Feature feature) const;
+ AxesOrientationMode axesOrientationMode() const;
+ void setAxesOrientationMode(AxesOrientationMode axesOrientationMode);
+
+ int currentOrientation() const;
+ void setCurrentOrientation(int currentOrientation);
+
+ int userOrientation() const;
+ void setUserOrientation(int userOrientation);
+
+ int maxBufferSize() const;
+ void setMaxBufferSize(int maxBufferSize);
+
+ int efficientBufferSize() const;
+ void setEfficientBufferSize(int efficientBufferSize);
+
+ int bufferSize() const;
+ void setBufferSize(int bufferSize);
+
public Q_SLOTS:
// Start receiving values from the sensor
bool start();
@@ -168,6 +199,13 @@ Q_SIGNALS:
void availableSensorsChanged();
void alwaysOnChanged();
void dataRateChanged();
+ void skipDuplicatesChanged(bool skipDuplicates);
+ void axesOrientationModeChanged(AxesOrientationMode axesOrientationMode);
+ void currentOrientationChanged(int currentOrientation);
+ void userOrientationChanged(int userOrientation);
+ void maxBufferSizeChanged(int maxBufferSize);
+ void efficientBufferSizeChanged(int efficientBufferSize);
+ void bufferSizeChanged(int bufferSize);
protected:
explicit QSensor(const QByteArray &type, QSensorPrivate &dd, QObject* parent = 0);
@@ -253,7 +291,6 @@ private:
QT_END_NAMESPACE
-QT_END_HEADER
Q_DECLARE_METATYPE(qrange)
Q_DECLARE_METATYPE(qrangelist)
diff --git a/src/sensors/qsensor_p.h b/src/sensors/qsensor_p.h
index 80312b65..71a5b6eb 100644
--- a/src/sensors/qsensor_p.h
+++ b/src/sensors/qsensor_p.h
@@ -57,7 +57,6 @@
#include "private/qobject_p.h"
-QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
typedef QList<QSensorFilter*> QFilterList;
@@ -79,6 +78,13 @@ public:
, cache_reading(0)
, error(0)
, alwaysOn(false)
+ , skipDuplicates(false)
+ , axesOrientationMode(QSensor::FixedOrientation)
+ , currentOrientation(0)
+ , userOrientation(0)
+ , bufferSize(1)
+ , maxBufferSize(1)
+ , efficientBufferSize(1)
{
}
@@ -108,6 +114,15 @@ public:
int error;
bool alwaysOn;
+ bool skipDuplicates;
+
+ QSensor::AxesOrientationMode axesOrientationMode;
+ int currentOrientation;
+ int userOrientation;
+
+ int bufferSize;
+ int maxBufferSize;
+ int efficientBufferSize;
};
class QSensorReadingPrivate
@@ -123,7 +138,6 @@ public:
};
QT_END_NAMESPACE
-QT_END_HEADER
#endif
diff --git a/src/sensors/qsensorbackend.h b/src/sensors/qsensorbackend.h
index 92dc9e91..4c6ce8b5 100644
--- a/src/sensors/qsensorbackend.h
+++ b/src/sensors/qsensorbackend.h
@@ -45,11 +45,8 @@
#include <QtSensors/qsensor.h>
#include <QtSensors/qsensormanager.h>
-QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
-QT_MODULE(QtSensors)
-
class Q_SENSORS_EXPORT QSensorBackend : public QObject
{
Q_OBJECT
@@ -94,7 +91,6 @@ private:
};
QT_END_NAMESPACE
-QT_END_HEADER
#endif
diff --git a/src/sensors/qsensormanager.h b/src/sensors/qsensormanager.h
index c2037f75..8fa87d1f 100644
--- a/src/sensors/qsensormanager.h
+++ b/src/sensors/qsensormanager.h
@@ -44,11 +44,8 @@
#include <QtSensors/qsensor.h>
-QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
-QT_MODULE(QtSensors)
-
class QSensorBackend;
class QSensorBackendFactory;
class QSensorPluginInterface;
@@ -77,7 +74,6 @@ protected:
};
QT_END_NAMESPACE
-QT_END_HEADER
#endif
diff --git a/src/sensors/qsensorplugin.h b/src/sensors/qsensorplugin.h
index 5caef6f1..336bce6b 100644
--- a/src/sensors/qsensorplugin.h
+++ b/src/sensors/qsensorplugin.h
@@ -46,11 +46,8 @@
#include <QtCore/qplugin.h>
-QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
-QT_MODULE(QtSensors)
-
class Q_SENSORS_EXPORT QSensorPluginInterface
{
public:
@@ -71,7 +68,6 @@ Q_DECLARE_INTERFACE(QSensorPluginInterface, "com.qt-project.Qt.QSensorPluginInte
Q_DECLARE_INTERFACE(QSensorChangesInterface, "com.qt-project.Qt.QSensorChangesInterface/5.0")
QT_END_NAMESPACE
-QT_END_HEADER
#endif
diff --git a/src/sensors/qsensorsglobal.h b/src/sensors/qsensorsglobal.h
index bdd016ff..496ff4ac 100644
--- a/src/sensors/qsensorsglobal.h
+++ b/src/sensors/qsensorsglobal.h
@@ -44,11 +44,8 @@
#include <QtCore/qglobal.h>
-QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
-QT_MODULE(QtSensors)
-
#ifndef QT_STATIC
# if defined(QT_BUILD_SENSORS_LIB)
# define Q_SENSORS_EXPORT Q_DECL_EXPORT
@@ -60,7 +57,6 @@ QT_MODULE(QtSensors)
#endif
QT_END_NAMESPACE
-QT_END_HEADER
#endif // QSENSORSGLOBAL_H
diff --git a/src/sensors/qtapsensor.cpp b/src/sensors/qtapsensor.cpp
index bd65196b..23ec492f 100644
--- a/src/sensors/qtapsensor.cpp
+++ b/src/sensors/qtapsensor.cpp
@@ -211,7 +211,7 @@ char const * const QTapSensor::type("QTapSensor");
Construct the sensor as a child of \a parent.
*/
QTapSensor::QTapSensor(QObject *parent)
- : QSensor(QTapSensor::type, parent)
+ : QSensor(QTapSensor::type, *new QTapSensorPrivate, parent)
{
}
@@ -240,10 +240,24 @@ QTapSensor::~QTapSensor()
It is not possible to have the sensor report both single and double tap events.
If both are needed the app should create 2 sensor objects.
- Note that you must access this property via QObject::property() and QObject::setProperty().
The property must be set before calling start().
*/
+bool QTapSensor::returnDoubleTapEvents() const
+{
+ Q_D(const QTapSensor);
+ return d->returnDoubleTapEvents;
+}
+
+void QTapSensor::setReturnDoubleTapEvents(bool returnDoubleTapEvents)
+{
+ Q_D(QTapSensor);
+ if (d->returnDoubleTapEvents != returnDoubleTapEvents) {
+ d->returnDoubleTapEvents = returnDoubleTapEvents;
+ emit returnDoubleTapEventsChanged(returnDoubleTapEvents);
+ }
+}
+
#include "moc_qtapsensor.cpp"
QT_END_NAMESPACE
diff --git a/src/sensors/qtapsensor.h b/src/sensors/qtapsensor.h
index da71e965..74ca40c2 100644
--- a/src/sensors/qtapsensor.h
+++ b/src/sensors/qtapsensor.h
@@ -44,11 +44,8 @@
#include <QtSensors/qsensor.h>
-QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
-QT_MODULE(QtSensors)
-
class QTapReadingPrivate;
class Q_SENSORS_EXPORT QTapReading : public QSensorReading
@@ -90,24 +87,31 @@ private:
bool filter(QSensorReading *reading) { return filter(static_cast<QTapReading*>(reading)); }
};
+class QTapSensorPrivate;
+
class Q_SENSORS_EXPORT QTapSensor : public QSensor
{
Q_OBJECT
-#ifdef Q_QDOC
- Q_PROPERTY(bool returnDoubleTapEvents)
-#endif
+ Q_PROPERTY(bool returnDoubleTapEvents READ returnDoubleTapEvents WRITE setReturnDoubleTapEvents
+ NOTIFY returnDoubleTapEventsChanged)
public:
explicit QTapSensor(QObject *parent = 0);
virtual ~QTapSensor();
QTapReading *reading() const { return static_cast<QTapReading*>(QSensor::reading()); }
static char const * const type;
+ bool returnDoubleTapEvents() const;
+ void setReturnDoubleTapEvents(bool returnDoubleTapEvents);
+
+Q_SIGNALS:
+ void returnDoubleTapEventsChanged(bool returnDoubleTapEvents);
+
private:
+ Q_DECLARE_PRIVATE(QTapSensor);
Q_DISABLE_COPY(QTapSensor)
};
QT_END_NAMESPACE
-QT_END_HEADER
#endif
diff --git a/src/sensors/qtapsensor_p.h b/src/sensors/qtapsensor_p.h
index 68270e87..6bf81473 100644
--- a/src/sensors/qtapsensor_p.h
+++ b/src/sensors/qtapsensor_p.h
@@ -53,7 +53,8 @@
// We mean it.
//
-QT_BEGIN_HEADER
+#include "qsensor_p.h"
+
QT_BEGIN_NAMESPACE
class QTapReadingPrivate
@@ -69,8 +70,18 @@ public:
bool doubleTap;
};
+class QTapSensorPrivate : public QSensorPrivate
+{
+public:
+ QTapSensorPrivate()
+ : returnDoubleTapEvents(true)
+ {
+ }
+
+ bool returnDoubleTapEvents;
+};
+
QT_END_NAMESPACE
-QT_END_HEADER
#endif
diff --git a/src/sensors/qtiltsensor.h b/src/sensors/qtiltsensor.h
index 68dcdfea..246a103e 100644
--- a/src/sensors/qtiltsensor.h
+++ b/src/sensors/qtiltsensor.h
@@ -44,11 +44,8 @@
#include <QtSensors/qsensor.h>
-QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
-QT_MODULE(QtSensors)
-
class QTiltReadingPrivate;
class Q_SENSORS_EXPORT QTiltReading : public QSensorReading
@@ -91,5 +88,4 @@ private:
};
QT_END_NAMESPACE
-QT_END_HEADER
#endif
diff --git a/src/sensors/qtiltsensor_p.h b/src/sensors/qtiltsensor_p.h
index 14946243..e8cce136 100644
--- a/src/sensors/qtiltsensor_p.h
+++ b/src/sensors/qtiltsensor_p.h
@@ -53,7 +53,6 @@
// We mean it.
//
-QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
class QTiltReadingPrivate
@@ -70,5 +69,4 @@ public:
};
QT_END_NAMESPACE
-QT_END_HEADER
#endif
diff --git a/src/sensors/sensorlog_p.h b/src/sensors/sensorlog_p.h
index d1cde707..f808ab2d 100644
--- a/src/sensors/sensorlog_p.h
+++ b/src/sensors/sensorlog_p.h
@@ -53,7 +53,6 @@
// We mean it.
//
-QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
#ifdef ENABLE_RUNTIME_SENSORLOG
@@ -83,7 +82,6 @@ static bool logEnabled()
#endif
QT_END_NAMESPACE
-QT_END_HEADER
#endif
diff --git a/src/sensors/sensors.pro b/src/sensors/sensors.pro
index 2cb33468..fe10a5e7 100644
--- a/src/sensors/sensors.pro
+++ b/src/sensors/sensors.pro
@@ -12,6 +12,11 @@ simulator {
QMAKE_DOCS = $$PWD/doc/qtsensors.qdocconf
+ANDROID_JAR_DEPENDENCIES = \
+ jar/QtSensors.jar:org.qtproject.qt5.android.sensors.QtSensors
+ANDROID_LIB_DEPENDENCIES = \
+ plugins/sensors/libqtsensors_android.so
+
load(qt_module)
PUBLIC_HEADERS += \
@@ -51,8 +56,11 @@ simulator {
SENSORS=\
qsensor\
qaccelerometer\
+ qaltimeter\
qambientlightsensor\
+ qambienttemperaturesensor\
qcompass\
+ qholstersensor\
qlightsensor\
qmagnetometer\
qorientationsensor\
@@ -62,6 +70,7 @@ SENSORS=\
qtapsensor\
qtiltsensor\
qgyroscope\
+ qpressuresensor\
for(s,SENSORS) {
# Client API
diff --git a/tests/auto/qsensor/test_backends.h b/tests/auto/qsensor/test_backends.h
index a36a8586..b76d4128 100644
--- a/tests/auto/qsensor/test_backends.h
+++ b/tests/auto/qsensor/test_backends.h
@@ -48,12 +48,16 @@ void register_test_backends();
void unregister_test_backends();
#include <qaccelerometer.h>
+#include <qaltimeter.h>
#include <qambientlightsensor.h>
+#include <qambienttemperaturesensor.h>
#include <qcompass.h>
#include <qgyroscope.h>
+#include <qholstersensor.h>
#include <qlightsensor.h>
#include <qmagnetometer.h>
#include <qorientationsensor.h>
+#include <qpressuresensor.h>
#include <qproximitysensor.h>
#include <qrotationsensor.h>
#include <qtapsensor.h>
@@ -96,9 +100,15 @@ PREPARE_SENSORINTERFACE(QAccelerometer, QAccelerometerReading, QAccelerometerFil
reading->setY(1.0);
reading->setZ(1.0);
})
+PREPARE_SENSORINTERFACE(QAltimeter, QAltimeterReading, QAltimeterFilter, {
+ reading->setAltitude(8848);
+})
PREPARE_SENSORINTERFACE(QAmbientLightSensor, QAmbientLightReading, QAmbientLightFilter, {
reading->setLightLevel(QAmbientLightReading::Twilight);
})
+PREPARE_SENSORINTERFACE(QAmbientTemperatureSensor, QAmbientTemperatureReading, QAmbientTemperatureFilter, {
+ reading->setTemperature(30);
+})
PREPARE_SENSORINTERFACE(QCompass, QCompassReading, QCompassFilter, {
reading->setAzimuth(1.0);
reading->setCalibrationLevel(1.0);
@@ -108,6 +118,9 @@ PREPARE_SENSORINTERFACE(QGyroscope, QGyroscopeReading, QGyroscopeFilter, {
reading->setY(1.0);
reading->setZ(1.0);
})
+PREPARE_SENSORINTERFACE(QHolsterSensor, QHolsterReading, QHolsterFilter, {
+ reading->setHolstered(true);
+})
PREPARE_SENSORINTERFACE(QLightSensor, QLightReading, QLightFilter, {
reading->setLux(1.0);
})
@@ -120,6 +133,9 @@ PREPARE_SENSORINTERFACE(QMagnetometer, QMagnetometerReading, QMagnetometerFilter
PREPARE_SENSORINTERFACE(QOrientationSensor, QOrientationReading, QOrientationFilter, {
reading->setOrientation(QOrientationReading::LeftUp);
})
+PREPARE_SENSORINTERFACE(QPressureSensor, QPressureReading, QPressureFilter, {
+ reading->setPressure(1.0);
+})
PREPARE_SENSORINTERFACE(QProximitySensor, QProximityReading, QProximityFilter, {
reading->setClose(true);
})
diff --git a/tests/auto/qsensor/tst_qsensor.cpp b/tests/auto/qsensor/tst_qsensor.cpp
index a4591aa4..a410f711 100644
--- a/tests/auto/qsensor/tst_qsensor.cpp
+++ b/tests/auto/qsensor/tst_qsensor.cpp
@@ -847,10 +847,18 @@ private slots:
QCOMPARE(reading->z(), 1.0);
})
+ TEST_SENSORINTERFACE(QAltimeter, QAltimeterReading, {
+ QCOMPARE(reading->altitude(), 8848.0);
+ })
+
TEST_SENSORINTERFACE(QAmbientLightSensor, QAmbientLightReading, {
QCOMPARE(reading->lightLevel(), QAmbientLightReading::Twilight);
})
+ TEST_SENSORINTERFACE(QAmbientTemperatureSensor, QAmbientTemperatureReading, {
+ QCOMPARE(reading->temperature(), 30.0);
+ })
+
TEST_SENSORINTERFACE(QCompass, QCompassReading, {
QCOMPARE(reading->azimuth(), 1.0);
QCOMPARE(reading->calibrationLevel(), 1.0);
@@ -862,6 +870,10 @@ private slots:
QCOMPARE(reading->z(), 1.0);
})
+ TEST_SENSORINTERFACE(QHolsterSensor, QHolsterReading, {
+ QCOMPARE(reading->holstered(), true);
+ })
+
TEST_SENSORINTERFACE(QLightSensor, QLightReading, {
QCOMPARE(reading->lux(), 1.0);
})
@@ -877,6 +889,10 @@ private slots:
QCOMPARE(reading->orientation(), QOrientationReading::LeftUp);
})
+ TEST_SENSORINTERFACE(QPressureSensor, QPressureReading, {
+ QCOMPARE(reading->pressure(), 1.0);
+ })
+
TEST_SENSORINTERFACE(QProximitySensor, QProximityReading, {
QCOMPARE(reading->close(), true);
})
@@ -959,6 +975,7 @@ private slots:
QVERIFY(!sensor.isFeatureSupported(QSensor::Buffering));
QVERIFY(!sensor.isFeatureSupported(QSensor::GeoValues));
QVERIFY(!sensor.isFeatureSupported(QSensor::FieldOfView));
+ QVERIFY(!sensor.isFeatureSupported(QSensor::AccelerationMode));
// Connect to backend - according to the testsensorimpl implementation, AlwaysOn and
// GeoValues should be supported afterwards
@@ -968,6 +985,7 @@ private slots:
QVERIFY(!sensor.isFeatureSupported(QSensor::Buffering));
QVERIFY(sensor.isFeatureSupported(QSensor::GeoValues));
QVERIFY(!sensor.isFeatureSupported(QSensor::FieldOfView));
+ QVERIFY(!sensor.isFeatureSupported(QSensor::AccelerationMode));
}
};