summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLorn Potter <lorn.potter@nokia.com>2012-03-26 13:07:28 +1000
committerQt by Nokia <qt-info@nokia.com>2012-03-26 05:11:06 +0200
commitdfc746b0bf8baaedc580e72f9897814ef9f4c560 (patch)
tree607254f3ab19022ef177a11fe9918d9b32790c13
parent53a555053376bbad0a21649464370772447475c5 (diff)
fix slam gesture to be downward only motion.
Change-Id: I3b115ca075610e7ca63828d1b3cc3e72e3820d75 Reviewed-by: Lincoln Ramsay <lincoln.ramsay@nokia.com>
-rw-r--r--doc/src/images/sensorgesture-slam_1.pngbin30696 -> 26212 bytes
-rw-r--r--doc/src/qtsensorgestures-plugins.qdoc4
-rw-r--r--src/plugins/sensorgestures/qtsensors/qslamgesturerecognizer.cpp26
-rw-r--r--src/plugins/sensorgestures/qtsensors/qslamgesturerecognizer.h2
4 files changed, 18 insertions, 14 deletions
diff --git a/doc/src/images/sensorgesture-slam_1.png b/doc/src/images/sensorgesture-slam_1.png
index 89b5e7d4..d56f8892 100644
--- a/doc/src/images/sensorgesture-slam_1.png
+++ b/doc/src/images/sensorgesture-slam_1.png
Binary files differ
diff --git a/doc/src/qtsensorgestures-plugins.qdoc b/doc/src/qtsensorgestures-plugins.qdoc
index d78f401e..b6dc9c77 100644
--- a/doc/src/qtsensorgestures-plugins.qdoc
+++ b/doc/src/qtsensorgestures-plugins.qdoc
@@ -143,8 +143,8 @@ For QtSensorGestures plugin:
\row
\li QtSensors.slam
\li slam
- \li Phone is held in a top up position with a side facing forward. Move phone up, then swing it down and then held stationary briefly.
- Like it is being used to point at something with the top corner. using the Accelerometer and Orientation sensors.
+ \li Phone is held in a top up position with a side facing forward. Swing it with a downward motion and then
+ hold stationary briefly, like it is being used to point at something with the top corner. using the Accelerometer and Orientation sensors.
\li \image sensorgesture-slam_1.png
\image sensorgesture-slam_2.png
\row
diff --git a/src/plugins/sensorgestures/qtsensors/qslamgesturerecognizer.cpp b/src/plugins/sensorgestures/qtsensors/qslamgesturerecognizer.cpp
index f8db7c29..ea3be725 100644
--- a/src/plugins/sensorgestures/qtsensors/qslamgesturerecognizer.cpp
+++ b/src/plugins/sensorgestures/qtsensors/qslamgesturerecognizer.cpp
@@ -128,8 +128,6 @@ void QSlamSensorGestureRecognizer::orientationReadingChanged(QOrientationReading
#define SLAM_Y_DEGREES 15
-#define RADIANS_TO_DEGREES 57.2957795
-
void QSlamSensorGestureRecognizer::accelChanged(QAccelerometerReading *reading)
{
const qreal x = reading->x();
@@ -155,8 +153,6 @@ void QSlamSensorGestureRecognizer::accelChanged(QAccelerometerReading *reading)
const qreal difference = lastX - x;
- roll = qAtan(x / qSqrt(y*y + z*z)) * RADIANS_TO_DEGREES;
-
if (!timer->isActive()
&& detecting
&& (orientationReading->orientation() == QOrientationReading::RightUp
@@ -164,12 +160,9 @@ void QSlamSensorGestureRecognizer::accelChanged(QAccelerometerReading *reading)
&& resting) {
timer->start();
}
-
if (!detecting
&& orientationReading->orientation() == QOrientationReading::TopUp
- && roll < SLAM_Y_DEGREES
- && (difference > accelRange * SLAM_DETECTION_FACTOR
- || difference < -accelRange * SLAM_DETECTION_FACTOR)) {
+ && hasBeenResting()) {
detectedX = x;
// start of gesture
detecting = true;
@@ -185,15 +178,24 @@ void QSlamSensorGestureRecognizer::accelChanged(QAccelerometerReading *reading)
lastZ = z;
}
-void QSlamSensorGestureRecognizer:: checkForSlam()
-{
+bool QSlamSensorGestureRecognizer::hasBeenResting()
+{
for (int i = 0; i < restingList.count() - 1; i++) {
if (!restingList.at(i)) {
- detecting = false;
- return;
+ return false;
}
}
+ return true;
+}
+
+void QSlamSensorGestureRecognizer::checkForSlam()
+{
+
+ if (!hasBeenResting()) {
+ detecting = false;
+ return;
+ }
if (detecting && (orientationReading->orientation() == QOrientationReading::RightUp // 3 or 4
|| orientationReading->orientation() == QOrientationReading::LeftUp)) {
diff --git a/src/plugins/sensorgestures/qtsensors/qslamgesturerecognizer.h b/src/plugins/sensorgestures/qtsensors/qslamgesturerecognizer.h
index 4ea6530a..eb31c818 100644
--- a/src/plugins/sensorgestures/qtsensors/qslamgesturerecognizer.h
+++ b/src/plugins/sensorgestures/qtsensors/qslamgesturerecognizer.h
@@ -92,6 +92,8 @@ private:
QList<qreal> restingList;
bool resting;
QList<qreal> xList;
+
+ bool hasBeenResting();
};
QT_END_NAMESPACE