diff options
author | Lorn Potter <lorn.potter@nokia.com> | 2012-05-10 09:00:58 +1000 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-05-11 11:51:15 +0200 |
commit | fb06538ffb57d82ae63b61dc7798f740fe27ba3e (patch) | |
tree | 229bbde8fa8b856e5999ea3f340f68ab35254957 /src/plugins/sensorgestures/qtsensors/qtwistsensorgesturerecognizer.cpp | |
parent | d45a9503de3f94a9630a34efb0e9ea02f894856e (diff) |
fix up gestures for auto test data
slam and other gestures need to be performed the way the test data
shows.
slam is effected the most as now the gesture needs no hold at end to be
recognized, in accordance with data collected.
Change-Id: Iedfcf8e42def0b1dfe1c4d289a416ca64d8846e1
Reviewed-by: Lincoln Ramsay <lincoln.ramsay@nokia.com>
Diffstat (limited to 'src/plugins/sensorgestures/qtsensors/qtwistsensorgesturerecognizer.cpp')
-rw-r--r-- | src/plugins/sensorgestures/qtsensors/qtwistsensorgesturerecognizer.cpp | 48 |
1 files changed, 25 insertions, 23 deletions
diff --git a/src/plugins/sensorgestures/qtsensors/qtwistsensorgesturerecognizer.cpp b/src/plugins/sensorgestures/qtsensors/qtwistsensorgesturerecognizer.cpp index 3956f17d..002f838e 100644 --- a/src/plugins/sensorgestures/qtsensors/qtwistsensorgesturerecognizer.cpp +++ b/src/plugins/sensorgestures/qtsensors/qtwistsensorgesturerecognizer.cpp @@ -72,7 +72,7 @@ void QTwistSensorGestureRecognizer::create() timer = new QTimer(this); connect(timer,SIGNAL(timeout()),this,SLOT(timeout())); timer->setSingleShot(true); - timer->setInterval(500); + timer->setInterval(750); } QString QTwistSensorGestureRecognizer::id() const @@ -142,15 +142,28 @@ void QTwistSensorGestureRecognizer::accelChanged(QAccelerometerReading *reading) if (orientationReading == 0) return; + if (negativeList.count() > 5) + negativeList.removeLast(); + + if ((((x < 0 && lastX > 0) || (x > 0 && lastX < 0)) && qAbs(diffX) > (accelRange * 0.35)) + || (x < 0 && lastX < 0 && qAbs(diffX > accelRange * 0.35)) + || (x > 0 && lastX > 0 && qAbs(diffX > accelRange * 0.35)) + || (((y < 0 && lastY > 0) || (y > 0 && lastY < 0)) && qAbs(diffY) > (accelRange * 0.35))) { + negativeList.insert(0,true); + } else { + negativeList.insert(0,false); + } + + if (detecting + && isShake()) { + // if shake-like: + detecting = false; + timer->stop(); + lastRoll = degrees; + } + if (rollList.count() > 4) { if (detecting - && isShake()) { - // if shake-like: - detecting = false; - timer->stop(); - lastRoll = degrees; - } - if (detecting && qAbs(degrees) < RESTING_VARIANCE && qAbs(pitch) < RESTING_VARIANCE && (qAbs(lastRoll + degrees) > (degrees / 2)) @@ -175,7 +188,6 @@ void QTwistSensorGestureRecognizer::accelChanged(QAccelerometerReading *reading) detecting = true; timer->start(); lastRoll = degrees; - lastOrientation = orientationReading->orientation(); } if (detecting && (orientationReading->orientation() == QOrientationReading::TopUp @@ -187,16 +199,6 @@ void QTwistSensorGestureRecognizer::accelChanged(QAccelerometerReading *reading) } } - if (negativeList.count() > 5) - negativeList.removeLast(); - - if ((((x < 0 && lastX > 0) || (x > 0 && lastX < 0)) && qAbs(diffX) > (accelRange * 0.5)) - || (((y < 0 && lastY > 0) || (y > 0 && lastY < 0)) && qAbs(diffY) > (accelRange * 0.5))) { - negativeList.insert(0,true); - } else { - negativeList.insert(0,false); - } - if (rollList.count() > 5) rollList.removeLast(); rollList.insert(0,degrees); @@ -208,17 +210,17 @@ void QTwistSensorGestureRecognizer::timeout() { detecting = false; lastRoll = 0; - lastOrientation = QOrientationReading::Undefined; } bool QTwistSensorGestureRecognizer::isShake() { - for (int i = 0; i < negativeList.count() - 1; i++) { + int count = 0; + for (int i = 1; i < negativeList.count() - 1; i++) { if (negativeList.at(i)) { - return true; + count++; } } - return false; + return (count > 1); } |