summaryrefslogtreecommitdiffstats
path: root/src/plugins/sensorgestures/qtsensors/qtwistsensorgesturerecognizer.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/sensorgestures/qtsensors/qtwistsensorgesturerecognizer.cpp')
-rw-r--r--src/plugins/sensorgestures/qtsensors/qtwistsensorgesturerecognizer.cpp29
1 files changed, 17 insertions, 12 deletions
diff --git a/src/plugins/sensorgestures/qtsensors/qtwistsensorgesturerecognizer.cpp b/src/plugins/sensorgestures/qtsensors/qtwistsensorgesturerecognizer.cpp
index fbbb37d0..01e7d234 100644
--- a/src/plugins/sensorgestures/qtsensors/qtwistsensorgesturerecognizer.cpp
+++ b/src/plugins/sensorgestures/qtsensors/qtwistsensorgesturerecognizer.cpp
@@ -167,19 +167,13 @@ void QTwistSensorGestureRecognizer::accelChanged(QAccelerometerReading *reading)
if (detecting
&& qAbs(degrees) < RESTING_VARIANCE
&& qAbs(pitch) < RESTING_VARIANCE
- && (qAbs(lastRoll + degrees) > (degrees / 2))
- ) {
- if (lastRoll > 0 ) {
- Q_EMIT twistLeft();
- Q_EMIT detected("twistLeft");
- } else {
- Q_EMIT twistRight();
- Q_EMIT detected("twistRight");
- }
+ && (qAbs(lastRoll + degrees) > (degrees / 2))) {
+
+ QTimer::singleShot(0,this,SLOT(checkTwist()));
// don't give two signals for same gestures
- detecting = false;
- timer->stop();
- lastRoll = degrees;
+ detecting = false;
+ timer->stop();
+ lastRoll = degrees;
}
if (orientationReading->orientation() == QOrientationReading::FaceUp
@@ -207,6 +201,17 @@ void QTwistSensorGestureRecognizer::accelChanged(QAccelerometerReading *reading)
lastX = x; lastY = y;
}
+void QTwistSensorGestureRecognizer::checkTwist()
+{
+ if (lastRoll > 0 && orientationReading->orientation() == QOrientationReading::RightUp) {
+ Q_EMIT twistLeft();
+ Q_EMIT detected("twistLeft");
+ } else if (orientationReading->orientation() == QOrientationReading::LeftUp){
+ Q_EMIT twistRight();
+ Q_EMIT detected("twistRight");
+ }
+}
+
void QTwistSensorGestureRecognizer::timeout()
{
detecting = false;