summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.qmake.conf2
-rw-r--r--dist/changes-5.15.228
-rw-r--r--examples/sensors/grue/lib/lib.pri3
-rw-r--r--examples/sensors/grue/lib/lib.pro1
-rw-r--r--src/plugins/sensors/android/androidrotation.cpp41
-rw-r--r--src/plugins/sensors/android/sensoreventqueue.h3
6 files changed, 69 insertions, 9 deletions
diff --git a/.qmake.conf b/.qmake.conf
index 2b92eda5..3880db6d 100644
--- a/.qmake.conf
+++ b/.qmake.conf
@@ -1,3 +1,3 @@
load(qt_build_config)
-MODULE_VERSION = 5.15.3
+MODULE_VERSION = 5.15.13
diff --git a/dist/changes-5.15.2 b/dist/changes-5.15.2
new file mode 100644
index 00000000..3f584aec
--- /dev/null
+++ b/dist/changes-5.15.2
@@ -0,0 +1,28 @@
+Qt 5.15.2 is a bug-fix release. It maintains both forward and backward
+compatibility (source and binary) with Qt 5.15.1.
+
+For more details, refer to the online documentation included in this
+distribution. The documentation is also available online:
+
+ https://doc.qt.io/qt-5.15/index.html
+
+The Qt version 5.15 series is binary compatible with the 5.14.x series.
+Applications compiled for 5.14 will continue to run with 5.15.
+
+Some of the changes listed in this file include issue tracking numbers
+corresponding to tasks in the Qt Bug Tracker:
+
+ https://bugreports.qt.io/
+
+Each of these identifiers can be entered in the bug tracker to obtain more
+information about a particular change.
+
+****************************************************************************
+* Important Behavior Changes *
+****************************************************************************
+
+****************************************************************************
+* Library *
+****************************************************************************
+
+
diff --git a/examples/sensors/grue/lib/lib.pri b/examples/sensors/grue/lib/lib.pri
index 0e3da252..675914bc 100644
--- a/examples/sensors/grue/lib/lib.pri
+++ b/examples/sensors/grue/lib/lib.pri
@@ -3,4 +3,5 @@ INCLUDEPATH += $$PWD
macos: LIBS += -L$$OUT_PWD/../grue_app.app/Contents/Frameworks
else: LIBS += -L$$OUT_PWD/..
-LIBS += -lgruesensor
+android: LIBS += -lgruesensor_$${QT_ARCH}
+else: LIBS += -lgruesensor
diff --git a/examples/sensors/grue/lib/lib.pro b/examples/sensors/grue/lib/lib.pro
index cc10e5c4..197d91c8 100644
--- a/examples/sensors/grue/lib/lib.pro
+++ b/examples/sensors/grue/lib/lib.pro
@@ -1,5 +1,6 @@
TEMPLATE = lib
TARGET = gruesensor
+android: TARGET = gruesensor_$${QT_ARCH}
macos: DESTDIR = ../grue_app.app/Contents/Frameworks
else: DESTDIR = $$OUT_PWD/..
diff --git a/src/plugins/sensors/android/androidrotation.cpp b/src/plugins/sensors/android/androidrotation.cpp
index c1d141a0..068d305f 100644
--- a/src/plugins/sensors/android/androidrotation.cpp
+++ b/src/plugins/sensors/android/androidrotation.cpp
@@ -48,12 +48,41 @@ AndroidRotation::AndroidRotation(int type, QSensor *sensor, QObject *parent)
void AndroidRotation::dataReceived(const ASensorEvent &event)
{
- // ### Check me, at first look it seems wrong,
- // here https://developer.android.com/reference/android/hardware/SensorEvent.html#sensor.type_rotation_vector:
- // are the Android values
- qreal rz = -qRadiansToDegrees(qreal(event.data[0])); // event.data[0] corresponds to x
- qreal rx = -qRadiansToDegrees(qreal(event.data[1])); // event.data[1] corresponds to y
- qreal ry = qRadiansToDegrees(qreal(event.data[2])); // event.data[2] corresponds to z
+ // From android documentation, the rotation sensor values are:
+ // values[0]: x*sin(θ/2)
+ // values[1]: y*sin(θ/2)
+ // values[2]: z*sin(θ/2)
+ // values[3]: cos(θ/2)
+
+ // The mathematics below is adapted from
+ // https://android.googlesource.com/platform/frameworks/base/+/master/core/java/android/hardware/SensorManager.java#1644
+ // and
+ // https://android.googlesource.com/platform/frameworks/base/+/master/core/java/android/hardware/SensorManager.java#1469
+ // (getRotationMatrixFromVector() followed by getOrientation())
+ qreal angles[3];
+ qreal q1 = qreal(event.data[0]);
+ qreal q2 = qreal(event.data[1]);
+ qreal q3 = qreal(event.data[2]);
+ qreal q0 = qreal(event.data[3]);
+
+ qreal sq_q1 = 2 * q1 * q1;
+ qreal sq_q2 = 2 * q2 * q2;
+ qreal sq_q3 = 2 * q3 * q3;
+ qreal q1_q2 = 2 * q1 * q2;
+ qreal q3_q0 = 2 * q3 * q0;
+ qreal q1_q3 = 2 * q1 * q3;
+ qreal q2_q0 = 2 * q2 * q0;
+ qreal q2_q3 = 2 * q2 * q3;
+ qreal q1_q0 = 2 * q1 * q0;
+
+ angles[0] = std::atan2((q1_q2 - q3_q0), (1 - sq_q1 - sq_q3));
+ angles[1] = std::asin(-(q2_q3 + q1_q0));
+ angles[2] = std::atan2(-(q1_q3 - q2_q0), (1 - sq_q1 - sq_q2));
+
+ qreal rz = -qRadiansToDegrees(angles[0]);
+ qreal rx = -qRadiansToDegrees(angles[1]);
+ qreal ry = qRadiansToDegrees(angles[2]);
+
if (sensor()->skipDuplicates() && qFuzzyCompare(m_reader.x(), rx) &&
qFuzzyCompare(m_reader.y(), ry) &&
qFuzzyCompare(m_reader.z(), rz)) {
diff --git a/src/plugins/sensors/android/sensoreventqueue.h b/src/plugins/sensors/android/sensoreventqueue.h
index 77bf05c6..e6087059 100644
--- a/src/plugins/sensors/android/sensoreventqueue.h
+++ b/src/plugins/sensors/android/sensoreventqueue.h
@@ -125,8 +125,9 @@ public:
void start() override
{
ASensorEventQueue_enableSensor(m_sensorEventQueue, m_sensor);
+ // The QSensor datarate is in Hz (frequency), whereas the setEventRate expects microseconds
if (sensor()->dataRate() > 0)
- ASensorEventQueue_setEventRate(m_sensorEventQueue, m_sensor, std::max(ASensor_getMinDelay(m_sensor), sensor()->dataRate()));
+ ASensorEventQueue_setEventRate(m_sensorEventQueue, m_sensor, std::max(ASensor_getMinDelay(m_sensor), 1000000/sensor()->dataRate()));
m_started = true;
}
void stop() override