diff options
author | Thomas McGuire <thomas.mcguire.qnx@kdab.com> | 2013-01-31 17:42:18 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-02-08 11:17:56 +0100 |
commit | 62ce0b92ee34a1ae6b2f4e81bb0efbaa2a7d53c9 (patch) | |
tree | a0c90db7d7b6dcd7233474a7cbfd30ff58402e74 /src | |
parent | 27cc67b75373905931448c3228e20a6c8d0797e6 (diff) |
Repair duplicate skipping for the tilt sensor
Found because the compiler was warning about an unused "change"
variable.
Change-Id: Iac968685ba8da7a4d38a00427d22d1e01e31b25f
Reviewed-by: Lorn Potter <lorn.potter@jollamobile.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/plugins/sensors/generic/generictiltsensor.cpp | 30 | ||||
-rw-r--r-- | src/plugins/sensors/generic/generictiltsensor.h | 2 |
2 files changed, 17 insertions, 15 deletions
diff --git a/src/plugins/sensors/generic/generictiltsensor.cpp b/src/plugins/sensors/generic/generictiltsensor.cpp index 01281bd0..dc118bf7 100644 --- a/src/plugins/sensors/generic/generictiltsensor.cpp +++ b/src/plugins/sensors/generic/generictiltsensor.cpp @@ -159,27 +159,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; } - xRotation = rad2deg(xRotation); - yRotation = rad2deg(yRotation); - - 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); @@ -188,3 +183,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 4d228bbc..0f84ca6f 100644 --- a/src/plugins/sensors/generic/generictiltsensor.h +++ b/src/plugins/sensors/generic/generictiltsensor.h @@ -63,6 +63,8 @@ public: bool filter(QAccelerometerReading *reading); + bool isFeatureSupported(QSensor::Feature feature) const Q_DECL_OVERRIDE; + private: QTiltReading m_reading; QAccelerometer *accelerometer; |