Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion adaptors/adaptors.pro
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ HYBRIS_SUBDIRS = hybrisaccelerometer \
hybrisorientationadaptor \
hybrisrotationadaptor \
hybrisgeorotationadaptor \
hybrisstepcounteradaptor
hybrisstepcounteradaptor \
hybrischopchopadaptor \
hybriscameragestureadaptor \
hybrisliftgestureadaptor

# split like this as Sailfish only installs hybris plugins
contains(CONFIG,hybris) {
Expand Down
91 changes: 91 additions & 0 deletions adaptors/hybriscameragestureadaptor/hybriscameragestureadaptor.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
/****************************************************************************
**
** Copyright (c) 2025 Jollyboys Ltd.
**
** $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 <QFile>
#include <QTextStream>

#include "hybriscameragestureadaptor.h"
#include "logging.h"
#include "datatypes/utils.h"
#include "config.h"

namespace {
int cameraGestureSensorType()
{
QVariant setting(SensorFrameworkConfig::configuration()->value("cameragesture/sensor_type"));
bool ok = false;
int sensorType = setting.toInt(&ok);
if (!ok)
sensorType = 65540;
qCInfo(lcSensorFw) << "cameraGestureSensorType:" << sensorType;
return sensorType;
}
}

HybrisCameraGestureAdaptor::HybrisCameraGestureAdaptor(const QString &id)
: HybrisAdaptor(id, cameraGestureSensorType())
{
m_buffer = new DeviceAdaptorRingBuffer<TimedUnsigned>(1);
setAdaptedSensor("cameragesture", "CameraGesture sensor events", m_buffer);
setDescription("Hybris cameraGesture");
m_powerStatePath = SensorFrameworkConfig::configuration()->value("cameragesture/powerstate_path").toByteArray();
if (!m_powerStatePath.isEmpty() && !QFile::exists(m_powerStatePath)) {
qCWarning(lcSensorFw) << NodeBase::id() << "Path does not exists: " << m_powerStatePath;
m_powerStatePath.clear();
}
}

HybrisCameraGestureAdaptor::~HybrisCameraGestureAdaptor()
{
delete m_buffer;
}

bool HybrisCameraGestureAdaptor::startSensor()
{
if (!(HybrisAdaptor::startSensor()))
return false;
if (isRunning() && !m_powerStatePath.isEmpty())
writeToFile(m_powerStatePath, "1");
qCInfo(lcSensorFw) << id() << "HybrisCameraGestureAdaptor start";
return true;
}

void HybrisCameraGestureAdaptor::stopSensor()
{
HybrisAdaptor::stopSensor();
if (!isRunning() && !m_powerStatePath.isEmpty())
writeToFile(m_powerStatePath, "0");
qCInfo(lcSensorFw) << id() << "HybrisCameraGestureAdaptor stop";
}

void HybrisCameraGestureAdaptor::processSample(const sensors_event_t &data)
{
TimedUnsigned *d = m_buffer->nextSlot();
d->timestamp_ = quint64(data.timestamp * 0.001);

#ifdef USE_BINDER
d->value_ = unsigned(data.u.scalar);
#else
d->value_ = unsigned(data.data[0]);
#endif

qCInfo(lcSensorFw) << id() << "HybrisCameraGestureAdaptor event" << d->timestamp_ << d->value_;

m_buffer->commit();
m_buffer->wakeUpReaders();
}
58 changes: 58 additions & 0 deletions adaptors/hybriscameragestureadaptor/hybriscameragestureadaptor.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/****************************************************************************
**
** Copyright (c) 2025 Jollyboys Ltd.
**
** $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 HYBRISCAMERAGESTUREADAPTOR_H
#define HYBRISCAMERAGESTUREADAPTOR_H
#include "hybrisadaptor.h"

#include <QString>
#include <QStringList>
#include <QTime>
#include <linux/input.h>
#include "datatypes/timedunsigned.h"
#include "deviceadaptorringbuffer.h"

/** Adaptor for hybris cameraGesture sensor.
*
* Adaptor for cameraGesture sensor. Provides cameraGesture events that can be used
* for example for triggering SneakPeek mode. Sensor value of one means
* cameraGesture condition was met. Other values should be ignored. Uses hybris
* sensor daemon driver interface.
*/
class HybrisCameraGestureAdaptor : public HybrisAdaptor
{
Q_OBJECT

public:
static DeviceAdaptor *factoryMethod(const QString &id) {
return new HybrisCameraGestureAdaptor(id);
}
HybrisCameraGestureAdaptor(const QString &id);
~HybrisCameraGestureAdaptor();

bool startSensor();
void stopSensor();

protected:
void processSample(const sensors_event_t &data);

private:
DeviceAdaptorRingBuffer<TimedUnsigned> *m_buffer;
QByteArray m_powerStatePath;
};
#endif // HYBRISCAMERAGESTUREADAPTOR_H
13 changes: 13 additions & 0 deletions adaptors/hybriscameragestureadaptor/hybriscameragestureadaptor.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
TARGET = hybriscameragestureadaptor

HEADERS += hybriscameragestureadaptor.h \
hybriscameragestureadaptorplugin.h

SOURCES += hybriscameragestureadaptor.cpp \
hybriscameragestureadaptorplugin.cpp
LIBS += -L../../core -lhybrissensorfw-qt$${QT_MAJOR_VERSION}

include( ../adaptor-config.pri )
config_hybris {
PKGCONFIG += android-headers
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/****************************************************************************
**
** Copyright (c) 2025 Jollyboys Ltd.
**
** $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 "hybriscameragestureadaptorplugin.h"
#include "hybriscameragestureadaptor.h"
#include "sensormanager.h"
#include "logging.h"

void HybrisCameraGestureAdaptorPlugin::Register(class Loader &l)
{
Q_UNUSED(l);
qCDebug(lcSensorFw) << "registering hybriscameragestureadaptor";
SensorManager &sm = SensorManager::instance();
sm.registerDeviceAdaptor<HybrisCameraGestureAdaptor>("cameragestureadaptor");
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/****************************************************************************
**
** Copyright (c) 2025 Jollyboys Ltd.
**
** $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 HYBRISCAMERAGESTUREADAPTORPLUGIN_H
#define HYBRISCAMERAGESTUREADAPTORPLUGIN_H

#include "plugin.h"

class HybrisCameraGestureAdaptorPlugin : public Plugin
{
Q_OBJECT
Q_PLUGIN_METADATA(IID "com.nokia.SensorService.Plugin/1.0")

private:
void Register(class Loader &l);
};
#endif // HYBRISCAMERAGESTUREADAPTORPLUGIN_H
91 changes: 91 additions & 0 deletions adaptors/hybrischopchopadaptor/hybrischopchopadaptor.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
/****************************************************************************
**
** Copyright (c) 2025 Jollyboys Ltd.
**
** $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 <QFile>
#include <QTextStream>

#include "hybrischopchopadaptor.h"
#include "logging.h"
#include "datatypes/utils.h"
#include "config.h"

namespace {
int chopChopSensorType()
{
QVariant setting(SensorFrameworkConfig::configuration()->value("chopchop/sensor_type"));
bool ok = false;
int sensorType = setting.toInt(&ok);
if (!ok)
sensorType = 65546;
qCInfo(lcSensorFw) << "chopChopSensorType:" << sensorType;
return sensorType;
}
}

HybrisChopChopAdaptor::HybrisChopChopAdaptor(const QString &id)
: HybrisAdaptor(id, chopChopSensorType())
{
m_buffer = new DeviceAdaptorRingBuffer<TimedUnsigned>(1);
setAdaptedSensor("chopchop", "ChopChop sensor events", m_buffer);
setDescription("Hybris chopChop");
m_powerStatePath = SensorFrameworkConfig::configuration()->value("chopchop/powerstate_path").toByteArray();
if (!m_powerStatePath.isEmpty() && !QFile::exists(m_powerStatePath)) {
qCWarning(lcSensorFw) << NodeBase::id() << "Path does not exists: " << m_powerStatePath;
m_powerStatePath.clear();
}
}

HybrisChopChopAdaptor::~HybrisChopChopAdaptor()
{
delete m_buffer;
}

bool HybrisChopChopAdaptor::startSensor()
{
if (!(HybrisAdaptor::startSensor()))
return false;
if (isRunning() && !m_powerStatePath.isEmpty())
writeToFile(m_powerStatePath, "1");
qCInfo(lcSensorFw) << id() << "HybrisChopChopAdaptor start";
return true;
}

void HybrisChopChopAdaptor::stopSensor()
{
HybrisAdaptor::stopSensor();
if (!isRunning() && !m_powerStatePath.isEmpty())
writeToFile(m_powerStatePath, "0");
qCInfo(lcSensorFw) << id() << "HybrisChopChopAdaptor stop";
}

void HybrisChopChopAdaptor::processSample(const sensors_event_t &data)
{
TimedUnsigned *d = m_buffer->nextSlot();
d->timestamp_ = quint64(data.timestamp * 0.001);

#ifdef USE_BINDER
d->value_ = unsigned(data.u.scalar);
#else
d->value_ = unsigned(data.data[0]);
#endif

qCInfo(lcSensorFw) << id() << "HybrisChopChopAdaptor event" << d->timestamp_ << d->value_;

m_buffer->commit();
m_buffer->wakeUpReaders();
}
58 changes: 58 additions & 0 deletions adaptors/hybrischopchopadaptor/hybrischopchopadaptor.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/****************************************************************************
**
** Copyright (c) 2025 Jollyboys Ltd.
**
** $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 HYBRISCHOPCHOPADAPTOR_H
#define HYBRISCHOPCHOPADAPTOR_H
#include "hybrisadaptor.h"

#include <QString>
#include <QStringList>
#include <QTime>
#include <linux/input.h>
#include "datatypes/timedunsigned.h"
#include "deviceadaptorringbuffer.h"

/** Adaptor for hybris chopChop sensor.
*
* Adaptor for chopChop sensor. Provides chopChop events that can be used
* for example for triggering SneakPeek mode. Sensor value of one means
* chopChop condition was met. Other values should be ignored. Uses hybris
* sensor daemon driver interface.
*/
class HybrisChopChopAdaptor : public HybrisAdaptor
{
Q_OBJECT

public:
static DeviceAdaptor *factoryMethod(const QString &id) {
return new HybrisChopChopAdaptor(id);
}
HybrisChopChopAdaptor(const QString &id);
~HybrisChopChopAdaptor();

bool startSensor();
void stopSensor();

protected:
void processSample(const sensors_event_t &data);

private:
DeviceAdaptorRingBuffer<TimedUnsigned> *m_buffer;
QByteArray m_powerStatePath;
};
#endif // HYBRISCHOPCHOPADAPTOR_H
Loading