summaryrefslogtreecommitdiffstats
path: root/src/plugins/sensorgestures/qtsensors/qhoversensorgesturerecognizer.cpp
diff options
context:
space:
mode:
authorLorn Potter <lorn.potter@nokia.com>2012-02-01 10:28:51 +1000
committerQt by Nokia <qt-info@nokia.com>2012-02-01 06:24:50 +0100
commit89fbd66b01bab3eca2ed9591f158f28d6e43e9e2 (patch)
treee41f9c52421a9e011851720f628638870b9d1de0 /src/plugins/sensorgestures/qtsensors/qhoversensorgesturerecognizer.cpp
parentb643afb7845d4fc15eb469d0d9a1ec18b0dbb254 (diff)
try harder to make sure gesture dont fire too easily
some gestures will fire when trying other gestures. Make sure they don't collide and provide false positives as much. Change-Id: I4abd7d9ee876b77a211ae1b46bcc56f4fdc64ec0 Sanity-Review: Qt Sanity Bot <qt_sanity_bot@ovi.com> 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.cpp48
1 files changed, 27 insertions, 21 deletions
diff --git a/src/plugins/sensorgestures/qtsensors/qhoversensorgesturerecognizer.cpp b/src/plugins/sensorgestures/qtsensors/qhoversensorgesturerecognizer.cpp
index 096d83c4..4717c7d5 100644
--- a/src/plugins/sensorgestures/qtsensors/qhoversensorgesturerecognizer.cpp
+++ b/src/plugins/sensorgestures/qtsensors/qhoversensorgesturerecognizer.cpp
@@ -55,8 +55,11 @@ QHoverSensorGestureRecognizer::~QHoverSensorGestureRecognizer()
void QHoverSensorGestureRecognizer::create()
{
- light = new QLightSensor(this);
- light->connectToBackend();
+ proximity = new QProximitySensor(this);
+ proximity->connectToBackend();
+
+ irProx = new QIRProximitySensor(this);
+ irProx->connectToBackend();
timer = new QTimer(this);
connect(timer,SIGNAL(timeout()),this,SLOT(timeout()));
@@ -66,7 +69,7 @@ void QHoverSensorGestureRecognizer::create()
timer2 = new QTimer(this);
connect(timer2,SIGNAL(timeout()),this,SLOT(timeout2()));
timer2->setSingleShot(true);
- timer2->setInterval(3000);
+ timer2->setInterval(5000);
}
QString QHoverSensorGestureRecognizer::id() const
@@ -76,47 +79,50 @@ QString QHoverSensorGestureRecognizer::id() const
bool QHoverSensorGestureRecognizer::start()
{
- connect(light,SIGNAL(readingChanged()), this,SLOT(lightChanged()));
- light->start();
- return light->isActive();
+ connect(irProx,SIGNAL(readingChanged()), this,SLOT(proxyChanged()));
+ proximity->start();
+ irProx->start();
+ return irProx->isActive();
}
bool QHoverSensorGestureRecognizer::stop()
{
- light->stop();
- disconnect(light,SIGNAL(readingChanged()),this,SLOT(lightChanged()));
- return light->isActive();
+ proximity->stop();
+ irProx->stop();
+ disconnect(irProx,SIGNAL(readingChanged()),this,SLOT(proxyChanged()));
+ return irProx->isActive();
}
bool QHoverSensorGestureRecognizer::isActive()
{
- return light->isActive();
+ return irProx->isActive();
}
-void QHoverSensorGestureRecognizer::lightChanged()
+void QHoverSensorGestureRecognizer::proxyChanged()
{
- qreal lightReading = light->reading()->lux();
-
- int difference = 100 - (lightReading/lastLightReading) * 100;
-
- if (difference == 0) {
+ if (proximity->reading()->close()) {
+ hoverOk = false;
+ detecting = false;
return;
}
- if (!detecting && difference > 19) {
-// if (lightReading < lastLightReading ) {
+ int refl = irProx->reading()->reflectance() * 100;
+
+ if (!detecting && (refl > 20 && refl < 35)) {
detecting = true;
timer->start();
timer2->start();
- } else if (hoverOk && detecting && difference < -24) {
+
+ } else if (hoverOk && detecting
+ && refl == 0) {
// went light again after 1 seconds
-// qDebug() << "hover";
Q_EMIT hover();
Q_EMIT detected("hover");
hoverOk = false;
detecting = false;
}
- lastLightReading = lightReading;
+ if (refl == 0)
+ detecting = false;
}
void QHoverSensorGestureRecognizer::timeout()