summaryrefslogtreecommitdiffstats
path: root/src/plugins/sensorgestures
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/sensorgestures')
-rw-r--r--src/plugins/sensorgestures/qtsensors/qcoversensorgesturerecognizer.cpp115
-rw-r--r--src/plugins/sensorgestures/qtsensors/qcoversensorgesturerecognizer.h85
-rw-r--r--src/plugins/sensorgestures/qtsensors/qdoubletapsensorgesturerecognizer.cpp96
-rw-r--r--src/plugins/sensorgestures/qtsensors/qdoubletapsensorgesturerecognizer.h76
-rw-r--r--src/plugins/sensorgestures/qtsensors/qhoversensorgesturerecognizer.cpp132
-rw-r--r--src/plugins/sensorgestures/qtsensors/qhoversensorgesturerecognizer.h83
-rw-r--r--src/plugins/sensorgestures/qtsensors/qpickupsensorgesturerecognizer.cpp140
-rw-r--r--src/plugins/sensorgestures/qtsensors/qpickupsensorgesturerecognizer.h87
-rw-r--r--src/plugins/sensorgestures/qtsensors/qshake2recognizer.cpp205
-rw-r--r--src/plugins/sensorgestures/qtsensors/qshake2recognizer.h116
-rw-r--r--src/plugins/sensorgestures/qtsensors/qtsensorgestureplugin.cpp165
-rw-r--r--src/plugins/sensorgestures/qtsensors/qtsensorgestureplugin.h66
-rw-r--r--src/plugins/sensorgestures/qtsensors/qtsensors.pro32
-rw-r--r--src/plugins/sensorgestures/qtsensors/qturnoversensorgesturerecognizer.cpp130
-rw-r--r--src/plugins/sensorgestures/qtsensors/qturnoversensorgesturerecognizer.h83
-rw-r--r--src/plugins/sensorgestures/qtsensors/qtwistsensorgesturerecognizer.cpp178
-rw-r--r--src/plugins/sensorgestures/qtsensors/qtwistsensorgesturerecognizer.h87
-rw-r--r--src/plugins/sensorgestures/qtsensors/qwhipsensorgesturerecognizer.cpp139
-rw-r--r--src/plugins/sensorgestures/qtsensors/qwhipsensorgesturerecognizer.h81
-rw-r--r--src/plugins/sensorgestures/sensorgestures.pro2
-rw-r--r--src/plugins/sensorgestures/shake/qshakesensorgestureplugin.cpp3
21 files changed, 2098 insertions, 3 deletions
diff --git a/src/plugins/sensorgestures/qtsensors/qcoversensorgesturerecognizer.cpp b/src/plugins/sensorgestures/qtsensors/qcoversensorgesturerecognizer.cpp
new file mode 100644
index 00000000..db6a92e5
--- /dev/null
+++ b/src/plugins/sensorgestures/qtsensors/qcoversensorgesturerecognizer.cpp
@@ -0,0 +1,115 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtSensors module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+#include "qcoversensorgesturerecognizer.h"
+QT_BEGIN_NAMESPACE
+
+QCoverSensorGestureRecognizer::QCoverSensorGestureRecognizer(QObject *parent) :
+ QSensorGestureRecognizer(parent),
+ lastProx(0)
+{
+}
+
+QCoverSensorGestureRecognizer::~QCoverSensorGestureRecognizer()
+{
+}
+
+void QCoverSensorGestureRecognizer::create()
+{
+ proximity = new QProximitySensor(this);
+ proximity->connectToBackend();
+
+ orientation = new QOrientationSensor(this);
+ orientation->connectToBackend();
+
+ timer = new QTimer(this);
+ connect(timer,SIGNAL(timeout()),this,SLOT(timeout()));
+ timer->setSingleShot(true);
+ timer->setInterval(1000);
+}
+
+QString QCoverSensorGestureRecognizer::id() const
+{
+ return QString("QtSensors.cover");
+}
+
+bool QCoverSensorGestureRecognizer::start()
+{
+ connect(proximity,SIGNAL(readingChanged()),this,SLOT(proximityChanged()));
+ proximity->start();
+ orientation->start();
+ return proximity->isActive();
+}
+
+bool QCoverSensorGestureRecognizer::stop()
+{
+ proximity->stop();
+ orientation->stop();
+ disconnect(proximity,SIGNAL(readingChanged()),this,SLOT(proximityChanged()));
+ return proximity->isActive();
+}
+
+bool QCoverSensorGestureRecognizer::isActive()
+{
+ return proximity->isActive();
+}
+
+void QCoverSensorGestureRecognizer::proximityChanged()
+{
+ if ((orientation->reading()->orientation() == QOrientationReading::FaceDown
+ || orientation->reading()->orientation() == QOrientationReading::FaceUp)
+ && proximity->reading()->close())
+ timer->start();
+}
+
+void QCoverSensorGestureRecognizer::timeout()
+{
+
+ if ((orientation->reading()->orientation() == QOrientationReading::FaceUp)
+ && proximity->reading()->close()) {
+ Q_EMIT cover();
+ Q_EMIT detected("cover");
+ }
+ lastProx = proximity->reading()->close();
+}
+
+QT_END_NAMESPACE
diff --git a/src/plugins/sensorgestures/qtsensors/qcoversensorgesturerecognizer.h b/src/plugins/sensorgestures/qtsensors/qcoversensorgesturerecognizer.h
new file mode 100644
index 00000000..ee761b48
--- /dev/null
+++ b/src/plugins/sensorgestures/qtsensors/qcoversensorgesturerecognizer.h
@@ -0,0 +1,85 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtSensors module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+#ifndef QCOVERSENSORGESTURERECOGNIZER_H
+#define QCOVERSENSORGESTURERECOGNIZER_H
+
+#include <QtSensors/QSensor>
+#include <QProximitySensor>
+#include <QtSensors/QOrientationSensor>
+
+#include <qsensorgesturerecognizer.h>
+#include <QTimer>
+QT_BEGIN_NAMESPACE
+
+class QCoverSensorGestureRecognizer : public QSensorGestureRecognizer
+{
+ Q_OBJECT
+public:
+ explicit QCoverSensorGestureRecognizer(QObject *parent = 0);
+ ~QCoverSensorGestureRecognizer();
+
+ void create();
+
+ QString id() const;
+ bool start();
+ bool stop();
+ bool isActive();
+
+Q_SIGNALS:
+ void cover();
+
+private slots:
+ void proximityChanged();
+ void timeout();
+
+
+private:
+ QProximitySensor *proximity;
+ QOrientationSensor *orientation;
+
+ QTimer *timer;
+ bool lastProx;
+
+};
+QT_END_NAMESPACE
+#endif // QCOVERSENSORGESTURERECOGNIZER_H
diff --git a/src/plugins/sensorgestures/qtsensors/qdoubletapsensorgesturerecognizer.cpp b/src/plugins/sensorgestures/qtsensors/qdoubletapsensorgesturerecognizer.cpp
new file mode 100644
index 00000000..e732c850
--- /dev/null
+++ b/src/plugins/sensorgestures/qtsensors/qdoubletapsensorgesturerecognizer.cpp
@@ -0,0 +1,96 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtSensors module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QTapSensor>
+#include "qdoubletapsensorgesturerecognizer.h"
+QT_BEGIN_NAMESPACE
+
+QDoubleTapSensorGestureRecognizer::QDoubleTapSensorGestureRecognizer(QObject *parent) :
+ QSensorGestureRecognizer(parent)
+{
+}
+
+QDoubleTapSensorGestureRecognizer::~QDoubleTapSensorGestureRecognizer()
+{
+}
+
+void QDoubleTapSensorGestureRecognizer::create()
+{
+ tapSensor = new QTapSensor(this);
+ tapSensor->connectToBackend();
+}
+
+
+QString QDoubleTapSensorGestureRecognizer::id() const
+{
+ return QString("QtSensors.doubletap");
+}
+
+bool QDoubleTapSensorGestureRecognizer::start()
+{
+ connect(tapSensor,SIGNAL(readingChanged()),this,SLOT(tapChanged()));
+ tapSensor->start();
+ return isActive();
+}
+
+bool QDoubleTapSensorGestureRecognizer::stop()
+{
+ tapSensor->stop();
+ disconnect(tapSensor,SIGNAL(readingChanged()),this,SLOT(tapChanged()));
+ return isActive();
+}
+
+bool QDoubleTapSensorGestureRecognizer::isActive()
+{
+ return tapSensor->isActive();
+}
+
+void QDoubleTapSensorGestureRecognizer::tapChanged()
+{
+ QTapReading *reading = tapSensor->reading();
+ if (reading->isDoubleTap()) {
+ Q_EMIT doubletap();
+ Q_EMIT detected("doubletap");
+ }
+}
+
+
+QT_END_NAMESPACE
diff --git a/src/plugins/sensorgestures/qtsensors/qdoubletapsensorgesturerecognizer.h b/src/plugins/sensorgestures/qtsensors/qdoubletapsensorgesturerecognizer.h
new file mode 100644
index 00000000..7b2fec49
--- /dev/null
+++ b/src/plugins/sensorgestures/qtsensors/qdoubletapsensorgesturerecognizer.h
@@ -0,0 +1,76 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtSensors module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QDOUBLETAPSENSORGESTURERECOGNIZER_H
+#define QDOUBLETAPSENSORGESTURERECOGNIZER_H
+
+#include <QtSensors/QSensor>
+
+#include <qsensorgesturerecognizer.h>
+#include <QTapSensor>
+QT_BEGIN_NAMESPACE
+
+class QDoubleTapSensorGestureRecognizer : public QSensorGestureRecognizer
+{
+ Q_OBJECT
+public:
+ explicit QDoubleTapSensorGestureRecognizer(QObject *parent = 0);
+ ~QDoubleTapSensorGestureRecognizer();
+
+ void create();
+
+ QString id() const;
+ bool start();
+ bool stop();
+ bool isActive();
+
+Q_SIGNALS:
+ void doubletap();
+
+private slots:
+ void tapChanged();
+
+private:
+ QTapSensor *tapSensor;
+
+};
+QT_END_NAMESPACE
+#endif // QDOUBLETAPSENSORGESTURERECOGNIZER_H
diff --git a/src/plugins/sensorgestures/qtsensors/qhoversensorgesturerecognizer.cpp b/src/plugins/sensorgestures/qtsensors/qhoversensorgesturerecognizer.cpp
new file mode 100644
index 00000000..a76c2c94
--- /dev/null
+++ b/src/plugins/sensorgestures/qtsensors/qhoversensorgesturerecognizer.cpp
@@ -0,0 +1,132 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtSensors module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+#include "qhoversensorgesturerecognizer.h"
+QT_BEGIN_NAMESPACE
+
+QHoverSensorGestureRecognizer::QHoverSensorGestureRecognizer(QObject *parent) :
+ QSensorGestureRecognizer(parent),
+ hoverOk(0), lastLightReading(0), detecting(0)
+{
+}
+
+QHoverSensorGestureRecognizer::~QHoverSensorGestureRecognizer()
+{
+}
+
+void QHoverSensorGestureRecognizer::create()
+{
+ light = new QLightSensor(this);
+ light->connectToBackend();
+
+ timer = new QTimer(this);
+ connect(timer,SIGNAL(timeout()),this,SLOT(timeout()));
+ timer->setSingleShot(true);
+ timer->setInterval(1000);
+
+ timer2 = new QTimer(this);
+ connect(timer2,SIGNAL(timeout()),this,SLOT(timeout2()));
+ timer2->setSingleShot(true);
+ timer2->setInterval(3000);
+}
+
+QString QHoverSensorGestureRecognizer::id() const
+{
+ return QString("QtSensors.hover");
+}
+
+bool QHoverSensorGestureRecognizer::start()
+{
+ connect(light,SIGNAL(readingChanged()), this,SLOT(lightChanged()));
+ light->start();
+ return light->isActive();
+}
+
+bool QHoverSensorGestureRecognizer::stop()
+{
+ light->stop();
+ disconnect(light,SIGNAL(readingChanged()),this,SLOT(lightChanged()));
+ return light->isActive();
+}
+
+bool QHoverSensorGestureRecognizer::isActive()
+{
+ return light->isActive();
+}
+
+void QHoverSensorGestureRecognizer::lightChanged()
+{
+ qreal lightReading = light->reading()->lux();
+
+ int difference = 100 - (lightReading/lastLightReading) * 100;
+
+ if (difference == 0) {
+ return;
+ }
+
+ if (!detecting && difference > 19) {
+// if (lightReading < lastLightReading ) {
+ detecting = true;
+ timer->start();
+ timer2->start();
+ } else if (hoverOk && detecting && difference < -24) {
+ // went light again after 1 seconds
+// qDebug() << "hover";
+ Q_EMIT hover();
+ Q_EMIT detected("hover");
+ hoverOk = false;
+ detecting = false;
+ }
+ lastLightReading = lightReading;
+}
+
+void QHoverSensorGestureRecognizer::timeout()
+{
+ hoverOk = true;
+}
+
+
+void QHoverSensorGestureRecognizer::timeout2()
+{
+ detecting = false;
+}
+QT_END_NAMESPACE
diff --git a/src/plugins/sensorgestures/qtsensors/qhoversensorgesturerecognizer.h b/src/plugins/sensorgestures/qtsensors/qhoversensorgesturerecognizer.h
new file mode 100644
index 00000000..de680fcb
--- /dev/null
+++ b/src/plugins/sensorgestures/qtsensors/qhoversensorgesturerecognizer.h
@@ -0,0 +1,83 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtSensors module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+#ifndef QHOVERSENSORGESTURERECOGNIZER_H
+#define QHOVERSENSORGESTURERECOGNIZER_H
+
+#include <QSensorGestureRecognizer>
+#include <QtSensors/QSensor>
+#include <QTimer>
+#include <QLightSensor>
+QT_BEGIN_NAMESPACE
+
+class QHoverSensorGestureRecognizer : public QSensorGestureRecognizer
+{
+ Q_OBJECT
+public:
+ explicit QHoverSensorGestureRecognizer(QObject *parent = 0);
+ ~QHoverSensorGestureRecognizer();
+
+ void create();
+
+ QString id() const;
+ bool start();
+ bool stop();
+ bool isActive();
+
+Q_SIGNALS:
+ void hover();
+
+private slots:
+ void lightChanged();
+ void timeout();
+ void timeout2();
+private:
+ QLightSensor *light;
+ QTimer *timer;
+ QTimer *timer2;
+ bool hoverOk;
+ qreal lastLightReading;
+ bool detecting;
+
+};
+QT_END_NAMESPACE
+#endif // QHOVERSENSORGESTURERECOGNIZER_H
diff --git a/src/plugins/sensorgestures/qtsensors/qpickupsensorgesturerecognizer.cpp b/src/plugins/sensorgestures/qtsensors/qpickupsensorgesturerecognizer.cpp
new file mode 100644
index 00000000..98cf943f
--- /dev/null
+++ b/src/plugins/sensorgestures/qtsensors/qpickupsensorgesturerecognizer.cpp
@@ -0,0 +1,140 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtSensors module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+#include "qpickupsensorgesturerecognizer.h"
+QT_BEGIN_NAMESPACE
+
+QPickupSensorGestureRecognizer::QPickupSensorGestureRecognizer(QObject *parent) :
+ QSensorGestureRecognizer(parent),atRest(1),okToSignal(1)
+{
+}
+
+QPickupSensorGestureRecognizer::~QPickupSensorGestureRecognizer()
+{
+}
+
+void QPickupSensorGestureRecognizer::create()
+{
+ accel = new QAccelerometer(this);
+ accel->connectToBackend();
+ timer = new QTimer(this);
+
+ connect(timer,SIGNAL(timeout()),this,SLOT(timeout()));
+ timer->setSingleShot(true);
+ timer->setInterval(500);
+
+}
+
+QString QPickupSensorGestureRecognizer::id() const
+{
+ return QString("QtSensors.pickup");
+}
+
+bool QPickupSensorGestureRecognizer::start()
+{
+ connect(accel,SIGNAL(readingChanged()),this,SLOT(accelChanged()));
+ accel->start();
+
+ active = accel->isActive();
+ return active;
+}
+
+bool QPickupSensorGestureRecognizer::stop()
+{
+ accel->stop();
+ active = accel->isActive();
+ disconnect(accel,SIGNAL(readingChanged()),this,SLOT(accelChanged()));
+ return !active;
+}
+
+bool QPickupSensorGestureRecognizer::isActive()
+{
+ return active;
+}
+
+#define kFilteringFactor 0.1
+
+void QPickupSensorGestureRecognizer::accelChanged()
+{
+ qreal x = accel->reading()->x();
+ qreal xdiff = pXaxis - x;
+ qreal y = accel->reading()->y();
+ qreal ydiff = pYaxis - y;
+ qreal z = accel->reading()->z();
+ qreal zdiff = pZaxis - z;
+
+ if (xdiff < 0.3 && ydiff < .3 && zdiff < .3) {
+ atRest = true;
+ } else {
+ atRest = false;
+ okToSignal = true;
+ }
+
+ if (atRest && okToSignal && (y > 5.0 && y < 8.9) && (z > 5.0 && z < 7.9)) {
+ if (!timer->isActive()) {
+ timer->start();
+ }
+ }
+
+ // initial at ~0, z = 9.8
+ // at 'focus' when y == 6 to 8 && z == 5 to 7
+
+ pXaxis = x;
+ pYaxis = y;
+ pZaxis = z;
+}
+
+void QPickupSensorGestureRecognizer::timeout()
+{
+ qreal x = accel->reading()->x();
+ qreal y = accel->reading()->y();
+ qreal z = accel->reading()->z();
+
+ if (atRest && (y > 5.0 && y < 8.9) && (z > 5.0 && z < 7.9)) {
+ Q_EMIT pickup();
+ Q_EMIT detected("pickup");
+
+ okToSignal = false;
+ }
+}
+
+QT_END_NAMESPACE
diff --git a/src/plugins/sensorgestures/qtsensors/qpickupsensorgesturerecognizer.h b/src/plugins/sensorgestures/qtsensors/qpickupsensorgesturerecognizer.h
new file mode 100644
index 00000000..805c6fa8
--- /dev/null
+++ b/src/plugins/sensorgestures/qtsensors/qpickupsensorgesturerecognizer.h
@@ -0,0 +1,87 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtSensors module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+#ifndef QPICKUPSENSORGESTURERECOGNIZER_H
+#define QPICKUPSENSORGESTURERECOGNIZER_H
+
+#include <qsensorgesturerecognizer.h>
+#include <QtSensors/QSensor>
+#include <QtSensors/QAccelerometer>
+#include <QTimer>
+QT_BEGIN_NAMESPACE
+
+class QPickupSensorGestureRecognizer : public QSensorGestureRecognizer
+{
+ Q_OBJECT
+public:
+ explicit QPickupSensorGestureRecognizer(QObject *parent = 0);
+ ~QPickupSensorGestureRecognizer();
+
+ void create();
+
+ QString id() const;
+ bool start();
+ bool stop();
+ bool isActive();
+
+Q_SIGNALS:
+ void pickup();
+
+
+private slots:
+ void accelChanged();
+ void timeout();
+private:
+ QAccelerometer *accel;
+
+ QTimer *timer;
+ bool active;
+ bool atRest;
+ bool okToSignal;
+
+ qreal pXaxis;
+ qreal pYaxis;
+ qreal pZaxis;
+
+};
+QT_END_NAMESPACE
+#endif // QPICKUPSENSORGESTURERECOGNIZER_H
diff --git a/src/plugins/sensorgestures/qtsensors/qshake2recognizer.cpp b/src/plugins/sensorgestures/qtsensors/qshake2recognizer.cpp
new file mode 100644
index 00000000..4c491fb8
--- /dev/null
+++ b/src/plugins/sensorgestures/qtsensors/qshake2recognizer.cpp
@@ -0,0 +1,205 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtSensors module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QDebug>
+#include <QTimer>
+
+#include "qshake2recognizer.h"
+
+QT_BEGIN_NAMESPACE
+
+QShake2SensorGestureRecognizer::QShake2SensorGestureRecognizer(QObject *parent)
+ : QSensorGestureRecognizer(parent)
+ , active(0)
+{
+ pXaxis = 0;nXaxis = 0;
+ pYaxis = 0;nYaxis = 0;
+ pZaxis = 0;nZaxis = 0;
+ timerTimeout = 750;
+}
+
+QShake2SensorGestureRecognizer::~QShake2SensorGestureRecognizer()
+{
+}
+
+void QShake2SensorGestureRecognizer::create()
+{
+ accel = new QAccelerometer(this);
+ accel->connectToBackend();
+ timer = new QTimer(this);
+
+ qoutputrangelist outputranges = accel->outputRanges();
+
+ if (outputranges.count() > 0)
+ accelRange = (int)(outputranges.at(0).maximum *2) / 9.8; //approx range in g's
+ else
+ accelRange = 4; //this should never happen
+
+ connect(timer,SIGNAL(timeout()),this,SLOT(timeout()));
+ timer->setSingleShot(true);
+ timer->setInterval(timerTimeout);
+
+
+}
+
+bool QShake2SensorGestureRecognizer::start()
+{
+ connect(accel,SIGNAL(readingChanged()),this,SLOT(accelChanged()));
+ active = accel->start();
+
+ return active;
+}
+
+bool QShake2SensorGestureRecognizer::stop()
+{
+ accel->stop();
+ active = accel->isActive();
+ disconnect(accel,SIGNAL(readingChanged()),this,SLOT(accelChanged()));
+ return !active;
+}
+
+bool QShake2SensorGestureRecognizer::isActive()
+{
+ return active;
+}
+
+QString QShake2SensorGestureRecognizer::id() const
+{
+ return QString("QtSensors.shake2");
+}
+
+#define NUMBER_SHAKES 3
+void QShake2SensorGestureRecognizer::accelChanged()
+{
+ qreal x = accel->reading()->x();
+ qreal xdiff = pXaxis - x;
+ qreal y = accel->reading()->y();
+ qreal ydiff = pYaxis - y;
+ qreal z = accel->reading()->z();
+ qreal zdiff = pZaxis - z;
+
+ if (abs(xdiff) > (5 * accelRange)) {
+
+ if (shakeDirection == QShake2SensorGestureRecognizer::ShakeUndefined && nXaxis == 0) {
+ if (xdiff < 0)
+ shakeDirection = QShake2SensorGestureRecognizer::ShakeLeft;
+ else
+ shakeDirection = QShake2SensorGestureRecognizer::ShakeRight;
+ }
+
+ nXaxis++;
+ if (timer->isActive()) {
+ timer->stop();
+ }
+ timer->start();
+ }
+ if (abs(ydiff) > (5 * accelRange)) {
+ if (nYaxis == 0) {
+ if (shakeDirection == QShake2SensorGestureRecognizer::ShakeUndefined && ydiff < 0)
+ shakeDirection = QShake2SensorGestureRecognizer::ShakeDown;
+ else
+ shakeDirection = QShake2SensorGestureRecognizer::ShakeUp;
+ }
+ nYaxis++;
+ if (timer->isActive()) {
+ timer->stop();
+ }
+ timer->start();
+ }
+ if (abs(zdiff) > (5 * accelRange)) {
+ nZaxis++;
+ if (timer->isActive()) {
+ timer->stop();
+ }
+ timer->start();
+ }
+
+ if (nYaxis + nZaxis + nXaxis >= NUMBER_SHAKES) {
+
+ switch (shakeDirection) {
+ case QShake2SensorGestureRecognizer::ShakeLeft:
+ Q_EMIT shakeLeft();
+ Q_EMIT detected("shakeLeft");
+ break;
+ case QShake2SensorGestureRecognizer::ShakeRight:
+ Q_EMIT shakeRight();
+ Q_EMIT detected("shakeRight");
+ break;
+ case QShake2SensorGestureRecognizer::ShakeUp:
+ Q_EMIT shakeUp();
+ Q_EMIT detected("shakeUp");
+ break;
+ case QShake2SensorGestureRecognizer::ShakeDown:
+ Q_EMIT shakeDown();
+ Q_EMIT detected("shakeDown");
+ break;
+
+ };
+ if (timer->isActive()) {
+ timer->stop();
+ }
+ timeout();
+ }
+ pXaxis = x;
+ pYaxis = y;
+ pZaxis = z;
+}
+
+void QShake2SensorGestureRecognizer::timeout()
+{
+ nXaxis = 0;
+ nYaxis = 0;
+ nZaxis = 0;
+ shakeDirection = QShake2SensorGestureRecognizer::ShakeUndefined;
+
+}
+
+int QShake2SensorGestureRecognizer::thresholdTime() const
+{
+ return timerTimeout;
+}
+
+void QShake2SensorGestureRecognizer::setThresholdTime(int msec)
+{
+ timer->setInterval(msec);
+}
+
+QT_END_NAMESPACE
diff --git a/src/plugins/sensorgestures/qtsensors/qshake2recognizer.h b/src/plugins/sensorgestures/qtsensors/qshake2recognizer.h
new file mode 100644
index 00000000..1a6ba1cd
--- /dev/null
+++ b/src/plugins/sensorgestures/qtsensors/qshake2recognizer.h
@@ -0,0 +1,116 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtSensors module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QSHAKERECOGNIZER_H
+#define QSHAKERECOGNIZER_H
+
+
+#include <QtSensors/QSensor>
+#include <QtSensors/QAccelerometer>
+#include <QtSensors/QAccelerometerFilter>
+
+#include <QDebug>
+#include <QTimer>
+
+#include <qsensorgesturerecognizer.h>
+QT_BEGIN_NAMESPACE
+
+class QShake2SensorGestureRecognizer : public QSensorGestureRecognizer
+{
+ Q_OBJECT
+
+public:
+
+ enum ShakeDirection {
+ ShakeUndefined = 0,
+ ShakeLeft,
+ ShakeRight,
+ ShakeUp,
+ ShakeDown
+ };
+
+ QShake2SensorGestureRecognizer(QObject *parent = 0);
+ ~QShake2SensorGestureRecognizer();
+
+ void create();
+
+ QString id() const;
+ bool start();
+ bool stop();
+ bool isActive();
+
+ int thresholdTime() const;
+ void setThresholdTime(int msec);
+
+Q_SIGNALS:
+ void shakeLeft();
+ void shakeRight();
+ void shakeUp();
+ void shakeDown();
+
+private slots:
+ void accelChanged();
+ void timeout();
+
+private:
+ QAccelerometer *accel;
+
+ qreal pXaxis;
+ qreal nXaxis;
+
+ qreal pYaxis;
+ qreal nYaxis;
+
+ qreal pZaxis;
+ qreal nZaxis;
+
+ bool detectingState;
+ QTimer *timer;
+ int timerTimeout;
+ bool active;
+ int accelRange;
+
+ ShakeDirection shakeDirection;
+
+
+};
+QT_END_NAMESPACE
+#endif // QSHAKERECOGNIZER_H
diff --git a/src/plugins/sensorgestures/qtsensors/qtsensorgestureplugin.cpp b/src/plugins/sensorgestures/qtsensors/qtsensorgestureplugin.cpp
new file mode 100644
index 00000000..b28af13c
--- /dev/null
+++ b/src/plugins/sensorgestures/qtsensors/qtsensorgestureplugin.cpp
@@ -0,0 +1,165 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtSensors module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtPlugin>
+#include <QStringList>
+#include <QObject>
+#include <QFile>
+#include <QDateTime>
+#include "qtsensorgestureplugin.h"
+
+#include <qsensorgestureplugininterface.h>
+
+#include "qcoversensorgesturerecognizer.h"
+#include "qtwistsensorgesturerecognizer.h"
+#include "qdoubletapsensorgesturerecognizer.h"
+#include "qhoversensorgesturerecognizer.h"
+#include "qpickupsensorgesturerecognizer.h"
+#include "qshake2recognizer.h"
+#include "qturnoversensorgesturerecognizer.h"
+#include "qwhipsensorgesturerecognizer.h"
+
+
+QT_BEGIN_NAMESPACE
+
+QTextStream *out = 0;
+void logOutput(QtMsgType type, const char *msg)
+{
+ if (QString(msg).contains("setWindowProperty") ||
+ QString(msg).contains("getSurface"))
+ return;
+
+ QString debugdate = QDateTime::currentDateTime().toString("yyyy.MM.dd hh:mm:ss");
+ switch (type)
+ {
+ case QtDebugMsg:
+ debugdate += "[D]";
+ break;
+ case QtWarningMsg:
+ debugdate += "[W]";
+ break;
+ case QtCriticalMsg:
+ debugdate += "[C]";
+ break;
+ case QtFatalMsg:
+ debugdate += "[F]";
+ }
+ (*out) << debugdate << " " << msg << endl;
+
+ if (QtFatalMsg == type)
+ {
+ abort();
+ }
+}
+
+
+QtSensorGesturePlugin::QtSensorGesturePlugin()
+{
+ QString fileName = "/tmp/log";
+ QFile *log = new QFile(fileName);
+ if (log->open(QIODevice::WriteOnly | QIODevice::Append | QIODevice::Text)) {
+ out = new QTextStream(log);
+ qInstallMsgHandler(logOutput);
+ } else {
+ qDebug() << "Error opening log file '" << fileName << "'. All debug output redirected to console.";
+ }
+
+ qDebug() << Q_FUNC_INFO;
+}
+
+QtSensorGesturePlugin::~QtSensorGesturePlugin()
+{
+}
+
+QStringList QtSensorGesturePlugin::supportedIds() const
+{
+ qDebug() << Q_FUNC_INFO;
+
+ QStringList list;
+ list << "QtSensors.cover";
+ list << "QtSensors.doubletap";
+ list << "QtSensors.hover";
+ list << "QtSensors.pickup";
+ list << "QtSensors.shake2";
+ list << "QtSensors.turnover";
+ list << "QtSensors.twist";
+ list << "QtSensors.whip";
+ return list;
+}
+
+QList <QSensorGestureRecognizer *> QtSensorGesturePlugin::createRecognizers()
+{
+ qDebug() << Q_FUNC_INFO;
+ QList <QSensorGestureRecognizer *> recognizers;
+
+// QSensorGestureRecognizer *sRec1 = new QCirclesSensorGestureRecognizer(this);
+// recognizers.append(sRec1);
+
+ QSensorGestureRecognizer *sRec2 = new QCoverSensorGestureRecognizer(this);
+ recognizers.append(sRec2);
+
+ QSensorGestureRecognizer *sRec3 = new QDoubleTapSensorGestureRecognizer(this);
+ recognizers.append(sRec3);
+
+ QSensorGestureRecognizer *sRec4 = new QHoverSensorGestureRecognizer(this);
+ recognizers.append(sRec4);
+
+ QSensorGestureRecognizer *sRec5 = new QPickupSensorGestureRecognizer(this);
+ recognizers.append(sRec5);
+
+ QSensorGestureRecognizer *sRec6 = new QShake2SensorGestureRecognizer(this);
+ recognizers.append(sRec6);
+
+ QSensorGestureRecognizer *sRec7 = new QTurnoverSensorGestureRecognizer(this);
+ recognizers.append(sRec7);
+
+ QSensorGestureRecognizer *sRec8 = new QWhipSensorGestureRecognizer(this);
+ recognizers.append(sRec8);
+
+ QSensorGestureRecognizer *sRec9 = new QTwistSensorGestureRecognizer(this);
+ recognizers.append(sRec9);
+
+ return recognizers;
+}
+
+Q_EXPORT_PLUGIN2(qtsensorgestures_plugin, QtSensorGesturePlugin)
+
+QT_END_NAMESPACE
diff --git a/src/plugins/sensorgestures/qtsensors/qtsensorgestureplugin.h b/src/plugins/sensorgestures/qtsensors/qtsensorgestureplugin.h
new file mode 100644
index 00000000..412ff7dd
--- /dev/null
+++ b/src/plugins/sensorgestures/qtsensors/qtsensorgestureplugin.h
@@ -0,0 +1,66 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtSensors module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QTSENSORGESTURESPLUGIN_H
+#define QTSENSORGESTURESPLUGIN_H
+
+#include <QObject>
+#include <QStringList>
+
+#include <qsensorgestureplugininterface.h>
+QT_BEGIN_NAMESPACE
+
+class QtSensorGesturePlugin : public QObject, public QSensorGesturePluginInterface
+{
+ Q_OBJECT
+ Q_INTERFACES(QSensorGesturePluginInterface:QFactoryInterface)
+
+public:
+ explicit QtSensorGesturePlugin();
+ ~QtSensorGesturePlugin();
+ QList <QSensorGestureRecognizer *> createRecognizers();
+
+ QStringList gestureSignals() const;
+ QStringList supportedIds() const;
+ QString name() const { return "QtSensorGestures"; }
+};
+QT_END_NAMESPACE
+#endif // QTSENSORGESTURESPLUGIN_H
diff --git a/src/plugins/sensorgestures/qtsensors/qtsensors.pro b/src/plugins/sensorgestures/qtsensors/qtsensors.pro
new file mode 100644
index 00000000..01fef4d2
--- /dev/null
+++ b/src/plugins/sensorgestures/qtsensors/qtsensors.pro
@@ -0,0 +1,32 @@
+TEMPLATE = lib
+CONFIG += plugin
+
+TARGET = qtsensorgestures_plugin
+
+QT += sensors
+DESTDIR = $$QT.sensors.plugins/sensorgestures
+
+# Input
+HEADERS += qtsensorgestureplugin.h \
+ qcoversensorgesturerecognizer.h \
+ qdoubletapsensorgesturerecognizer.h \
+ qhoversensorgesturerecognizer.h \
+ qpickupsensorgesturerecognizer.h \
+ qshake2recognizer.h \
+ qturnoversensorgesturerecognizer.h \
+ qtwistsensorgesturerecognizer.h \
+ qwhipsensorgesturerecognizer.h
+
+SOURCES += qtsensorgestureplugin.cpp \
+ qcoversensorgesturerecognizer.cpp \
+ qdoubletapsensorgesturerecognizer.cpp \
+ qhoversensorgesturerecognizer.cpp \
+ qpickupsensorgesturerecognizer.cpp \
+ qshake2recognizer.cpp \
+ qturnoversensorgesturerecognizer.cpp \
+ qtwistsensorgesturerecognizer.cpp \
+ qwhipsensorgesturerecognizer.cpp
+
+target.path += $$[QT_INSTALL_PLUGINS]/sensorgestures
+INSTALLS += target
+
diff --git a/src/plugins/sensorgestures/qtsensors/qturnoversensorgesturerecognizer.cpp b/src/plugins/sensorgestures/qtsensors/qturnoversensorgesturerecognizer.cpp
new file mode 100644
index 00000000..a7d9310a
--- /dev/null
+++ b/src/plugins/sensorgestures/qtsensors/qturnoversensorgesturerecognizer.cpp
@@ -0,0 +1,130 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtSensors module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtSensors/QSensor>
+
+#include "qturnoversensorgesturerecognizer.h"
+QT_BEGIN_NAMESPACE
+
+// turnover and put down i.e. facedown
+
+QTurnoverSensorGestureRecognizer::QTurnoverSensorGestureRecognizer(QObject *parent) :
+ QSensorGestureRecognizer(parent),
+ isClose(0)
+ , isFaceDown(0)
+{
+}
+
+QTurnoverSensorGestureRecognizer::~QTurnoverSensorGestureRecognizer()
+{
+}
+
+void QTurnoverSensorGestureRecognizer::create()
+{
+ orientation = new QOrientationSensor(this);
+ orientation->connectToBackend();
+ proximity = new QProximitySensor(this);
+ proximity->connectToBackend();
+
+
+}
+
+bool QTurnoverSensorGestureRecognizer::start()
+{
+ connect(orientation,SIGNAL(readingChanged()),this,SLOT(orientationChanged()));
+ connect(proximity,SIGNAL(readingChanged()),this,SLOT(proximityChanged()));
+ active = (orientation->start() && proximity->start());
+ return active;
+}
+
+bool QTurnoverSensorGestureRecognizer::stop()
+{
+ orientation->stop();
+ proximity->stop();
+ active = (orientation->isActive() && proximity->isActive());
+ disconnect(orientation,SIGNAL(readingChanged()),this,SLOT(orientationChanged()));
+ disconnect(proximity,SIGNAL(readingChanged()),this,SLOT(proximityChanged()));
+ return !active;
+}
+
+bool QTurnoverSensorGestureRecognizer::isActive()
+{
+ return active;
+}
+
+QString QTurnoverSensorGestureRecognizer::id() const
+{
+ return QString("QtSensors.turnover");
+}
+
+void QTurnoverSensorGestureRecognizer::proximityChanged()
+{
+ isClose = proximity->reading()->close();
+ isRecognized();
+}
+
+void QTurnoverSensorGestureRecognizer::orientationChanged()
+{
+ switch (orientation->reading()->orientation()) {
+ case QOrientationReading::FaceDown:
+ {
+ isFaceDown = true;
+ isRecognized();
+ }
+ break;
+ default:
+ isFaceDown = false;
+ break;
+ };
+}
+
+void QTurnoverSensorGestureRecognizer::isRecognized()
+{
+ qDebug() << Q_FUNC_INFO
+ << isClose << isFaceDown;
+
+ if (isClose && isFaceDown) {
+ Q_EMIT turnover();
+ Q_EMIT detected("turnover");
+ }
+}
+QT_END_NAMESPACE
+
diff --git a/src/plugins/sensorgestures/qtsensors/qturnoversensorgesturerecognizer.h b/src/plugins/sensorgestures/qtsensors/qturnoversensorgesturerecognizer.h
new file mode 100644
index 00000000..7b1158c6
--- /dev/null
+++ b/src/plugins/sensorgestures/qtsensors/qturnoversensorgesturerecognizer.h
@@ -0,0 +1,83 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtSensors module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QTURNOVERSENSORGESTURERECOGNIZER_H
+#define QTURNOVERSENSORGESTURERECOGNIZER_H
+
+#include <QtSensors/QSensor>
+#include <QtSensors/QOrientationSensor>
+#include <QtSensors/QProximitySensor>
+
+#include <qsensorgesturerecognizer.h>
+QT_BEGIN_NAMESPACE
+
+class QTurnoverSensorGestureRecognizer : public QSensorGestureRecognizer
+{
+ Q_OBJECT
+public:
+ explicit QTurnoverSensorGestureRecognizer(QObject *parent = 0);
+ ~QTurnoverSensorGestureRecognizer();
+ void create();
+ QString id() const;
+ bool start();
+ bool stop();
+ bool isActive();
+
+Q_SIGNALS:
+ void turnover();
+
+private slots:
+ void orientationChanged();
+ void proximityChanged();
+
+private:
+ QOrientationSensor *orientation;
+ QProximitySensor *proximity;
+
+ bool isClose;
+ bool isFaceDown;
+ bool active;
+
+ void isRecognized();
+
+};
+QT_END_NAMESPACE
+#endif // QTURNOVERSENSORGESTURERECOGNIZER_H
diff --git a/src/plugins/sensorgestures/qtsensors/qtwistsensorgesturerecognizer.cpp b/src/plugins/sensorgestures/qtsensors/qtwistsensorgesturerecognizer.cpp
new file mode 100644
index 00000000..e7a656f8
--- /dev/null
+++ b/src/plugins/sensorgestures/qtsensors/qtwistsensorgesturerecognizer.cpp
@@ -0,0 +1,178 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtSensors module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+#include "qtwistsensorgesturerecognizer.h"
+
+#define _USE_MATH_DEFINES
+#include <QtCore/qmath.h>
+#ifndef M_PI
+#define M_PI 3.14159265358979323846264338327950288419717
+#endif
+#ifndef M_PI_2
+#define M_PI_2 1.57079632679489661923
+#endif
+
+QT_BEGIN_NAMESPACE
+
+// from qsensor2tilt
+inline qreal calcPitch(double Ax, double Ay, double Az)
+{
+ return (float)-atan2(Ax, sqrt(Ay * Ay + Az * Az));
+}
+
+inline qreal calcRoll(double Ax, double Ay, double Az)
+{
+ return (float)atan2(Ay, (sqrt(Ax * Ax + Az * Az)));
+}
+
+QTwistSensorGestureRecognizer::QTwistSensorGestureRecognizer(QObject *parent) :
+ QSensorGestureRecognizer(parent), detecting(0)
+{
+}
+
+QTwistSensorGestureRecognizer::~QTwistSensorGestureRecognizer()
+{
+}
+
+void QTwistSensorGestureRecognizer::create()
+{
+ accel = new QAccelerometer(this);
+ accel->connectToBackend();
+ timer = new QTimer(this);
+
+ qoutputrangelist outputranges = accel->outputRanges();
+
+ if (outputranges.count() > 0)
+ accelRange = (int)(outputranges.at(0).maximum *2);
+ else
+ accelRange = 44; //this should never happen
+
+ connect(timer,SIGNAL(timeout()),this,SLOT(timeout()));
+ timer->setSingleShot(true);
+ timer->setInterval(250);
+
+}
+
+QString QTwistSensorGestureRecognizer::id() const
+{
+ return QString("QtSensors.twist");
+}
+
+bool QTwistSensorGestureRecognizer::start()
+{
+ connect(accel,SIGNAL(readingChanged()),this,SLOT(accelChanged()));
+ active = accel->start();
+ return active;
+}
+
+bool QTwistSensorGestureRecognizer::stop()
+{
+ accel->stop();
+ disconnect(accel,SIGNAL(readingChanged()),this,SLOT(accelChanged()));
+
+ active = accel->isActive();
+ return !active;
+}
+
+bool QTwistSensorGestureRecognizer::isActive()
+{
+ return active;
+}
+
+#define RESTING_VARIANCE 10
+
+void QTwistSensorGestureRecognizer::accelChanged()
+{
+ qreal x = accel->reading()->x();
+ qreal y = accel->reading()->y();
+ qreal z = accel->reading()->z();
+
+ pitch = calcPitch(x, y, z);
+ roll = calcRoll(x, y, z);
+
+ qreal degrees = calc(pitch);
+
+ if (xList.count() > 4) {
+
+ if (detecting && abs(degrees) < RESTING_VARIANCE) {
+ if (lastX < 0) {
+ Q_EMIT twistLeft();
+ Q_EMIT detected("twistLeft");
+ } else {
+ Q_EMIT twistRight();
+ Q_EMIT detected("twistRight");
+ }
+ detecting = false;
+ }
+
+ if (abs(degrees) > 60 && abs(xList.last()) < RESTING_VARIANCE) {
+ detecting = true;
+ timer->start();
+ lastX = degrees;
+ }
+ }
+
+ if (xList.count() > 5)
+ xList.removeLast();
+ xList.insert(0,degrees);
+}
+
+void QTwistSensorGestureRecognizer::timeout()
+{
+ detecting = false;
+}
+
+qreal QTwistSensorGestureRecognizer::calc(qreal yrot)
+{
+ qreal aG = 1 * sin(yrot);
+ qreal aK = 1 * cos(yrot);
+
+ yrot = atan2(aG, aK);
+ if (yrot > M_PI_2)
+ yrot = M_PI - yrot;
+ else if (yrot < -M_PI_2)
+ yrot = -(M_PI + yrot);
+
+ return yrot * 180 / M_PI;
+}
+
+QT_END_NAMESPACE
diff --git a/src/plugins/sensorgestures/qtsensors/qtwistsensorgesturerecognizer.h b/src/plugins/sensorgestures/qtsensors/qtwistsensorgesturerecognizer.h
new file mode 100644
index 00000000..df297a99
--- /dev/null
+++ b/src/plugins/sensorgestures/qtsensors/qtwistsensorgesturerecognizer.h
@@ -0,0 +1,87 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtSensors module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+#ifndef QWFLICKSENSORGESTURERECOGNIZER_H
+#define QWFLICKSENSORGESTURERECOGNIZER_H
+
+#include <qsensorgesturerecognizer.h>
+#include <QtSensors/QAccelerometer>
+QT_BEGIN_NAMESPACE
+
+class QTwistSensorGestureRecognizer : public QSensorGestureRecognizer
+{
+ Q_OBJECT
+public:
+ explicit QTwistSensorGestureRecognizer(QObject *parent = 0);
+ ~QTwistSensorGestureRecognizer();
+
+ void create();
+
+ QString id() const;
+ bool start();
+ bool stop();
+ bool isActive();
+
+Q_SIGNALS:
+ void twistLeft();
+ void twistRight();
+
+private slots:
+ void accelChanged();
+ void timeout();
+
+private:
+ QAccelerometer *accel;
+ QTimer *timer;
+ int accelRange;
+ qreal lastX;
+ bool active;
+ QList<int> xList;
+
+ qreal pitch;
+ qreal roll;
+
+ qreal calc(qreal yrot);
+ bool detecting;
+};
+QT_END_NAMESPACE
+#endif // QWFLICKSENSORGESTURERECOGNIZER_H
diff --git a/src/plugins/sensorgestures/qtsensors/qwhipsensorgesturerecognizer.cpp b/src/plugins/sensorgestures/qtsensors/qwhipsensorgesturerecognizer.cpp
new file mode 100644
index 00000000..15322dfc
--- /dev/null
+++ b/src/plugins/sensorgestures/qtsensors/qwhipsensorgesturerecognizer.cpp
@@ -0,0 +1,139 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtSensors module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+#include "qwhipsensorgesturerecognizer.h"
+QT_BEGIN_NAMESPACE
+
+QWhipSensorGestureRecognizer::QWhipSensorGestureRecognizer(QObject *parent) :
+ QSensorGestureRecognizer(parent), whipIt(0)
+{
+}
+
+QWhipSensorGestureRecognizer::~QWhipSensorGestureRecognizer()
+{
+}
+
+void QWhipSensorGestureRecognizer::create()
+{
+ accel = new QAccelerometer(this);
+ accel->connectToBackend();
+ timer = new QTimer(this);
+
+ qoutputrangelist outputranges = accel->outputRanges();
+
+ if (outputranges.count() > 0)
+ accelRange = (int)(outputranges.at(0).maximum *2);
+ else
+ accelRange = 44; //this should never happen
+qDebug() << accelRange;
+ connect(timer,SIGNAL(timeout()),this,SLOT(timeout()));
+ timer->setSingleShot(true);
+ timer->setInterval(750);
+
+}
+
+QString QWhipSensorGestureRecognizer::id() const
+{
+ return QString("QtSensors.whip");
+}
+
+bool QWhipSensorGestureRecognizer::start()
+{
+ connect(accel,SIGNAL(readingChanged()),this,SLOT(accelChanged()));
+ active = accel->start();
+
+ return active;
+}
+
+bool QWhipSensorGestureRecognizer::stop()
+{
+ accel->stop();
+ active = accel->isActive();
+ disconnect(accel,SIGNAL(readingChanged()),this,SLOT(accelChanged()));
+ return !active;
+}
+
+bool QWhipSensorGestureRecognizer::isActive()
+{
+ return active;
+}
+
+void QWhipSensorGestureRecognizer::accelChanged()
+{
+ qreal x = accel->reading()->x();
+ qreal y = accel->reading()->y();
+
+ if (whipIt) {
+ qreal difference = lastX - x;
+// qDebug() << Q_FUNC_INFO << x << difference << wasNegative;
+
+ if ((!wasNegative && difference > accelRange * .75) //58
+ || (wasNegative && difference < -accelRange * .75)) {
+
+// qDebug() << Q_FUNC_INFO << "WHIP";
+ Q_EMIT whip();
+ Q_EMIT detected("whip");
+ whipIt = false;
+ }
+// } else if ((lastX - x) > (accelRange/2) || // 39
+// (x - lastX) < -(accelRange/2)) {
+ } else if (x > (accelRange/3.3) || // 23
+ x < -(accelRange/3.3)) {
+ //start of gesture
+// qDebug() << Q_FUNC_INFO << "start detection";
+ timer->start();
+ whipIt = true;
+ lastX = x;
+ if (lastX > 0)
+ wasNegative = false;
+ else
+ wasNegative = true;
+ }
+}
+
+void QWhipSensorGestureRecognizer::timeout()
+{
+// qDebug() << Q_FUNC_INFO;
+ whipIt = false;
+}
+
+QT_END_NAMESPACE
diff --git a/src/plugins/sensorgestures/qtsensors/qwhipsensorgesturerecognizer.h b/src/plugins/sensorgestures/qtsensors/qwhipsensorgesturerecognizer.h
new file mode 100644
index 00000000..701750ea
--- /dev/null
+++ b/src/plugins/sensorgestures/qtsensors/qwhipsensorgesturerecognizer.h
@@ -0,0 +1,81 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtSensors module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+#ifndef QWHIPSENSORGESTURERECOGNIZER_H
+#define QWHIPSENSORGESTURERECOGNIZER_H
+
+#include <qsensorgesturerecognizer.h>
+#include <QtSensors/QAccelerometer>
+QT_BEGIN_NAMESPACE
+
+class QWhipSensorGestureRecognizer : public QSensorGestureRecognizer
+{
+ Q_OBJECT
+public:
+ explicit QWhipSensorGestureRecognizer(QObject *parent = 0);
+ ~QWhipSensorGestureRecognizer();
+
+ void create();
+
+ QString id() const;
+ bool start();
+ bool stop();
+ bool isActive();
+
+Q_SIGNALS:
+ void whip();
+
+private slots:
+ void accelChanged();
+ void timeout();
+private:
+ QAccelerometer *accel;
+ QTimer *timer;
+ int accelRange;
+ bool whipIt;
+ bool wasNegative;
+ qreal lastX;
+ bool active;
+
+};
+QT_END_NAMESPACE
+#endif // QWHIPSENSORGESTURERECOGNIZER_H
diff --git a/src/plugins/sensorgestures/sensorgestures.pro b/src/plugins/sensorgestures/sensorgestures.pro
index 18898807..56f8cde6 100644
--- a/src/plugins/sensorgestures/sensorgestures.pro
+++ b/src/plugins/sensorgestures/sensorgestures.pro
@@ -1,3 +1,3 @@
TEMPLATE = subdirs
-!simulator:SUBDIRS += shake
+!simulator:SUBDIRS += shake qtsensors
simulator:SUBDIRS += simulator
diff --git a/src/plugins/sensorgestures/shake/qshakesensorgestureplugin.cpp b/src/plugins/sensorgestures/shake/qshakesensorgestureplugin.cpp
index bcbf5159..9ccd9582 100644
--- a/src/plugins/sensorgestures/shake/qshakesensorgestureplugin.cpp
+++ b/src/plugins/sensorgestures/shake/qshakesensorgestureplugin.cpp
@@ -46,7 +46,6 @@
#include "qshakesensorgestureplugin.h"
#include <qsensorgestureplugininterface.h>
-#include <qsensorgesturemanager.h>
#include "qshakerecognizer.h"
@@ -76,5 +75,5 @@ QList <QSensorGestureRecognizer *> QShakeSensorGesturePlugin::createRecognizers(
return recognizers;
}
-Q_EXPORT_PLUGIN2(QShakeSensorGestureRecognizer, QShakeSensorGesturePlugin)
+Q_EXPORT_PLUGIN2(qtsensorgestures_shakeplugin, QShakeSensorGesturePlugin)