summaryrefslogtreecommitdiffstats
path: root/src/plugins/sensorgestures/qtsensors/qhoversensorgesturerecognizer.cpp
diff options
context:
space:
mode:
authorLorn Potter <lorn.potter@nokia.com>2012-02-07 08:58:29 +1000
committerQt by Nokia <qt-info@nokia.com>2012-02-08 06:59:15 +0100
commit68045db7c9025f5d0fa82e33a71df4fe48754fe6 (patch)
tree50536371738c43d28ed7b885b59ebfcfb54dde49 /src/plugins/sensorgestures/qtsensors/qhoversensorgesturerecognizer.cpp
parent820e423d6bfe5368b081c6956c767ea8027df0d6 (diff)
fix hover and cover since prox driver output changed.
Change-Id: Ic620a9012472c81f7f1bb15e450638745809effa Reviewed-by: Lorn Potter <lorn.potter@nokia.com>
Diffstat (limited to 'src/plugins/sensorgestures/qtsensors/qhoversensorgesturerecognizer.cpp')
-rw-r--r--src/plugins/sensorgestures/qtsensors/qhoversensorgesturerecognizer.cpp24
1 files changed, 12 insertions, 12 deletions
diff --git a/src/plugins/sensorgestures/qtsensors/qhoversensorgesturerecognizer.cpp b/src/plugins/sensorgestures/qtsensors/qhoversensorgesturerecognizer.cpp
index 4717c7d5..a441cda6 100644
--- a/src/plugins/sensorgestures/qtsensors/qhoversensorgesturerecognizer.cpp
+++ b/src/plugins/sensorgestures/qtsensors/qhoversensorgesturerecognizer.cpp
@@ -41,6 +41,8 @@
#include "qhoversensorgesturerecognizer.h"
+#include <math.h>
+
QT_BEGIN_NAMESPACE
QHoverSensorGestureRecognizer::QHoverSensorGestureRecognizer(QObject *parent) :
@@ -55,9 +57,6 @@ QHoverSensorGestureRecognizer::~QHoverSensorGestureRecognizer()
void QHoverSensorGestureRecognizer::create()
{
- proximity = new QProximitySensor(this);
- proximity->connectToBackend();
-
irProx = new QIRProximitySensor(this);
irProx->connectToBackend();
@@ -80,14 +79,12 @@ QString QHoverSensorGestureRecognizer::id() const
bool QHoverSensorGestureRecognizer::start()
{
connect(irProx,SIGNAL(readingChanged()), this,SLOT(proxyChanged()));
- proximity->start();
irProx->start();
return irProx->isActive();
}
bool QHoverSensorGestureRecognizer::stop()
{
- proximity->stop();
irProx->stop();
disconnect(irProx,SIGNAL(readingChanged()),this,SLOT(proxyChanged()));
return irProx->isActive();
@@ -100,28 +97,31 @@ bool QHoverSensorGestureRecognizer::isActive()
void QHoverSensorGestureRecognizer::proxyChanged()
{
- if (proximity->reading()->close()) {
+ qreal refl = irProx->reading()->reflectance();
+
+ if (refl > .51) {
hoverOk = false;
detecting = false;
return;
}
- int refl = irProx->reading()->reflectance() * 100;
-
- if (!detecting && (refl > 20 && refl < 35)) {
+ if (!detecting && (refl > .40 && refl < .50)) {
detecting = true;
timer->start();
timer2->start();
+ detectedHigh = refl;
} else if (hoverOk && detecting
- && refl == 0) {
+ && refl < .33
+ && detectedHigh
+ ) {
// went light again after 1 seconds
Q_EMIT hover();
Q_EMIT detected("hover");
hoverOk = false;
detecting = false;
}
- if (refl == 0)
+ if (refl > .60)
detecting = false;
}
@@ -130,9 +130,9 @@ void QHoverSensorGestureRecognizer::timeout()
hoverOk = true;
}
-
void QHoverSensorGestureRecognizer::timeout2()
{
detecting = false;
}
+
QT_END_NAMESPACE