summaryrefslogtreecommitdiffstats
path: root/src/plugins/sensorgestures/qtsensors/qcoversensorgesturerecognizer.cpp
diff options
context:
space:
mode:
authorLorn Potter <lorn.potter@nokia.com>2012-05-10 09:00:58 +1000
committerQt by Nokia <qt-info@nokia.com>2012-05-11 11:51:15 +0200
commitfb06538ffb57d82ae63b61dc7798f740fe27ba3e (patch)
tree229bbde8fa8b856e5999ea3f340f68ab35254957 /src/plugins/sensorgestures/qtsensors/qcoversensorgesturerecognizer.cpp
parentd45a9503de3f94a9630a34efb0e9ea02f894856e (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/qcoversensorgesturerecognizer.cpp')
-rw-r--r--src/plugins/sensorgestures/qtsensors/qcoversensorgesturerecognizer.cpp41
1 files changed, 15 insertions, 26 deletions
diff --git a/src/plugins/sensorgestures/qtsensors/qcoversensorgesturerecognizer.cpp b/src/plugins/sensorgestures/qtsensors/qcoversensorgesturerecognizer.cpp
index bfc1f827..1af52f07 100644
--- a/src/plugins/sensorgestures/qtsensors/qcoversensorgesturerecognizer.cpp
+++ b/src/plugins/sensorgestures/qtsensors/qcoversensorgesturerecognizer.cpp
@@ -46,7 +46,7 @@ QT_BEGIN_NAMESPACE
QCoverSensorGestureRecognizer::QCoverSensorGestureRecognizer(QObject *parent) :
QSensorGestureRecognizer(parent),
- orientationReading(0), proximityReading(0),lastProx(0), active(0), detecting(0)
+ orientationReading(0), proximityReading(0),active(0), detecting(0)
{
}
@@ -59,7 +59,7 @@ void QCoverSensorGestureRecognizer::create()
timer = new QTimer(this);
connect(timer,SIGNAL(timeout()),this,SLOT(timeout()));
timer->setSingleShot(true);
- timer->setInterval(1000);
+ timer->setInterval(750);
}
QString QCoverSensorGestureRecognizer::id() const
@@ -69,16 +69,16 @@ QString QCoverSensorGestureRecognizer::id() const
bool QCoverSensorGestureRecognizer::start()
{
- if (QtSensorGestureSensorHandler::instance()->startSensor(QtSensorGestureSensorHandler::IrProximity)) {
+ if (QtSensorGestureSensorHandler::instance()->startSensor(QtSensorGestureSensorHandler::Proximity)) {
if (QtSensorGestureSensorHandler::instance()->startSensor(QtSensorGestureSensorHandler::Orientation)) {
active = true;
- connect(QtSensorGestureSensorHandler::instance(),SIGNAL(irProximityReadingChanged(QIRProximityReading *)),
- this,SLOT(proximityChanged(QIRProximityReading *)));
+ connect(QtSensorGestureSensorHandler::instance(),SIGNAL(proximityReadingChanged(QProximityReading *)),
+ this,SLOT(proximityChanged(QProximityReading *)));
connect(QtSensorGestureSensorHandler::instance(),SIGNAL(orientationReadingChanged(QOrientationReading *)),
this,SLOT(orientationReadingChanged(QOrientationReading *)));
} else {
- QtSensorGestureSensorHandler::instance()->stopSensor(QtSensorGestureSensorHandler::IrProximity);
+ QtSensorGestureSensorHandler::instance()->stopSensor(QtSensorGestureSensorHandler::Proximity);
active = false;
}
} else {
@@ -89,13 +89,13 @@ bool QCoverSensorGestureRecognizer::start()
bool QCoverSensorGestureRecognizer::stop()
{
- QtSensorGestureSensorHandler::instance()->stopSensor(QtSensorGestureSensorHandler::IrProximity);
+ QtSensorGestureSensorHandler::instance()->stopSensor(QtSensorGestureSensorHandler::Proximity);
QtSensorGestureSensorHandler::instance()->stopSensor(QtSensorGestureSensorHandler::Orientation);
- disconnect(QtSensorGestureSensorHandler::instance(),SIGNAL(irProximityReadingChanged(QIRProximityReading *)),
- this,SLOT(proximityChanged(QIRProximityReading *)));
+ disconnect(QtSensorGestureSensorHandler::instance(),SIGNAL(proximityReadingChanged(QProximityReading *)),
+ this,SLOT(proximityChanged(QProximityReading *)));
disconnect(QtSensorGestureSensorHandler::instance(),SIGNAL(orientationReadingChanged(QOrientationReading *)),
- this,SLOT(orientationReadingChanged(QOrientationReading *)));
+ this,SLOT(orientationReadingChanged(QOrientationReading *)));
active = false;
@@ -107,32 +107,22 @@ bool QCoverSensorGestureRecognizer::isActive()
return active;
}
-void QCoverSensorGestureRecognizer::proximityChanged(QIRProximityReading *reading)
+void QCoverSensorGestureRecognizer::proximityChanged(QProximityReading *reading)
{
if (orientationReading == 0)
return;
- proximityReading = reading->reflectance();
- const qreal difference = lastProx - proximityReading;
+ proximityReading = reading->close();
- if (qAbs(difference) < .15) {
- return;
- }
// look at case of face up->face down->face up.
if (orientationReading->orientation() == QOrientationReading::FaceUp
- && proximityReading > .55) {
+ && proximityReading) {
if (!timer->isActive()) {
timer->start();
detecting = true;
}
}
- if (proximityReading < .55) {
- if (timer->isActive()) {
- timer->stop();
- detecting = false;
- }
- }
- lastProx = proximityReading;
+ lastTs = reading->timestamp();
}
void QCoverSensorGestureRecognizer::orientationReadingChanged(QOrientationReading *reading)
@@ -143,12 +133,11 @@ void QCoverSensorGestureRecognizer::orientationReadingChanged(QOrientationReadin
void QCoverSensorGestureRecognizer::timeout()
{
if ((orientationReading->orientation() == QOrientationReading::FaceUp)
- && proximityReading > 0.55) {
+ && proximityReading) {
Q_EMIT cover();
Q_EMIT detected("cover");
detecting = false;
}
- lastProx = proximityReading;
}
QT_END_NAMESPACE