aports/community/sensorfw/0003-Add-Wrist-gesture-sensor-via-libhybris-adaptor.patch
2024-07-28 16:49:54 +02:00

838 lines
27 KiB
Diff

From 10b1795c2eb3b524fab0e76bcc6754f1cae5336b Mon Sep 17 00:00:00 2001
From: MagneFire <dgriet@gmail.com>
Date: Tue, 11 Jan 2022 23:48:18 +0100
Subject: [PATCH 3/4] Add Wrist gesture sensor via libhybris adaptor.
---
adaptors/adaptors.pro | 1 +
.../hybriswristgestureadaptor.cpp | 91 +++++++++++++
.../hybriswristgestureadaptor.h | 61 +++++++++
.../hybriswristgestureadaptor.pro | 14 ++
.../hybriswristgestureadaptorplugin.cpp | 34 +++++
.../hybriswristgestureadaptorplugin.h | 38 ++++++
config/20-sensors-default.conf | 1 +
config/sensord-hybris.conf | 1 +
sensors/sensors.pro | 3 +-
.../wristgesturesensor/wristgestureplugin.cpp | 43 +++++++
.../wristgesturesensor/wristgestureplugin.h | 42 ++++++
.../wristgesturesensor/wristgesturesensor.cpp | 121 ++++++++++++++++++
.../wristgesturesensor/wristgesturesensor.h | 114 +++++++++++++++++
.../wristgesturesensor/wristgesturesensor.pro | 11 ++
.../wristgesturesensor_a.cpp | 49 +++++++
.../wristgesturesensor/wristgesturesensor_a.h | 57 +++++++++
16 files changed, 680 insertions(+), 1 deletion(-)
create mode 100644 adaptors/hybriswristgestureadaptor/hybriswristgestureadaptor.cpp
create mode 100644 adaptors/hybriswristgestureadaptor/hybriswristgestureadaptor.h
create mode 100644 adaptors/hybriswristgestureadaptor/hybriswristgestureadaptor.pro
create mode 100644 adaptors/hybriswristgestureadaptor/hybriswristgestureadaptorplugin.cpp
create mode 100644 adaptors/hybriswristgestureadaptor/hybriswristgestureadaptorplugin.h
create mode 100644 sensors/wristgesturesensor/wristgestureplugin.cpp
create mode 100644 sensors/wristgesturesensor/wristgestureplugin.h
create mode 100644 sensors/wristgesturesensor/wristgesturesensor.cpp
create mode 100644 sensors/wristgesturesensor/wristgesturesensor.h
create mode 100644 sensors/wristgesturesensor/wristgesturesensor.pro
create mode 100644 sensors/wristgesturesensor/wristgesturesensor_a.cpp
create mode 100644 sensors/wristgesturesensor/wristgesturesensor_a.h
diff --git a/adaptors/adaptors.pro b/adaptors/adaptors.pro
index ce558a4..0341717 100644
--- a/adaptors/adaptors.pro
+++ b/adaptors/adaptors.pro
@@ -12,7 +12,8 @@ HYBRIS_SUBDIRS = hybrisaccelerometer \
hybrisrotationadaptor \
hybrisgeorotationadaptor \
hybrisstepcounteradaptor \
- hybrishrmadaptor
+ hybrishrmadaptor \
+ hybriswristgestureadaptor
# split like this as Sailfish only installs hybris plugins
contains(CONFIG,hybris) {
diff --git a/adaptors/hybriswristgestureadaptor/hybriswristgestureadaptor.cpp b/adaptors/hybriswristgestureadaptor/hybriswristgestureadaptor.cpp
new file mode 100644
index 0000000..bb2c4fc
--- /dev/null
+++ b/adaptors/hybriswristgestureadaptor/hybriswristgestureadaptor.cpp
@@ -0,0 +1,91 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Jolla Ltd
+** Contact: lorn.potter@jollamobile.com
+**
+** Copyright (C) 2020 Darrel Griët
+** Contact: idanlcontact@gmail.com
+**
+**
+** $QT_BEGIN_LICENSE:LGPL$
+**
+** GNU Lesser General Public License Usage
+** Alternatively, 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.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "hybriswristgestureadaptor.h"
+#include "logging.h"
+#include "datatypes/utils.h"
+#include <hardware/sensors.h>
+#include "config.h"
+
+
+#ifndef SENSOR_TYPE_WRIST_TILT_GESTURE
+#define SENSOR_TYPE_WRIST_TILT_GESTURE (26)
+#endif
+
+HybrisWristGestureAdaptor::HybrisWristGestureAdaptor(const QString& id) :
+ HybrisAdaptor(id,SENSOR_TYPE_WRIST_TILT_GESTURE)
+{
+ buffer = new DeviceAdaptorRingBuffer<TimedUnsigned>(1);
+ setAdaptedSensor("hybriswristgesture", "Internal wristgesture coordinates", buffer);
+
+ setDescription("Hybris wristgesture");
+ powerStatePath = SensorFrameworkConfig::configuration()->value("wristgesture/powerstate_path").toByteArray();
+ if (!powerStatePath.isEmpty() && !QFile::exists(powerStatePath))
+ {
+ sensordLogW() << "Path does not exists: " << powerStatePath;
+ powerStatePath.clear();
+ }
+
+ // Set default delay.
+ setInterval(200, 0);
+}
+
+HybrisWristGestureAdaptor::~HybrisWristGestureAdaptor()
+{
+ delete buffer;
+}
+
+bool HybrisWristGestureAdaptor::startSensor()
+{
+ if (!(HybrisAdaptor::startSensor()))
+ return false;
+ if (isRunning() && !powerStatePath.isEmpty())
+ writeToFile(powerStatePath, "1");
+ sensordLogD() << "Hybris WristGestureAdaptor start\n";
+ return true;
+}
+
+void HybrisWristGestureAdaptor::stopSensor()
+{
+ HybrisAdaptor::stopSensor();
+ if (!isRunning() && !powerStatePath.isEmpty())
+ writeToFile(powerStatePath, "0");
+ sensordLogD() << "Hybris WristGestureAdaptor stop\n";
+}
+
+void HybrisWristGestureAdaptor::processSample(const sensors_event_t& data)
+{
+ TimedUnsigned *d = buffer->nextSlot();
+ d->timestamp_ = quint64(data.timestamp * .001);
+#ifdef NO_SENSORS_EVENT_U64
+ uint64_t value = 0;
+ memcpy(&value, data.data, sizeof value);
+ d->value_ = value;
+#else
+ d->value_ = data.u64.step_counter;
+#endif
+ sensordLogD() << "HybrisWristGestureAdaptor: processSample(): " << data.data[0];
+
+ buffer->commit();
+ buffer->wakeUpReaders();
+}
diff --git a/adaptors/hybriswristgestureadaptor/hybriswristgestureadaptor.h b/adaptors/hybriswristgestureadaptor/hybriswristgestureadaptor.h
new file mode 100644
index 0000000..ebdd729
--- /dev/null
+++ b/adaptors/hybriswristgestureadaptor/hybriswristgestureadaptor.h
@@ -0,0 +1,61 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Jolla Ltd
+** Contact: lorn.potter@jollamobile.com
+**
+** Copyright (C) 2020 Darrel Griët
+** Contact: idanlcontact@gmail.com
+**
+**
+** $QT_BEGIN_LICENSE:LGPL$
+**
+** GNU Lesser General Public License Usage
+** Alternatively, 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.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef HYBRISWRISTGESTUREADAPTOR_H
+#define HYBRISWRISTGESTUREADAPTOR_H
+#include "hybrisadaptor.h"
+
+#include <QString>
+#include <QStringList>
+#include "deviceadaptorringbuffer.h"
+#include "datatypes/orientationdata.h"
+
+/**
+ * @brief Adaptor for hybris wrist gesture sensor.
+ *
+ * Adaptor for wrist gesture sensor.
+ */
+class HybrisWristGestureAdaptor : public HybrisAdaptor
+{
+ Q_OBJECT
+
+public:
+ static DeviceAdaptor* factoryMethod(const QString& id) {
+ return new HybrisWristGestureAdaptor(id);
+ }
+ HybrisWristGestureAdaptor(const QString& id);
+ ~HybrisWristGestureAdaptor();
+
+ bool startSensor();
+ void stopSensor();
+
+protected:
+ void processSample(const sensors_event_t& data);
+
+private:
+ DeviceAdaptorRingBuffer<TimedUnsigned>* buffer;
+ int sensorType;
+ QByteArray powerStatePath;
+
+};
+#endif
diff --git a/adaptors/hybriswristgestureadaptor/hybriswristgestureadaptor.pro b/adaptors/hybriswristgestureadaptor/hybriswristgestureadaptor.pro
new file mode 100644
index 0000000..f5465d5
--- /dev/null
+++ b/adaptors/hybriswristgestureadaptor/hybriswristgestureadaptor.pro
@@ -0,0 +1,14 @@
+TARGET = hybriswristgestureadaptor
+
+HEADERS += hybriswristgestureadaptor.h \
+ hybriswristgestureadaptorplugin.h
+
+SOURCES += hybriswristgestureadaptor.cpp \
+ hybriswristgestureadaptorplugin.cpp
+
+LIBS+= -L../../core -lhybrissensorfw-qt5
+
+include( ../adaptor-config.pri )
+config_hybris {
+ PKGCONFIG += android-headers
+}
diff --git a/adaptors/hybriswristgestureadaptor/hybriswristgestureadaptorplugin.cpp b/adaptors/hybriswristgestureadaptor/hybriswristgestureadaptorplugin.cpp
new file mode 100644
index 0000000..2c7713b
--- /dev/null
+++ b/adaptors/hybriswristgestureadaptor/hybriswristgestureadaptorplugin.cpp
@@ -0,0 +1,34 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Jolla Ltd
+** Contact: lorn.potter@jollamobile.com
+**
+** Copyright (C) 2020 Darrel Griët
+** Contact: idanlcontact@gmail.com
+**
+**
+** $QT_BEGIN_LICENSE:LGPL$
+**
+** GNU Lesser General Public License Usage
+** Alternatively, 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.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "hybriswristgestureadaptorplugin.h"
+#include "hybriswristgestureadaptor.h"
+#include "sensormanager.h"
+#include "logging.h"
+
+void HybrisWristGestureAdaptorPlugin::Register(class Loader&)
+{
+ sensordLogD() << "registering hybriswristgestureadaptor";
+ SensorManager& sm = SensorManager::instance();
+ sm.registerDeviceAdaptor<HybrisWristGestureAdaptor>("wristgestureadaptor");
+}
diff --git a/adaptors/hybriswristgestureadaptor/hybriswristgestureadaptorplugin.h b/adaptors/hybriswristgestureadaptor/hybriswristgestureadaptorplugin.h
new file mode 100644
index 0000000..9e6b8b0
--- /dev/null
+++ b/adaptors/hybriswristgestureadaptor/hybriswristgestureadaptorplugin.h
@@ -0,0 +1,38 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Jolla Ltd
+** Contact: lorn.potter@jollamobile.com
+**
+** Copyright (C) 2020 Darrel Griët
+** Contact: idanlcontact@gmail.com
+**
+**
+** $QT_BEGIN_LICENSE:LGPL$
+**
+** GNU Lesser General Public License Usage
+** Alternatively, 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.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef HYBRISWRISTGESTUREADAPTORPLUGIN_H
+#define HYBRISWRISTGESTUREADAPTORPLUGIN_H
+
+#include "plugin.h"
+
+class HybrisWristGestureAdaptorPlugin : public Plugin
+{
+ Q_OBJECT
+ Q_PLUGIN_METADATA(IID "com.nokia.SensorService.Plugin/1.0")
+
+private:
+ void Register(class Loader& l);
+};
+
+#endif
diff --git a/config/20-sensors-default.conf b/config/20-sensors-default.conf
index 5bccd68..4439764 100644
--- a/config/20-sensors-default.conf
+++ b/config/20-sensors-default.conf
@@ -43,6 +43,7 @@ pressuresensor=True
rotationsensor=True
stepcountersensor=True
hrmsensor=True
+wristgesturesensor=True
; To avoid revisiting config files for all old ports in the future, the
; defaults for added sensors should be set "False" by default here, and
diff --git a/config/sensord-hybris.conf b/config/sensord-hybris.conf
index 8d5cdfb..c596172 100644
--- a/config/sensord-hybris.conf
+++ b/config/sensord-hybris.conf
@@ -8,6 +8,7 @@ orientationadaptor = hybrisorientationadaptor
stepcounteradaptor = hybrisstepcounteradaptor
pressureadaptor = hybrispressureadaptor
hrmadaptor = hybrishrmadaptor
+wristgestureadaptor = hybriswristgestureadaptor
[magnetometer]
scale_coefficient = 1
diff --git a/sensors/sensors.pro b/sensors/sensors.pro
index 286fecf..52197f5 100644
--- a/sensors/sensors.pro
+++ b/sensors/sensors.pro
@@ -17,6 +17,7 @@ SUBDIRS = accelerometersensor \
pressuresensor \
temperaturesensor \
stepcountersensor \
- hrmsensor
+ hrmsensor \
+ wristgesturesensor
contextprovider:SUBDIRS += contextplugin
diff --git a/sensors/wristgesturesensor/wristgestureplugin.cpp b/sensors/wristgesturesensor/wristgestureplugin.cpp
new file mode 100644
index 0000000..0122916
--- /dev/null
+++ b/sensors/wristgesturesensor/wristgestureplugin.cpp
@@ -0,0 +1,43 @@
+/**
+ @file wristgestureplugin.cpp
+ @brief Plugin for WristGestureSensor
+
+ <p>
+ Copyright (C) 2009-2010 Nokia Corporation
+ Copyright (C) 2020 Darrel Griët
+
+ @author Timo Rongas <ext-timo.2.rongas@nokia.com>
+ @author Ustun Ergenoglu <ext-ustun.ergenoglu@nokia.com>
+ @author Darrel Griët <idanlcontact@gmail.com>
+
+ This file is part of Sensord.
+
+ Sensord is free software; you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License
+ version 2.1 as published by the Free Software Foundation.
+
+ Sensord is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with Sensord. If not, see <http://www.gnu.org/licenses/>.
+ </p>
+*/
+
+#include "wristgestureplugin.h"
+#include "wristgesturesensor.h"
+#include "sensormanager.h"
+#include "logging.h"
+
+void WristGesturePlugin::Register(class Loader&)
+{
+ sensordLogD() << "registering wristgesturesensor";
+ SensorManager& sm = SensorManager::instance();
+ sm.registerSensor<WristGestureSensorChannel>("wristgesturesensor");
+}
+
+QStringList WristGesturePlugin::Dependencies() {
+ return QString("wristgestureadaptor").split(":", QString::SkipEmptyParts);
+}
diff --git a/sensors/wristgesturesensor/wristgestureplugin.h b/sensors/wristgesturesensor/wristgestureplugin.h
new file mode 100644
index 0000000..1d9a9eb
--- /dev/null
+++ b/sensors/wristgesturesensor/wristgestureplugin.h
@@ -0,0 +1,42 @@
+/**
+ @file orientationplugin.h
+ @brief Plugin for WristGestureSensor
+
+ <p>
+ Copyright (C) 2009-2010 Nokia Corporation
+ Copyright (C) 2020 Darrel Griët
+
+ @author Timo Rongas <ext-timo.2.rongas@nokia.com>
+ @author Darrel Griët <idanlcontact@gmail.com>
+
+ This file is part of Sensord.
+
+ Sensord is free software; you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License
+ version 2.1 as published by the Free Software Foundation.
+
+ Sensord is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with Sensord. If not, see <http://www.gnu.org/licenses/>.
+ </p>
+*/
+
+#ifndef WRISTGESTUREPLUGIN_H
+#define WRISTGESTUREPLUGIN_H
+
+#include "plugin.h"
+
+class WristGesturePlugin : public Plugin
+{
+ Q_OBJECT
+ Q_PLUGIN_METADATA(IID "com.nokia.SensorService.Plugin/1.0")
+private:
+ void Register(class Loader& l);
+ QStringList Dependencies();
+};
+
+#endif
diff --git a/sensors/wristgesturesensor/wristgesturesensor.cpp b/sensors/wristgesturesensor/wristgesturesensor.cpp
new file mode 100644
index 0000000..7b03ca4
--- /dev/null
+++ b/sensors/wristgesturesensor/wristgesturesensor.cpp
@@ -0,0 +1,121 @@
+/**
+ @file wristgesturesensor.cpp
+ @brief WristGestureSensor
+
+ <p>
+ Copyright (C) 2009-2010 Nokia Corporation
+ Copyright (C) 2020 Darrel Griët
+
+ @author Timo Rongas <ext-timo.2.rongas@nokia.com>
+ @author Ustun Ergenoglu <ext-ustun.ergenoglu@nokia.com>
+ @author Darrel Griët <idanlcontact@gmail.com>
+
+ This file is part of Sensord.
+
+ Sensord is free software; you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License
+ version 2.1 as published by the Free Software Foundation.
+
+ Sensord is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with Sensord. If not, see <http://www.gnu.org/licenses/>.
+ </p>
+*/
+
+#include "wristgesturesensor.h"
+
+#include "sensormanager.h"
+#include "bin.h"
+#include "bufferreader.h"
+
+WristGestureSensorChannel::WristGestureSensorChannel(const QString& id) :
+ AbstractSensorChannel(id),
+ DataEmitter<TimedUnsigned>(1),
+ prevWristGesture(0,0)
+{
+ SensorManager& sm = SensorManager::instance();
+
+ wristGestureAdaptor_ = sm.requestDeviceAdaptor("wristgestureadaptor");
+ if (!wristGestureAdaptor_) {
+ setValid(false);
+ return;
+ }
+
+ wristgestureReader_ = new BufferReader<TimedUnsigned>(1);
+
+ outputBuffer_ = new RingBuffer<TimedUnsigned>(1);
+
+ // Create buffers for filter chain
+ filterBin_ = new Bin;
+
+ filterBin_->add(wristgestureReader_, "wristgesture");
+ filterBin_->add(outputBuffer_, "buffer");
+
+ // Join filterchain buffers
+ filterBin_->join("wristgesture", "source", "buffer", "sink");
+
+ // Join datasources to the chain
+ connectToSource(wristGestureAdaptor_, "wristgesture", wristgestureReader_);
+
+ marshallingBin_ = new Bin;
+ marshallingBin_->add(this, "sensorchannel");
+
+ outputBuffer_->join(this);
+
+ setDescription("wristgesture sensor for wake up detection");
+ setRangeSource(wristGestureAdaptor_);
+ addStandbyOverrideSource(wristGestureAdaptor_);
+ setIntervalSource(wristGestureAdaptor_);
+
+ setValid(true);
+}
+
+WristGestureSensorChannel::~WristGestureSensorChannel()
+{
+ if (isValid()) {
+ SensorManager& sm = SensorManager::instance();
+
+ disconnectFromSource(wristGestureAdaptor_, "wristgesture", wristgestureReader_);
+
+ sm.releaseDeviceAdaptor("wristgestureadaptor");
+
+ delete wristgestureReader_;
+ delete outputBuffer_;
+ delete marshallingBin_;
+ delete filterBin_;
+ }
+}
+
+bool WristGestureSensorChannel::start()
+{
+ sensordLogD() << "Starting WristGestureSensorChannel";
+
+ if (AbstractSensorChannel::start()) {
+ marshallingBin_->start();
+ filterBin_->start();
+ wristGestureAdaptor_->startSensor();
+ }
+ return true;
+}
+
+bool WristGestureSensorChannel::stop()
+{
+ sensordLogD() << "Stopping WristGestureSensorChannel";
+
+ if (AbstractSensorChannel::stop()) {
+ wristGestureAdaptor_->stopSensor();
+ filterBin_->stop();
+ marshallingBin_->stop();
+ }
+ return true;
+}
+
+void WristGestureSensorChannel::emitData(const TimedUnsigned& value)
+{
+ prevWristGesture.value_ = value.value_;
+ writeToClients((const void *)&value, sizeof(value));
+}
diff --git a/sensors/wristgesturesensor/wristgesturesensor.h b/sensors/wristgesturesensor/wristgesturesensor.h
new file mode 100644
index 0000000..0c809f0
--- /dev/null
+++ b/sensors/wristgesturesensor/wristgesturesensor.h
@@ -0,0 +1,114 @@
+/**
+ @file wristgesturesensor.h
+ @brief WristGestureSensor
+
+ <p>
+ Copyright (C) 2009-2010 Nokia Corporation
+ Copyright (C) 2020 Darrel Griët
+
+ @author Timo Rongas <ext-timo.2.rongas@nokia.com>
+ @author Darrel Griët <idanlcontact@gmail.com>
+
+ This file is part of Sensord.
+
+ Sensord is free software; you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License
+ version 2.1 as published by the Free Software Foundation.
+
+ Sensord is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with Sensord. If not, see <http://www.gnu.org/licenses/>.
+ </p>
+*/
+
+#ifndef WRISTGESTURE_SENSOR_CHANNEL_H
+#define WRISTGESTURE_SENSOR_CHANNEL_H
+
+#include <QObject>
+
+#include "deviceadaptor.h"
+#include "abstractsensor.h"
+#include "wristgesturesensor_a.h"
+#include "dataemitter.h"
+#include "datatypes/timedunsigned.h"
+#include "datatypes/unsigned.h"
+
+class Bin;
+template <class TYPE> class BufferReader;
+class FilterBase;
+
+/**
+ * @brief Sensor for accessing device wristgesture.
+ *
+ * Provides device wristgesture based on the direction of acceleration vector.
+ * Threshold value (mG) is used to control the sensitivity of change from one
+ * wristgesture into another. See #WristGestureInterpreter for details on threshold.
+ */
+class WristGestureSensorChannel :
+ public AbstractSensorChannel,
+ public DataEmitter<TimedUnsigned>
+{
+ Q_OBJECT;
+ Q_PROPERTY(Unsigned wristgesture READ wristgesture);
+
+public:
+
+ /**
+ * Factory method for WristGestureSensorChannel.
+ * @return New WristGestureSensorChannel as AbstractSensorChannel*
+ */
+ static AbstractSensorChannel* factoryMethod(const QString& id)
+ {
+ WristGestureSensorChannel* sc = new WristGestureSensorChannel(id);
+ new WristGestureSensorChannelAdaptor(sc);
+
+ return sc;
+ }
+
+ /**
+ * Property method returning current wristgesture.
+ * @return Current wristgesture.
+ */
+ Unsigned wristgesture() const
+ {
+ return prevWristGesture;
+ }
+
+public Q_SLOTS:
+ bool start();
+ bool stop();
+
+signals:
+ /**
+ * Sent whenever wristgesture interpretation has changed.
+ * @param wristgesture New wristgesture.
+ */
+ void wristgestureChanged(const int& wristgesture);
+
+protected:
+ WristGestureSensorChannel(const QString& id);
+ virtual ~WristGestureSensorChannel();
+
+private:
+ TimedUnsigned prevWristGesture;
+ Bin* filterBin_;
+ Bin* marshallingBin_;
+
+ DeviceAdaptor* wristGestureAdaptor_;
+
+ BufferReader<TimedUnsigned>* wristgestureReader_;
+
+ RingBuffer<TimedUnsigned>* outputBuffer_;
+
+ /**
+ * Emits new device wristgesture through DBus.
+ * @param value WristGesture value to emit.
+ */
+ void emitData(const TimedUnsigned& value);
+};
+
+#endif // WRISTGESTURE_SENSOR_CHANNEL_H
diff --git a/sensors/wristgesturesensor/wristgesturesensor.pro b/sensors/wristgesturesensor/wristgesturesensor.pro
new file mode 100644
index 0000000..dfd759f
--- /dev/null
+++ b/sensors/wristgesturesensor/wristgesturesensor.pro
@@ -0,0 +1,11 @@
+TARGET = wristgesturesensor
+
+HEADERS += wristgesturesensor.h \
+ wristgesturesensor_a.h \
+ wristgestureplugin.h
+
+SOURCES += wristgesturesensor.cpp \
+ wristgesturesensor_a.cpp \
+ wristgestureplugin.cpp
+
+include( ../sensor-config.pri )
diff --git a/sensors/wristgesturesensor/wristgesturesensor_a.cpp b/sensors/wristgesturesensor/wristgesturesensor_a.cpp
new file mode 100644
index 0000000..e3817e8
--- /dev/null
+++ b/sensors/wristgesturesensor/wristgesturesensor_a.cpp
@@ -0,0 +1,49 @@
+/**
+ @file wristgesturesensor_a.cpp
+ @brief D-Bus Adaptor for WristGestureSensor
+
+ <p>
+ Copyright (C) 2009-2010 Nokia Corporation
+ Copyright (C) 2020 Darrel Griët
+
+ @author Timo Rongas <ext-timo.2.rongas@nokia.com>
+ @author Antti Virtanen <antti.i.virtanen@nokia.com>
+ @author Darrel Griët <idanlcontact@gmail.com>
+
+ This file is part of Sensord.
+
+ Sensord is free software; you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License
+ version 2.1 as published by the Free Software Foundation.
+
+ Sensord is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with Sensord. If not, see <http://www.gnu.org/licenses/>.
+ </p>
+*/
+
+#include "wristgesturesensor_a.h"
+
+WristGestureSensorChannelAdaptor::WristGestureSensorChannelAdaptor(QObject* parent) :
+ AbstractSensorChannelAdaptor(parent)
+{
+}
+
+Unsigned WristGestureSensorChannelAdaptor::wristgesture() const
+{
+ return qvariant_cast<Unsigned>(parent()->property("wristgesture"));
+}
+
+int WristGestureSensorChannelAdaptor::threshold() const
+{
+ return qvariant_cast<int>(parent()->property("threshold"));
+}
+
+void WristGestureSensorChannelAdaptor::setThreshold(int value)
+{
+ parent()->setProperty("threshold", value);
+}
diff --git a/sensors/wristgesturesensor/wristgesturesensor_a.h b/sensors/wristgesturesensor/wristgesturesensor_a.h
new file mode 100644
index 0000000..a589337
--- /dev/null
+++ b/sensors/wristgesturesensor/wristgesturesensor_a.h
@@ -0,0 +1,57 @@
+/**
+ @file wristgesturesensor_a.h
+ @brief D-Bus Adaptor for WristGestureSensor
+
+ <p>
+ Copyright (C) 2009-2010 Nokia Corporation
+ Copyright (C) 2020 Darrel Griët
+
+ @author Timo Rongas <ext-timo.2.rongas@nokia.com>
+ @author Antti Virtanen <antti.i.virtanen@nokia.com>
+ @author Darrel Griët <idanlcontact@gmail.com>
+
+ This file is part of Sensord.
+
+ Sensord is free software; you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License
+ version 2.1 as published by the Free Software Foundation.
+
+ Sensord is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with Sensord. If not, see <http://www.gnu.org/licenses/>.
+ </p>
+*/
+
+#ifndef WRISTGESTURE_SENSOR_H
+#define WRISTGESTURE_SENSOR_H
+
+#include <QtDBus/QtDBus>
+
+#include "datatypes/unsigned.h"
+#include "abstractsensor_a.h"
+
+class WristGestureSensorChannelAdaptor : public AbstractSensorChannelAdaptor
+{
+ Q_OBJECT
+ Q_DISABLE_COPY(WristGestureSensorChannelAdaptor)
+ Q_CLASSINFO("D-Bus Interface", "local.WristGestureSensor")
+ Q_PROPERTY(Unsigned wristgesture READ wristgesture)
+ Q_PROPERTY(int threshold READ threshold WRITE setThreshold)
+
+public:
+ WristGestureSensorChannelAdaptor(QObject* parent);
+
+public Q_SLOTS:
+ Unsigned wristgesture() const;
+ int threshold() const;
+ void setThreshold(int value);
+
+Q_SIGNALS:
+ void wristgestureChanged(const Unsigned& wristgesture);
+};
+
+#endif
--
2.34.1