diff options
author | Lorn Potter <lorn.potter@nokia.com> | 2012-05-18 11:48:52 +1000 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-05-18 04:50:02 +0200 |
commit | a697ee84cd4c854046b5876a44d6215c468cce18 (patch) | |
tree | 40ae3a425398ce02ee7a12518527768720b924a9 /src/plugins/sensorgestures | |
parent | eb2ae89dc043a0c0be419de2f2f76016e360b4dd (diff) |
make twist dependent upon an orientation change.
This fixes getting a twist gesture by just moving the device left or right.
and update one test data that did not have needed orientation change
when the gesture was performed.
Change-Id: I4fd9148d3f9c3d093530d08c2f6834f0972c659e
Reviewed-by: Lincoln Ramsay <lincoln.ramsay@nokia.com>
Diffstat (limited to 'src/plugins/sensorgestures')
-rw-r--r-- | src/plugins/sensorgestures/qtsensors/qtwistsensorgesturerecognizer.cpp | 29 | ||||
-rw-r--r-- | src/plugins/sensorgestures/qtsensors/qtwistsensorgesturerecognizer.h | 1 |
2 files changed, 18 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; diff --git a/src/plugins/sensorgestures/qtsensors/qtwistsensorgesturerecognizer.h b/src/plugins/sensorgestures/qtsensors/qtwistsensorgesturerecognizer.h index 6beb7c82..9cd46f64 100644 --- a/src/plugins/sensorgestures/qtsensors/qtwistsensorgesturerecognizer.h +++ b/src/plugins/sensorgestures/qtsensors/qtwistsensorgesturerecognizer.h @@ -72,6 +72,7 @@ private slots: void accelChanged(QAccelerometerReading *reading); void orientationReadingChanged(QOrientationReading *reading); void timeout(); + void checkTwist(); private: |