diff options
author | Alex Blasche <alexander.blasche@theqtcompany.com> | 2015-06-17 14:37:27 +0200 |
---|---|---|
committer | Alex Blasche <alexander.blasche@theqtcompany.com> | 2015-06-18 08:02:57 +0000 |
commit | 7a396992b19b440c236e3a8f483698fd0abee5e4 (patch) | |
tree | fd858371b1011599fb7294352d4ae806c07cd4c7 /src/plugins | |
parent | 6452e1d21df010541900aa2fd4baa9e89c5fd382 (diff) | |
download | qtsensors-7a396992b19b440c236e3a8f483698fd0abee5e4.tar.gz |
Remove BlackBerry as supported platform from QtSensors
[ChangeLog][QtSensors][Platform Specific Changes] Removed support
for BlackBerry 10 from QtSensors.
Change-Id: I56788caaa53797b7d4e23bb053c3ea8b460b1341
Reviewed-by: Rafael Roquetto <rafael.roquetto@kdab.com>
Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
Diffstat (limited to 'src/plugins')
41 files changed, 6 insertions, 2907 deletions
diff --git a/src/plugins/sensors/blackberry/bbaccelerometer.cpp b/src/plugins/sensors/blackberry/bbaccelerometer.cpp deleted file mode 100644 index 59ac68c..0000000 --- a/src/plugins/sensors/blackberry/bbaccelerometer.cpp +++ /dev/null @@ -1,94 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Research In Motion -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL21$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** 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 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** As a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include "bbaccelerometer.h" - -BbAccelerometer::BbAccelerometer(QSensor *sensor) - : BbSensorBackend<QAccelerometerReading>(devicePath(), SENSOR_TYPE_ACCELEROMETER, sensor) -{ - setDescription(QLatin1String("X, Y, and Z axes accelerations in m/s^2")); - - QAccelerometer * const accelerometer = qobject_cast<QAccelerometer *>(sensor); - if (accelerometer) { - connect(accelerometer, SIGNAL(accelerationModeChanged(AccelerationMode)), - this, SLOT(applyAccelerationMode())); - } -} - -bool BbAccelerometer::updateReadingFromEvent(const sensor_event_t &event, QAccelerometerReading *reading) -{ - float x = event.motion.dsp.x; - float y = event.motion.dsp.y; - float z = event.motion.dsp.z; - remapAxes(&x, &y, &z); - reading->setX(x); - reading->setY(y); - reading->setZ(z); - return true; -} - -void BbAccelerometer::start() -{ - applyAccelerationMode(); - BbSensorBackend<QAccelerometerReading>::start(); -} - -QString BbAccelerometer::devicePath() -{ - return QLatin1String("/dev/sensor/accel"); -} - -void BbAccelerometer::applyAccelerationMode() -{ - const QAccelerometer * const accelerometer = qobject_cast<QAccelerometer *>(sensor()); - if (accelerometer) { - QString fileName; - sensor_type_e sensorType; - switch (accelerometer->accelerationMode()) { - case QAccelerometer::Gravity: - fileName = QLatin1String("/dev/sensor/gravity"); - sensorType = SENSOR_TYPE_GRAVITY; - break; - case QAccelerometer::User: - fileName = QLatin1String("/dev/sensor/linAccel"); - sensorType = SENSOR_TYPE_LINEAR_ACCEL; - break; - default: - case QAccelerometer::Combined: - fileName = devicePath(); - sensorType = SENSOR_TYPE_ACCELEROMETER; - break; - } - - setDevice(fileName, sensorType); - } -} diff --git a/src/plugins/sensors/blackberry/bbaccelerometer.h b/src/plugins/sensors/blackberry/bbaccelerometer.h deleted file mode 100644 index 3ac6256..0000000 --- a/src/plugins/sensors/blackberry/bbaccelerometer.h +++ /dev/null @@ -1,56 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Research In Motion -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL21$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** 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 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** As a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#ifndef BBACCELEROMETER_H -#define BBACCELEROMETER_H - -#include "bbsensorbackend.h" -#include <qaccelerometer.h> - -class BbAccelerometer : public BbSensorBackend<QAccelerometerReading> -{ - Q_OBJECT - -public: - explicit BbAccelerometer(QSensor *sensor); - - void start() Q_DECL_OVERRIDE; - static QString devicePath(); - -protected: - bool updateReadingFromEvent(const sensor_event_t &event, QAccelerometerReading *reading) Q_DECL_OVERRIDE; - -private Q_SLOTS: - void applyAccelerationMode(); -}; - -#endif diff --git a/src/plugins/sensors/blackberry/bbaltimeter.cpp b/src/plugins/sensors/blackberry/bbaltimeter.cpp deleted file mode 100644 index 0ec05df..0000000 --- a/src/plugins/sensors/blackberry/bbaltimeter.cpp +++ /dev/null @@ -1,50 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Research In Motion -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL21$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** 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 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** As a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include "bbaltimeter.h" - -BbAltimeter::BbAltimeter(QSensor *sensor) - : BbSensorBackend<QAltimeterReading>(devicePath(), SENSOR_TYPE_ALTIMETER, sensor) -{ - setDescription(QLatin1String("Altitude in meters relative to mean sea level")); -} - -bool BbAltimeter::updateReadingFromEvent(const sensor_event_t &event, QAltimeterReading *reading) -{ - reading->setAltitude(event.altitude_s.altitude); - return true; -} - -QString BbAltimeter::devicePath() -{ - return QLatin1String("/dev/sensor/alt"); -} diff --git a/src/plugins/sensors/blackberry/bbaltimeter.h b/src/plugins/sensors/blackberry/bbaltimeter.h deleted file mode 100644 index 7e34ead..0000000 --- a/src/plugins/sensors/blackberry/bbaltimeter.h +++ /dev/null @@ -1,52 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Research In Motion -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL21$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** 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 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** As a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#ifndef BBALTIMETER_H -#define BBALTIMETER_H - -#include "bbsensorbackend.h" -#include <qaltimeter.h> - -class BbAltimeter : public BbSensorBackend<QAltimeterReading> -{ - Q_OBJECT - -public: - explicit BbAltimeter(QSensor *sensor); - - static QString devicePath(); - -protected: - bool updateReadingFromEvent(const sensor_event_t &event, QAltimeterReading *reading) Q_DECL_OVERRIDE; -}; - -#endif diff --git a/src/plugins/sensors/blackberry/bbambientlightsensor.cpp b/src/plugins/sensors/blackberry/bbambientlightsensor.cpp deleted file mode 100644 index 4eadefe..0000000 --- a/src/plugins/sensors/blackberry/bbambientlightsensor.cpp +++ /dev/null @@ -1,61 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Research In Motion -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL21$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** 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 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** As a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include "bbambientlightsensor.h" - -BbAmbientLightSensor::BbAmbientLightSensor(QSensor *sensor) - : BbSensorBackend<QAmbientLightReading>(devicePath(), SENSOR_TYPE_LIGHT, sensor) -{ - setDescription(QLatin1String("Ambient light brightness")); -} - -bool BbAmbientLightSensor::updateReadingFromEvent(const sensor_event_t &event, QAmbientLightReading *reading) -{ - const int lightLevelLux = event.light_s.illuminance; - if (lightLevelLux < 10) - reading->setLightLevel(QAmbientLightReading::Dark); - else if (lightLevelLux < 80) - reading->setLightLevel(QAmbientLightReading::Twilight); - else if (lightLevelLux < 400) - reading->setLightLevel(QAmbientLightReading::Light); - else if (lightLevelLux < 2500) - reading->setLightLevel(QAmbientLightReading::Bright); - else - reading->setLightLevel(QAmbientLightReading::Sunny); - - return true; -} - -QString BbAmbientLightSensor::devicePath() -{ - return QLatin1String("/dev/sensor/light"); -} diff --git a/src/plugins/sensors/blackberry/bbambientlightsensor.h b/src/plugins/sensors/blackberry/bbambientlightsensor.h deleted file mode 100644 index 612bda5..0000000 --- a/src/plugins/sensors/blackberry/bbambientlightsensor.h +++ /dev/null @@ -1,52 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Research In Motion -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL21$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** 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 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** As a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#ifndef BBAMBIENTLIGHTSENSOR_H -#define BBAMBIENTLIGHTSENSOR_H - -#include "bbsensorbackend.h" -#include <qambientlightsensor.h> - -class BbAmbientLightSensor : public BbSensorBackend<QAmbientLightReading> -{ - Q_OBJECT - -public: - explicit BbAmbientLightSensor(QSensor *sensor); - - static QString devicePath(); - -protected: - bool updateReadingFromEvent(const sensor_event_t &event, QAmbientLightReading *reading) Q_DECL_OVERRIDE; -}; - -#endif diff --git a/src/plugins/sensors/blackberry/bbcompass.cpp b/src/plugins/sensors/blackberry/bbcompass.cpp deleted file mode 100644 index 1f517bc..0000000 --- a/src/plugins/sensors/blackberry/bbcompass.cpp +++ /dev/null @@ -1,102 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Research In Motion -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL21$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** 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 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** As a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include "bbcompass.h" -#include "bbutil.h" - -using namespace BbUtil; - -BbCompass::BbCompass(QSensor *sensor) -#ifdef HAVE_COMPASS_SENSOR - : BbSensorBackend<QCompassReading>(devicePath(), SENSOR_TYPE_COMPASS, sensor) -#else - : BbSensorBackend<QCompassReading>(devicePath(), SENSOR_TYPE_ROTATION_MATRIX, sensor) -#endif -{ - setDescription(QLatin1String("Azimuth in degrees from magnetic north")); -} - -bool BbCompass::updateReadingFromEvent(const sensor_event_t &event, QCompassReading *reading) -{ - float azimuth; -#ifdef HAVE_COMPASS_SENSOR - azimuth = event.compass_s.azimuth; -#else - float xRad, yRad, zRad; - matrixToEulerZXY(event.rotation_matrix, xRad, yRad, zRad); - azimuth = radiansToDegrees(zRad); - if (azimuth < 0) - azimuth = -azimuth; - else - azimuth = 360.0f - azimuth; -#endif - - if (isAutoAxisRemappingEnabled()) { - azimuth += orientationForRemapping(); - if (azimuth >= 360.0f) - azimuth -= 360.0f; - } - - reading->setAzimuth(azimuth); - - - switch (event.accuracy) { - case SENSOR_ACCURACY_UNRELIABLE: - reading->setCalibrationLevel(0.0f); - break; - case SENSOR_ACCURACY_LOW: - reading->setCalibrationLevel(0.1f); - break; - - // We determined that MEDIUM should map to 1.0, because existing code samples - // show users should pop a calibration screen when seeing < 1.0. The MEDIUM accuracy - // is actually good enough not to require calibration, so we don't want to make it seem - // like it is required artificially. - case SENSOR_ACCURACY_MEDIUM: - reading->setCalibrationLevel(1.0f); - break; - case SENSOR_ACCURACY_HIGH: - reading->setCalibrationLevel(1.0f); - break; - } - - return true; -} - -QString BbCompass::devicePath() -{ -#ifdef HAVE_COMPASS_SENSOR - return QLatin1String("/dev/sensor/compass"); -#else - return QLatin1String("/dev/sensor/rotMatrix"); -#endif -} diff --git a/src/plugins/sensors/blackberry/bbcompass.h b/src/plugins/sensors/blackberry/bbcompass.h deleted file mode 100644 index c51aa44..0000000 --- a/src/plugins/sensors/blackberry/bbcompass.h +++ /dev/null @@ -1,52 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Research In Motion -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL21$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** 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 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** As a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#ifndef BBCOMPASS_H -#define BBCOMPASS_H - -#include "bbsensorbackend.h" -#include <qcompass.h> - -class BbCompass : public BbSensorBackend<QCompassReading> -{ - Q_OBJECT - -public: - explicit BbCompass(QSensor *sensor); - - static QString devicePath(); - -protected: - bool updateReadingFromEvent(const sensor_event_t &event, QCompassReading *reading) Q_DECL_OVERRIDE; -}; - -#endif diff --git a/src/plugins/sensors/blackberry/bbdistancesensor.cpp b/src/plugins/sensors/blackberry/bbdistancesensor.cpp deleted file mode 100644 index 34d6dfb..0000000 --- a/src/plugins/sensors/blackberry/bbdistancesensor.cpp +++ /dev/null @@ -1,50 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014 BlackBerry Limited. All rights reserved. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL21$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** 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 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** As a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include "bbdistancesensor.h" - -BbDistanceSensor::BbDistanceSensor(QSensor *sensor) - : BbSensorBackend<QDistanceReading>(devicePath(), SENSOR_TYPE_PROXIMITY, sensor) -{ - setDescription(QLatin1String("Distance")); -} - -QString BbDistanceSensor::devicePath() -{ - return QLatin1String("/dev/sensor/prox"); -} - -bool BbDistanceSensor::updateReadingFromEvent(const sensor_event_t &event, QDistanceReading *reading) -{ - reading->setDistance(event.proximity_s.distance); - return true; -} diff --git a/src/plugins/sensors/blackberry/bbdistancesensor.h b/src/plugins/sensors/blackberry/bbdistancesensor.h deleted file mode 100644 index abf1bcb..0000000 --- a/src/plugins/sensors/blackberry/bbdistancesensor.h +++ /dev/null @@ -1,52 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014 BlackBerry Limited. All rights reserved. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL21$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** 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 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** As a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#ifndef BBDISTANCESENSOR_H -#define BBDISTANCESENSOR_H - -#include "bbsensorbackend.h" -#include <qdistancesensor.h> - -class BbDistanceSensor : public BbSensorBackend<QDistanceReading> -{ - Q_OBJECT - -public: - explicit BbDistanceSensor(QSensor *sensor); - - static QString devicePath(); - -protected: - bool updateReadingFromEvent(const sensor_event_t &event, QDistanceReading *reading) Q_DECL_OVERRIDE; -}; - -#endif diff --git a/src/plugins/sensors/blackberry/bbguihelper.cpp b/src/plugins/sensors/blackberry/bbguihelper.cpp deleted file mode 100644 index e1b3af9..0000000 --- a/src/plugins/sensors/blackberry/bbguihelper.cpp +++ /dev/null @@ -1,134 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Research In Motion -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL21$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** 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 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** As a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include "bbguihelper.h" - -#include <QtCore/QAbstractEventDispatcher> -#include <QtCore/QCoreApplication> -#include <QtCore/QFile> -#include <QtCore/QTextStream> -#include <bps/navigator.h> - -BbGuiHelper::BbGuiHelper(QObject *parent) - : QObject(parent), - m_currentOrientation(0), - m_applicationActive(true) -{ - readApplicationActiveState(); - readOrientation(); - - QCoreApplication::eventDispatcher()->installNativeEventFilter(this); -} - -BbGuiHelper::~BbGuiHelper() -{ - QCoreApplication::eventDispatcher()->removeNativeEventFilter(this); -} - -int BbGuiHelper::currentOrientation() const -{ - return m_currentOrientation; -} - -bool BbGuiHelper::applicationActive() const -{ - return m_applicationActive; -} - -bool BbGuiHelper::nativeEventFilter(const QByteArray &eventType, void *message, long *result) -{ - Q_UNUSED(result); - Q_UNUSED(eventType); - - bps_event_t * const event = static_cast<bps_event_t *>(message); - if (event && bps_event_get_domain(event) == navigator_get_domain()) { - const int code = bps_event_get_code(event); - if (code == NAVIGATOR_ORIENTATION) { - const int newOrientation = navigator_event_get_orientation_angle(event); - if (newOrientation != m_currentOrientation) { - m_currentOrientation = newOrientation; - emit orientationChanged(); - } - } else if (code == NAVIGATOR_WINDOW_STATE) { - const bool appActive = - (navigator_event_get_window_state(event) == NAVIGATOR_WINDOW_FULLSCREEN); - if (m_applicationActive != appActive) { - m_applicationActive = appActive; - emit applicationActiveChanged(); - } - } - } - - return false; -} - -void BbGuiHelper::readApplicationActiveState() -{ - const QLatin1String fileName("/pps/services/navigator/state"); - QFile navigatorState(fileName); - if (!navigatorState.open(QFile::ReadOnly)) - return; - - const QString separator(QLatin1String("::")); - QTextStream stream(&navigatorState); - Q_FOREVER { - const QString line = stream.readLine(); - if (line.isNull()) - break; - - const int separatorPos = line.indexOf(separator); - if (separatorPos != -1) { - const QString key = line.left(separatorPos); - const QString value = line.mid(separatorPos + separator.length()); - - if (key.endsWith(QLatin1String("fullscreen"))) { - bool ok = false; - const int fullscreenPid = value.toInt(&ok); - if (ok) - m_applicationActive = (fullscreenPid == QCoreApplication::applicationPid()); - break; - } - } - } -} - -void BbGuiHelper::readOrientation() -{ - // There is no API to get the current orientation at the moment. - // Therefore, we assume that the initial orientation that is set in the environment variable - // hasn't changed yet. - // This assumptions don't always hold, but it is the best we got so far. - // The navigator will at least inform us about updates. - const QByteArray orientationText = qgetenv("ORIENTATION"); - if (!orientationText.isEmpty()) - m_currentOrientation = orientationText.toInt(); -} diff --git a/src/plugins/sensors/blackberry/bbguihelper.h b/src/plugins/sensors/blackberry/bbguihelper.h deleted file mode 100644 index ffb5da7..0000000 --- a/src/plugins/sensors/blackberry/bbguihelper.h +++ /dev/null @@ -1,69 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Research In Motion -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL21$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** 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 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** As a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#ifndef BBGUIHELPER_H -#define BBGUIHELPER_H - -#include <QtCore/QAbstractNativeEventFilter> -#include <QtCore/QObject> - -// We can't depend on QtGui in this plugin, only on BPS. -// This class provides replacements for some QtGui functions, implemented using BPS. -class BbGuiHelper : public QObject, public QAbstractNativeEventFilter -{ - Q_OBJECT -public: - explicit BbGuiHelper(QObject *parent = 0); - ~BbGuiHelper(); - - // Orientation 0 is device held in normal position (Blackberry logo readable), then orientation - // increases in 90 degrees steps counter-clockwise, i.e. rotating the device to the left. - // Therefore the range is 0 to 270 degrees. - int currentOrientation() const; - - bool applicationActive() const; - - bool nativeEventFilter(const QByteArray &eventType, void *message, long *result) Q_DECL_OVERRIDE; - -signals: - void orientationChanged(); - void applicationActiveChanged(); - -private: - void readOrientation(); - void readApplicationActiveState(); - - int m_currentOrientation; - bool m_applicationActive; -}; - -#endif diff --git a/src/plugins/sensors/blackberry/bbgyroscope.cpp b/src/plugins/sensors/blackberry/bbgyroscope.cpp deleted file mode 100644 index a97c018..0000000 --- a/src/plugins/sensors/blackberry/bbgyroscope.cpp +++ /dev/null @@ -1,67 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Research In Motion -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL21$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** 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 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** As a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include "bbgyroscope.h" - -#include "bbutil.h" -#include <QtCore/qmath.h> - -using namespace BbUtil; - -BbGyroscope::BbGyroscope(QSensor *sensor) - : BbSensorBackend<QGyroscopeReading>(devicePath(), SENSOR_TYPE_GYROSCOPE, sensor) -{ - setDescription(QLatin1String("Angular velocities around x, y, and z axis in degrees per second")); -} - -bool BbGyroscope::updateReadingFromEvent(const sensor_event_t &event, QGyroscopeReading *reading) -{ - float x = radiansToDegrees(event.motion.dsp.x); - float y = radiansToDegrees(event.motion.dsp.y); - float z = radiansToDegrees(event.motion.dsp.z); - remapAxes(&x, &y, &z); - reading->setX(x); - reading->setY(y); - reading->setZ(z); - - return true; -} - -QString BbGyroscope::devicePath() -{ - return QLatin1String("/dev/sensor/gyro"); -} - -qreal BbGyroscope::convertValue(float valueInRadiansPerSecond) -{ - return radiansToDegrees(valueInRadiansPerSecond); -} diff --git a/src/plugins/sensors/blackberry/bbgyroscope.h b/src/plugins/sensors/blackberry/bbgyroscope.h deleted file mode 100644 index 877fb43..0000000 --- a/src/plugins/sensors/blackberry/bbgyroscope.h +++ /dev/null @@ -1,53 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Research In Motion -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL21$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** 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 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** As a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#ifndef BBGYROSCOPE_H -#define BBGYROSCOPE_H - -#include "bbsensorbackend.h" -#include <qgyroscope.h> - -class BbGyroscope : public BbSensorBackend<QGyroscopeReading> -{ - Q_OBJECT - -public: - explicit BbGyroscope(QSensor *sensor); - - static QString devicePath(); - -protected: - qreal convertValue(float bbValue) Q_DECL_OVERRIDE; - bool updateReadingFromEvent(const sensor_event_t &event, QGyroscopeReading *reading) Q_DECL_OVERRIDE; -}; - -#endif diff --git a/src/plugins/sensors/blackberry/bbholstersensor.cpp b/src/plugins/sensors/blackberry/bbholstersensor.cpp deleted file mode 100644 index 0f302a0..0000000 --- a/src/plugins/sensors/blackberry/bbholstersensor.cpp +++ /dev/null @@ -1,50 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Research In Motion -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL21$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** 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 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** As a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include "bbholstersensor.h" - -BbHolsterSensor::BbHolsterSensor(QSensor *sensor) - : BbSensorBackend<QHolsterReading>(devicePath(), SENSOR_TYPE_HOLSTER, sensor) -{ - setDescription(QLatin1String("Whether the device is holstered or not")); -} - -bool BbHolsterSensor::updateReadingFromEvent(const sensor_event_t &event, QHolsterReading *reading) -{ - reading->setHolstered(event.holster_s.holstered == 1); - return true; -} - -QString BbHolsterSensor::devicePath() -{ - return QLatin1String("/dev/sensor/holster"); -} diff --git a/src/plugins/sensors/blackberry/bbholstersensor.h b/src/plugins/sensors/blackberry/bbholstersensor.h deleted file mode 100644 index 46b22c6..0000000 --- a/src/plugins/sensors/blackberry/bbholstersensor.h +++ /dev/null @@ -1,52 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Research In Motion -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL21$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** 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 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** As a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#ifndef BBHOLSTERSENSOR_H -#define BBHOLSTERSENSOR_H - -#include "bbsensorbackend.h" -#include <qholstersensor.h> - -class BbHolsterSensor : public BbSensorBackend<QHolsterReading> -{ - Q_OBJECT - -public: - explicit BbHolsterSensor(QSensor *sensor); - - static QString devicePath(); - -protected: - bool updateReadingFromEvent(const sensor_event_t &event, QHolsterReading *reading) Q_DECL_OVERRIDE; -}; - -#endif diff --git a/src/plugins/sensors/blackberry/bbirproximitysensor.cpp b/src/plugins/sensors/blackberry/bbirproximitysensor.cpp deleted file mode 100644 index 398d1a4..0000000 --- a/src/plugins/sensors/blackberry/bbirproximitysensor.cpp +++ /dev/null @@ -1,50 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Research In Motion -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL21$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** 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 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** As a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include "bbirproximitysensor.h" - -BbIRProximitySensor::BbIRProximitySensor(QSensor *sensor) - : BbSensorBackend<QIRProximityReading>(devicePath(), SENSOR_TYPE_PROXIMITY, sensor) -{ - setDescription(QLatin1String("IR Proximity")); -} - -bool BbIRProximitySensor::updateReadingFromEvent(const sensor_event_t &event, QIRProximityReading *reading) -{ - reading->setReflectance(1.0f - event.proximity_s.normalized); - return true; -} - -QString BbIRProximitySensor::devicePath() -{ - return QLatin1String("/dev/sensor/prox"); -} diff --git a/src/plugins/sensors/blackberry/bbirproximitysensor.h b/src/plugins/sensors/blackberry/bbirproximitysensor.h deleted file mode 100644 index 7a0515a..0000000 --- a/src/plugins/sensors/blackberry/bbirproximitysensor.h +++ /dev/null @@ -1,52 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Research In Motion -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL21$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** 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 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** As a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#ifndef BBIRPROXIMITYSENSOR_H -#define BBIRPROXIMITYSENSOR_H - -#include "bbsensorbackend.h" -#include <qirproximitysensor.h> - -class BbIRProximitySensor : public BbSensorBackend<QIRProximityReading> -{ - Q_OBJECT - -public: - explicit BbIRProximitySensor(QSensor *sensor); - - static QString devicePath(); - -protected: - bool updateReadingFromEvent(const sensor_event_t &event, QIRProximityReading *reading) Q_DECL_OVERRIDE; -}; - -#endif diff --git a/src/plugins/sensors/blackberry/bblightsensor.cpp b/src/plugins/sensors/blackberry/bblightsensor.cpp deleted file mode 100644 index 5257b6e..0000000 --- a/src/plugins/sensors/blackberry/bblightsensor.cpp +++ /dev/null @@ -1,50 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Research In Motion -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL21$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** 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 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** As a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include "bblightsensor.h" - -BbLightSensor::BbLightSensor(QSensor *sensor) - : BbSensorBackend<QLightReading>(devicePath(), SENSOR_TYPE_LIGHT, sensor) -{ - setDescription(QLatin1String("Light intensity in lux")); -} - -bool BbLightSensor::updateReadingFromEvent(const sensor_event_t &event, QLightReading *reading) -{ - reading->setLux(event.light_s.illuminance); - return true; -} - -QString BbLightSensor::devicePath() -{ - return QLatin1String("/dev/sensor/light"); -} diff --git a/src/plugins/sensors/blackberry/bblightsensor.h b/src/plugins/sensors/blackberry/bblightsensor.h deleted file mode 100644 index de5c917..0000000 --- a/src/plugins/sensors/blackberry/bblightsensor.h +++ /dev/null @@ -1,52 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Research In Motion -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL21$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** 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 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** As a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#ifndef BBLIGHTSENSOR_H -#define BBLIGHTSENSOR_H - -#include "bbsensorbackend.h" -#include <qlightsensor.h> - -class BbLightSensor : public BbSensorBackend<QLightReading> -{ - Q_OBJECT - -public: - explicit BbLightSensor(QSensor *sensor); - - static QString devicePath(); - -protected: - bool updateReadingFromEvent(const sensor_event_t &event, QLightReading *reading) Q_DECL_OVERRIDE; -}; - -#endif diff --git a/src/plugins/sensors/blackberry/bbmagnetometer.cpp b/src/plugins/sensors/blackberry/bbmagnetometer.cpp deleted file mode 100644 index c839d80..0000000 --- a/src/plugins/sensors/blackberry/bbmagnetometer.cpp +++ /dev/null @@ -1,77 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Research In Motion -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL21$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** 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 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** As a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include "bbmagnetometer.h" - -BbMagnetometer::BbMagnetometer(QSensor *sensor) - : BbSensorBackend<QMagnetometerReading>(devicePath(), SENSOR_TYPE_MAGNETOMETER, sensor) -{ - setDescription(QLatin1String("Magnetic flux density in Teslas (T)")); -} - -QString BbMagnetometer::devicePath() -{ - return QLatin1String("/dev/sensor/mag"); -} - -bool BbMagnetometer::updateReadingFromEvent(const sensor_event_t &event, QMagnetometerReading *reading) -{ - float x, y, z; - - switch (event.accuracy) { - case SENSOR_ACCURACY_UNRELIABLE: reading->setCalibrationLevel(0.0f); break; - case SENSOR_ACCURACY_LOW: reading->setCalibrationLevel(0.1f); break; - - // We determined that MEDIUM should map to 1.0, because existing code samples - // show users should pop a calibration screen when seeing < 1.0. The MEDIUM accuracy - // is actually good enough not to require calibration, so we don't want to make it seem - // like it is required artificially. - case SENSOR_ACCURACY_MEDIUM: reading->setCalibrationLevel(1.0f); break; - case SENSOR_ACCURACY_HIGH: reading->setCalibrationLevel(1.0f); break; - } - - x = convertValue(event.motion.dsp.x); - y = convertValue(event.motion.dsp.y); - z = convertValue(event.motion.dsp.z); - - remapAxes(&x, &y, &z); - reading->setX(x); - reading->setY(y); - reading->setZ(z); - return true; -} - -qreal BbMagnetometer::convertValue(float bbValueInMicroTesla) -{ - // Convert from microtesla to tesla - return bbValueInMicroTesla * 1.0e-6; -} diff --git a/src/plugins/sensors/blackberry/bbmagnetometer.h b/src/plugins/sensors/blackberry/bbmagnetometer.h deleted file mode 100644 index 9572fb0..0000000 --- a/src/plugins/sensors/blackberry/bbmagnetometer.h +++ /dev/null @@ -1,53 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Research In Motion -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL21$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** 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 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** As a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#ifndef BBMAGNETOMETER_H -#define BBMAGNETOMETER_H - -#include "bbsensorbackend.h" -#include <qmagnetometer.h> - -class BbMagnetometer : public BbSensorBackend<QMagnetometerReading> -{ - Q_OBJECT - -public: - explicit BbMagnetometer(QSensor *sensor); - - static QString devicePath(); - -protected: - qreal convertValue(float bbValue) Q_DECL_OVERRIDE; - bool updateReadingFromEvent(const sensor_event_t &event, QMagnetometerReading *reading) Q_DECL_OVERRIDE; -}; - -#endif diff --git a/src/plugins/sensors/blackberry/bborientationsensor.cpp b/src/plugins/sensors/blackberry/bborientationsensor.cpp deleted file mode 100644 index aaa4e98..0000000 --- a/src/plugins/sensors/blackberry/bborientationsensor.cpp +++ /dev/null @@ -1,76 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Research In Motion -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL21$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** 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 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** As a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include "bborientationsensor.h" - -BbOrientationSensor::BbOrientationSensor(QSensor *sensor) - : BbSensorBackend<QOrientationReading>(devicePath(), SENSOR_TYPE_ORIENTATION, sensor) -{ - setDescription(QLatin1String("Device orientation")); - - // Orientation rarely changes, so enable skipping of duplicates by default - sensor->setSkipDuplicates(true); -} - -QString BbOrientationSensor::devicePath() -{ - return QLatin1String("/dev/sensor/orientation"); -} - -void BbOrientationSensor::additionalDeviceInit() -{ - // When querying the OS service for the range, it gives us the angles, which we don't need. - // So set the possible enum values of QOrientationReading::Orientation as the output range here. - // By returning false in addDefaultRange(), we skip setting the range from the OS service in the - // base class. - addOutputRange(0, 6, 1); -} - -bool BbOrientationSensor::addDefaultRange() -{ - return false; -} - -bool BbOrientationSensor::updateReadingFromEvent(const sensor_event_t &event, QOrientationReading *reading) -{ - QOrientationReading::Orientation qtOrientation = QOrientationReading::Undefined; - const QByteArray face(event.orientation.face); - if (face == "FACE_UP") qtOrientation = QOrientationReading::FaceUp; - else if (face == "TOP_UP") qtOrientation = QOrientationReading::TopUp; - else if (face == "RIGHT_UP") qtOrientation = QOrientationReading::RightUp; - else if (face == "LEFT_UP") qtOrientation = QOrientationReading::LeftUp; - else if (face == "BOTTOM_UP") qtOrientation = QOrientationReading::TopDown; - else if (face == "FACE_DOWN") qtOrientation = QOrientationReading::FaceDown; - - reading->setOrientation(qtOrientation); - return true; -} diff --git a/src/plugins/sensors/blackberry/bborientationsensor.h b/src/plugins/sensors/blackberry/bborientationsensor.h deleted file mode 100644 index 1a02f9c..0000000 --- a/src/plugins/sensors/blackberry/bborientationsensor.h +++ /dev/null @@ -1,55 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Research In Motion -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL21$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** 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 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** As a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#ifndef BBORIENTATIONSENSOR_H -#define BBORIENTATIONSENSOR_H - -#include "bbsensorbackend.h" -#include <qorientationsensor.h> - -class BbOrientationSensor : public BbSensorBackend<QOrientationReading> -{ - Q_OBJECT - -public: - explicit BbOrientationSensor(QSensor *sensor); - - static QString devicePath(); - - void additionalDeviceInit() Q_DECL_OVERRIDE; - bool addDefaultRange() Q_DECL_OVERRIDE; - -protected: - bool updateReadingFromEvent(const sensor_event_t &event, QOrientationReading *reading) Q_DECL_OVERRIDE; -}; - -#endif diff --git a/src/plugins/sensors/blackberry/bbpressuresensor.cpp b/src/plugins/sensors/blackberry/bbpressuresensor.cpp deleted file mode 100644 index 3f48ff6..0000000 --- a/src/plugins/sensors/blackberry/bbpressuresensor.cpp +++ /dev/null @@ -1,51 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Research In Motion -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL21$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** 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 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** As a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include "bbpressuresensor.h" - -BbPressureSensor::BbPressureSensor(QSensor *sensor) - : BbSensorBackend<QPressureReading>(devicePath(), SENSOR_TYPE_PRESSURE, sensor) -{ - setDescription(QLatin1String("Pressure in Pascals")); -} - -QString BbPressureSensor::devicePath() -{ - return QLatin1String("/dev/sensor/pressure"); -} - -bool BbPressureSensor::updateReadingFromEvent(const sensor_event_t &event, QPressureReading *reading) -{ - reading->setPressure(event.pressure_s.pressure); - reading->setTemperature(event.pressure_s.temperature); - return true; -} diff --git a/src/plugins/sensors/blackberry/bbpressuresensor.h b/src/plugins/sensors/blackberry/bbpressuresensor.h deleted file mode 100644 index 8d29ed6..0000000 --- a/src/plugins/sensors/blackberry/bbpressuresensor.h +++ /dev/null @@ -1,52 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Research In Motion -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL21$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** 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 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** As a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#ifndef BBPRESSURESENSOR_H -#define BBPRESSURESENSOR_H - -#include "bbsensorbackend.h" -#include <qpressuresensor.h> - -class BbPressureSensor : public BbSensorBackend<QPressureReading> -{ - Q_OBJECT - -public: - explicit BbPressureSensor(QSensor *sensor); - - static QString devicePath(); - -protected: - bool updateReadingFromEvent(const sensor_event_t &event, QPressureReading *reading) Q_DECL_OVERRIDE; -}; - -#endif diff --git a/src/plugins/sensors/blackberry/bbproximitysensor.cpp b/src/plugins/sensors/blackberry/bbproximitysensor.cpp deleted file mode 100644 index 0d1a594..0000000 --- a/src/plugins/sensors/blackberry/bbproximitysensor.cpp +++ /dev/null @@ -1,55 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Research In Motion -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL21$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** 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 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** As a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include "bbproximitysensor.h" - -BbProximitySensor::BbProximitySensor(QSensor *sensor) - : BbSensorBackend<QProximityReading>(devicePath(), SENSOR_TYPE_PROXIMITY, sensor) -{ - setDescription(QLatin1String("Proximity")); -} - -QString BbProximitySensor::devicePath() -{ - return QLatin1String("/dev/sensor/prox"); -} - -bool BbProximitySensor::updateReadingFromEvent(const sensor_event_t &event, QProximityReading *reading) -{ - const qreal minProximity = sensor()->outputRanges().first().minimum; - const qreal maxProximity = sensor()->outputRanges().first().maximum; - // An object within 8.0 cm of the sensor is regarded as close. This is the same threshold used - // for face-detect during phone calls on BB10. - const qreal threshold = (maxProximity > 1.0) ? 8.0 : minProximity; - reading->setClose(event.proximity_s.distance <= threshold); - return true; -} diff --git a/src/plugins/sensors/blackberry/bbproximitysensor.h b/src/plugins/sensors/blackberry/bbproximitysensor.h deleted file mode 100644 index 55d4e64..0000000 --- a/src/plugins/sensors/blackberry/bbproximitysensor.h +++ /dev/null @@ -1,52 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Research In Motion -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL21$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** 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 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** As a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#ifndef BBPROXIMITYSENSOR_H -#define BBPROXIMITYSENSOR_H - -#include "bbsensorbackend.h" -#include <qproximitysensor.h> - -class BbProximitySensor : public BbSensorBackend<QProximityReading> -{ - Q_OBJECT - -public: - explicit BbProximitySensor(QSensor *sensor); - - static QString devicePath(); - -protected: - bool updateReadingFromEvent(const sensor_event_t &event, QProximityReading *reading) Q_DECL_OVERRIDE; -}; - -#endif diff --git a/src/plugins/sensors/blackberry/bbrotationsensor.cpp b/src/plugins/sensors/blackberry/bbrotationsensor.cpp deleted file mode 100644 index 2752d91..0000000 --- a/src/plugins/sensors/blackberry/bbrotationsensor.cpp +++ /dev/null @@ -1,83 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Research In Motion -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL21$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** 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 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** As a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include "bbrotationsensor.h" - -#include "bbguihelper.h" -#include "bbutil.h" - -using namespace BbUtil; - -BbRotationSensor::BbRotationSensor(QSensor *sensor) - : BbSensorBackend<QRotationReading>(devicePath(), SENSOR_TYPE_ROTATION_MATRIX, sensor) -{ - setDescription(QLatin1String("Device rotation in degrees")); -} - -QString BbRotationSensor::devicePath() -{ - return QLatin1String("/dev/sensor/rotMatrix"); -} - -void BbRotationSensor::additionalDeviceInit() -{ - addOutputRange(-180, 180, 0 /* ? */); -} - -bool BbRotationSensor::addDefaultRange() -{ - // The range we get from the OS service is only -1 to 1, which are the values of the matrix. - // We need the values of the axes in degrees. - return false; -} - -bool BbRotationSensor::updateReadingFromEvent(const sensor_event_t &event, QRotationReading *reading) -{ - // sensor_event_t has euler angles for a Z-Y'-X'' system, but the QtSensors API - // uses Z-X'-Y''. - // So extract the euler angles using the Z-X'-Y'' system from the matrix. - float xRad, yRad, zRad; - float mappedRotationMatrix[3*3]; - remapMatrix(event.rotation_matrix, mappedRotationMatrix); - matrixToEulerZXY(mappedRotationMatrix, xRad, yRad, zRad); - - reading->setFromEuler(radiansToDegrees(xRad), - radiansToDegrees(yRad), - radiansToDegrees(zRad)); - - return true; -} - -qreal BbRotationSensor::convertValue(float bbValueInRad) -{ - return radiansToDegrees(bbValueInRad); -} diff --git a/src/plugins/sensors/blackberry/bbrotationsensor.h b/src/plugins/sensors/blackberry/bbrotationsensor.h deleted file mode 100644 index 9dc6e03..0000000 --- a/src/plugins/sensors/blackberry/bbrotationsensor.h +++ /dev/null @@ -1,55 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Research In Motion -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL21$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** 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 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** As a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#ifndef BBROTATIONSENSOR_H -#define BBROTATIONSENSOR_H - -#include "bbsensorbackend.h" -#include <qrotationsensor.h> - -class BbRotationSensor : public BbSensorBackend<QRotationReading> -{ - Q_OBJECT - -public: - explicit BbRotationSensor(QSensor *sensor); - - static QString devicePath(); - -protected: - void additionalDeviceInit() Q_DECL_OVERRIDE; - bool addDefaultRange() Q_DECL_OVERRIDE; - qreal convertValue(float bbValue) Q_DECL_OVERRIDE; - bool updateReadingFromEvent(const sensor_event_t &event, QRotationReading *reading) Q_DECL_OVERRIDE; -}; - -#endif diff --git a/src/plugins/sensors/blackberry/bbsensorbackend.cpp b/src/plugins/sensors/blackberry/bbsensorbackend.cpp deleted file mode 100644 index bfd4daf..0000000 --- a/src/plugins/sensors/blackberry/bbsensorbackend.cpp +++ /dev/null @@ -1,446 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Research In Motion -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL21$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** 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 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** As a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include "bbsensorbackend.h" - -#include "bbguihelper.h" -#include <QtCore/QDebug> -#include <QtCore/qmath.h> -#include <fcntl.h> - -static const int microSecondsPerSecond = 1000 * 1000; -static const int defaultBufferSize = 10; - -static int microSecondsToHertz(uint microSeconds) -{ - return microSecondsPerSecond / microSeconds; -} - -static uint hertzToMicroSeconds(int hertz) -{ - return microSecondsPerSecond / hertz; -} - -static void remapMatrix(const float inputMatrix[3*3], - const float mappingMatrix[4], - float outputMatrix[3*3]) -{ - int i,j,k; - - for (i = 0; i < 3; i++) { - for (j = 0; j < 2; j++) { //only goto 2 because last column stays unchanged - - outputMatrix[i*3+j] = 0; - - for (k = 0; k < 2; k++) { //only goto 2 because we know rotation matrix is zero in bottom row - outputMatrix[i*3+j] += inputMatrix[i*3+k] * mappingMatrix[k*2+j]; - } - } - - outputMatrix[i*3+2] = inputMatrix[i*3+2]; - } -} - -BbSensorBackendBase::BbSensorBackendBase(const QString &devicePath, sensor_type_e sensorType, - QSensor *sensor) - : QSensorBackend(sensor), m_deviceFile(devicePath), m_sensorType(sensorType), m_guiHelper(0), - m_started(false), m_applyingBufferSize(false) -{ - m_mappingMatrix[0] = m_mappingMatrix[3] = 1; - m_mappingMatrix[1] = m_mappingMatrix[2] = 0; - connect(sensor, SIGNAL(alwaysOnChanged()), this, SLOT(applyAlwaysOnProperty())); - connect(sensor, SIGNAL(bufferSizeChanged(int)), this, SLOT(applyBuffering())); - connect(sensor, SIGNAL(userOrientationChanged(int)), this, SLOT(updateOrientation())); - - // Set some sensible default values - sensor->setEfficientBufferSize(defaultBufferSize); - sensor->setMaxBufferSize(defaultBufferSize); -} - -BbGuiHelper *BbSensorBackendBase::guiHelper() const -{ - return m_guiHelper; -} - -QFile &BbSensorBackendBase::deviceFile() -{ - return m_deviceFile; -} - -sensor_type_e BbSensorBackendBase::sensorType() const -{ - return m_sensorType; -} - -void BbSensorBackendBase::setDevice(const QString &deviceFile, sensor_type_e sensorType) -{ - if (deviceFile != m_deviceFile.fileName()) { - setPaused(true); - delete m_socketNotifier.take(); - m_deviceFile.close(); - - m_sensorType = sensorType; - m_deviceFile.setFileName(deviceFile); - initSensorInfo(); - if (m_started) - start(); // restart with new device file - } -} - -void BbSensorBackendBase::initSensorInfo() -{ - if (!m_deviceFile.open(QFile::ReadOnly | QFile::Unbuffered)) { - qDebug() << "Failed to open sensor" << m_deviceFile.fileName() - << ":" << m_deviceFile.errorString(); - } else { - - // Explicitly switch to non-blocking mode, otherwise read() will wait until new sensor - // data is available, and we have no way to check if there is more data or not (bytesAvailable() - // does not work for unbuffered mode) - const int oldFlags = fcntl(m_deviceFile.handle(), F_GETFL); - if (fcntl(m_deviceFile.handle(), F_SETFL, oldFlags | O_NONBLOCK) == -1) { - perror(QString::fromLatin1("Starting sensor %1 failed, fcntl() returned -1") - .arg(m_deviceFile.fileName()).toLocal8Bit()); - sensorError(errno); - stop(); - return; - } - - sensor_devctl_info_u deviceInfo; - const int result = devctl(m_deviceFile.handle(), DCMD_SENSOR_INFO, &deviceInfo, - sizeof(deviceInfo), NULL); - if (result != EOK) { - perror(QString::fromLatin1("Querying sensor info for %1 failed") - .arg(m_deviceFile.fileName()).toLocal8Bit()); - } else { - if (addDefaultRange()) { - addOutputRange(convertValue(deviceInfo.rx.info.range_min), - convertValue(deviceInfo.rx.info.range_max), - convertValue(deviceInfo.rx.info.resolution)); - } - - if (deviceInfo.rx.info.delay_max > 0 && deviceInfo.rx.info.delay_min > 0) { - // Min and max intentionally swapped here, as the minimum delay is the maximum rate - addDataRate(microSecondsToHertz(deviceInfo.rx.info.delay_max), - microSecondsToHertz(deviceInfo.rx.info.delay_min)); - } - } - additionalDeviceInit(); - - // Instead of closing the device here and opening it again in start(), just pause the sensor. - // This avoids an expensive close() and open() call. - setPaused(true); - - m_socketNotifier.reset(new QSocketNotifier(m_deviceFile.handle(), QSocketNotifier::Read)); - m_socketNotifier->setEnabled(false); - connect(m_socketNotifier.data(), SIGNAL(activated(int)), this, SLOT(dataAvailable())); - } -} - -void BbSensorBackendBase::setGuiHelper(BbGuiHelper *guiHelper) -{ - Q_ASSERT(!m_guiHelper); - m_guiHelper = guiHelper; - connect(m_guiHelper, SIGNAL(applicationActiveChanged()), this, SLOT(updatePauseState())); - connect(guiHelper, SIGNAL(orientationChanged()), this, SLOT(updateOrientation())); - updateOrientation(); -} - -void BbSensorBackendBase::additionalDeviceInit() -{ -} - -bool BbSensorBackendBase::addDefaultRange() -{ - return true; -} - -qreal BbSensorBackendBase::convertValue(float bbValue) -{ - return bbValue; -} - -bool BbSensorBackendBase::isAutoAxisRemappingEnabled() const -{ - return sensor()->isFeatureSupported(QSensor::AxesOrientation) && - sensor()->axesOrientationMode() != QSensor::FixedOrientation; -} - -void BbSensorBackendBase::remapMatrix(const float inputMatrix[], float outputMatrix[]) -{ - if (!isAutoAxisRemappingEnabled() || orientationForRemapping() == 0) { - memcpy(outputMatrix, inputMatrix, sizeof(float) * 9); - return; - } - - ::remapMatrix(inputMatrix, m_mappingMatrix, outputMatrix); -} - -void BbSensorBackendBase::remapAxes(float *x, float *y, float *z) -{ - Q_UNUSED(z); - Q_ASSERT(x && y); - if (!isAutoAxisRemappingEnabled() || orientationForRemapping() == 0) - return; - - const int angle = orientationForRemapping(); - - const float oldX = *x; - const float oldY = *y; - - switch (angle) { - case 90: - *x = -oldY; - *y = oldX; - break; - case 180: - *x = -oldX; - *y = -oldY; - break; - case 270: - *x = oldY; - *y = -oldX; - break; - } -} - -void BbSensorBackendBase::start() -{ - Q_ASSERT(m_guiHelper); - - if (!m_deviceFile.isOpen() || !setPaused(false)) { - qDebug() << "Starting sensor" << m_deviceFile.fileName() - << "failed:" << m_deviceFile.errorString(); - sensorError(m_deviceFile.error()); - return; - } - m_started = true; - - const int rateInHertz = sensor()->dataRate(); - if (rateInHertz != 0) { - const uint rateInMicroseconds = hertzToMicroSeconds(rateInHertz); - sensor_devctl_rate_u deviceRate; - deviceRate.tx.rate = rateInMicroseconds; - const int result = devctl(m_deviceFile.handle(), DCMD_SENSOR_RATE, &deviceRate, - sizeof(deviceRate), NULL); - if (result != EOK) { - sensor()->setDataRate(0); - perror(QString::fromLatin1("Setting sensor rate for %1 failed") - .arg(m_deviceFile.fileName()).toLocal8Bit()); - } else { - if (deviceRate.rx.rate > 0) - sensor()->setDataRate(microSecondsToHertz(deviceRate.rx.rate)); - else - sensor()->setDataRate(0); - } - } - - // Enable/disable duplicate skipping - sensor_devctl_skipdupevent_u deviceSkip; - deviceSkip.tx.enable = sensor()->skipDuplicates(); - const int result = devctl(deviceFile().handle(), DCMD_SENSOR_SKIPDUPEVENT, &deviceSkip, - sizeof(deviceSkip), NULL); - if (result != EOK) { - perror(QString::fromLatin1("Setting duplicate skipping for %1 failed") - .arg(m_deviceFile.fileName()).toLocal8Bit()); - } - - applyBuffering(); - applyAlwaysOnProperty(); -} - -void BbSensorBackendBase::stop() -{ - setPaused(true); - m_started = false; -} - -bool BbSensorBackendBase::isFeatureSupported(QSensor::Feature feature) const -{ - switch (feature) { - case QSensor::AxesOrientation: - return (sensorType() == SENSOR_TYPE_ACCELEROMETER || sensorType() == SENSOR_TYPE_MAGNETOMETER || - sensorType() == SENSOR_TYPE_GYROSCOPE || sensorType() == SENSOR_TYPE_GRAVITY || - sensorType() == SENSOR_TYPE_LINEAR_ACCEL || sensorType() == SENSOR_TYPE_ROTATION_VECTOR || - sensorType() == SENSOR_TYPE_ROTATION_MATRIX || sensorType() == SENSOR_TYPE_AZIMUTH_PITCH_ROLL); - case QSensor::AlwaysOn: - case QSensor::Buffering: - case QSensor::AccelerationMode: - case QSensor::SkipDuplicates: - case QSensor::PressureSensorTemperature: - return true; - case QSensor::GeoValues: - case QSensor::Reserved: - case QSensor::FieldOfView: - break; - } - - return false; -} - -void BbSensorBackendBase::dataAvailable() -{ - if (!m_started) { - // Spurious dataAvailable() call, drain the device file of data. We also disable - // the socket notifier for this, so this is just added safety here. - m_deviceFile.readAll(); - return; - } - - Q_FOREVER { - sensor_event_t event; - const qint64 numBytes = m_deviceFile.read(reinterpret_cast<char *>(&event), - sizeof(sensor_event_t)); - if (numBytes == -1) { - break; - } else if (numBytes == sizeof(sensor_event_t)) { - processEvent(event); - } else { - qDebug() << "Reading sensor event data for" << m_deviceFile.fileName() - << "failed (unexpected data size):" << m_deviceFile.errorString(); - } - } -} - -void BbSensorBackendBase::applyAlwaysOnProperty() -{ - if (!m_deviceFile.isOpen() || !m_started) - return; - - sensor_devctl_bkgrnd_u bgState; - bgState.tx.enable = sensor()->isAlwaysOn() ? 1 : 0; - - const int result = devctl(m_deviceFile.handle(), DCMD_SENSOR_BKGRND, &bgState, sizeof(bgState), NULL); - if (result != EOK) { - perror(QString::fromLatin1("Setting sensor always on for %1 failed") - .arg(m_deviceFile.fileName()).toLocal8Bit()); - } - - // We might need to pause now - updatePauseState(); -} - -void BbSensorBackendBase::applyBuffering() -{ - if (!m_deviceFile.isOpen() || !m_started || m_applyingBufferSize) - return; - - // Flag to prevent recursion. We call setBufferSize() below, and because of the changed signal, - // we might end up in this slot again. - // The call to setBufferSize() is needed since the requested buffer size is most likely different - // from the actual buffer size that will be used. - m_applyingBufferSize = true; - - const bool enableBuffering = sensor()->bufferSize() > 1; - sensor_devctl_queue_u queueControl; - queueControl.tx.enable = enableBuffering ? 1 : 0; - const int result = devctl(m_deviceFile.handle(), DCMD_SENSOR_QUEUE, &queueControl, sizeof(queueControl), NULL); - if (result != EOK) { - perror(QString::fromLatin1("Enabling sensor queuing for %1 failed") - .arg(m_deviceFile.fileName()).toLocal8Bit()); - } else { - if (enableBuffering) { - int actualBufferSize = queueControl.rx.size; - - // Some firmware versions don't report the buffer size correctly. Simply pretend the - // buffer size is the same as the requested buffer size, as setting the buffer size to - // 1 here would seem as if buffering were disabled. - if (actualBufferSize == 1) - actualBufferSize = sensor()->bufferSize(); - - sensor()->setBufferSize(actualBufferSize); - sensor()->setEfficientBufferSize(actualBufferSize); - sensor()->setMaxBufferSize(actualBufferSize); - } else { - sensor()->setBufferSize(1); - sensor()->setEfficientBufferSize(defaultBufferSize); - sensor()->setMaxBufferSize(defaultBufferSize); - } - } - m_applyingBufferSize = false; -} - -bool BbSensorBackendBase::setPaused(bool paused) -{ - if (!m_deviceFile.isOpen()) - return false; - - sensor_devctl_enable_u enableState; - enableState.tx.enable = paused ? 0 : 1; - - if (m_socketNotifier) - m_socketNotifier->setEnabled(!paused); - - const int result = devctl(m_deviceFile.handle(), DCMD_SENSOR_ENABLE, &enableState, sizeof(enableState), NULL); - if (result != EOK) { - perror(QString::fromLatin1("Setting sensor enabled (%1) for %2 failed") - .arg(paused) - .arg(m_deviceFile.fileName()).toLocal8Bit()); - return false; - } - - return true; -} - -void BbSensorBackendBase::updatePauseState() -{ - if (!m_started) - return; - - setPaused(!sensor()->isAlwaysOn() && !m_guiHelper->applicationActive()); -} - -void BbSensorBackendBase::updateOrientation() -{ - const int rotationAngle = orientationForRemapping(); - - m_mappingMatrix[0] = cos(rotationAngle*M_PI/180); - m_mappingMatrix[1] = sin(rotationAngle*M_PI/180); - m_mappingMatrix[2] = -sin(rotationAngle*M_PI/180); - m_mappingMatrix[3] = cos(rotationAngle*M_PI/180); - - if (sensor()->isFeatureSupported(QSensor::AxesOrientation)) - sensor()->setCurrentOrientation(rotationAngle); -} - -int BbSensorBackendBase::orientationForRemapping() const -{ - if (!sensor()->isFeatureSupported(QSensor::AxesOrientation)) - return 0; - - switch (sensor()->axesOrientationMode()) { - default: - case QSensor::FixedOrientation: return 0; - case QSensor::AutomaticOrientation: return guiHelper()->currentOrientation(); - case QSensor::UserOrientation: return sensor()->userOrientation(); - } -} diff --git a/src/plugins/sensors/blackberry/bbsensorbackend.h b/src/plugins/sensors/blackberry/bbsensorbackend.h deleted file mode 100644 index 858b40a..0000000 --- a/src/plugins/sensors/blackberry/bbsensorbackend.h +++ /dev/null @@ -1,141 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Research In Motion -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL21$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** 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 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** As a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#ifndef BBSENSORBACKEND_H -#define BBSENSORBACKEND_H - -#include <qsensorbackend.h> -#include <QtCore/QFile> -#include <QtCore/QSocketNotifier> - -#include <sensor/sensor.h> -#include <devctl.h> -#include <errno.h> - -class BbGuiHelper; - -class BbSensorBackendBase : public QSensorBackend -{ - Q_OBJECT - -public: - BbSensorBackendBase(const QString &devicePath, sensor_type_e sensorType, QSensor *sensor); - - void initSensorInfo(); - void setGuiHelper(BbGuiHelper *guiHelper); - - void start() Q_DECL_OVERRIDE; - void stop() Q_DECL_OVERRIDE; - bool isFeatureSupported(QSensor::Feature feature) const Q_DECL_OVERRIDE; - -protected: - BbGuiHelper *guiHelper() const; - QFile& deviceFile(); - sensor_type_e sensorType() const; - int orientationForRemapping() const; - - void setDevice(const QString &deviceFile, sensor_type_e sensorType); - - // This is called while the device file is open during initialization and gives a subclass - // an opportunity to do additional initialization. - virtual void additionalDeviceInit(); - - // If true is returned here, initSensorInfo() will read the output range from the OS sensor - // service and pass it to the QtSensor API. - virtual bool addDefaultRange(); - - // Converts a value from units of the OS sensor service to units needed by the QtSensors API. - // This is used in initSensorInfo(), where the output range is read from the backend and passed - // on to the QtSensors side. - // One example is the magnetometer: The OS sensor service returns units in microtesla, whereas - // QtSensors expects tesla. This function would therefore convert from microtesla to tesla. - virtual qreal convertValue(float bbValue); - - bool isAutoAxisRemappingEnabled() const; - - // These functions will automatically remap the matrix or the axes if auto axes remapping is - // enabled - void remapMatrix(const float inputMatrix[3*3], float outputMatrix[3*3]); - void remapAxes(float *x, float *y, float *z); - - virtual void processEvent(const sensor_event_t &sensorEvent) = 0; - -private slots: - void dataAvailable(); - void applyAlwaysOnProperty(); - void applyBuffering(); - bool setPaused(bool paused); - void updatePauseState(); - void updateOrientation(); - -private: - QFile m_deviceFile; - QScopedPointer<QSocketNotifier> m_socketNotifier; - sensor_type_e m_sensorType; - BbGuiHelper *m_guiHelper; - float m_mappingMatrix[4]; - bool m_started; - bool m_applyingBufferSize; -}; - -template<class SensorReading> -class BbSensorBackend : public BbSensorBackendBase -{ -public: - BbSensorBackend(const QString &devicePath, sensor_type_e sensorType, QSensor *sensor) - : BbSensorBackendBase(devicePath, sensorType, sensor) - { - setReading(&m_reading); - } - -protected: - virtual bool updateReadingFromEvent(const sensor_event_t &sensorEvent, SensorReading *reading) = 0; - -private: - void processEvent(const sensor_event_t &sensorEvent) - { - // There may be "non-sensor" event types added later for housekeeping, so we have to check - // if the senor type matches the expected value - if (sensorEvent.type != sensorType()) - return; - - if (updateReadingFromEvent(sensorEvent, &m_reading)) { - // The OS timestamp is in nanoseconds, QtSensors expects microseconds - m_reading.setTimestamp(sensorEvent.timestamp / 1000); - newReadingAvailable(); - } - } - - SensorReading m_reading; -}; - -#endif diff --git a/src/plugins/sensors/blackberry/bbtemperaturesensor.cpp b/src/plugins/sensors/blackberry/bbtemperaturesensor.cpp deleted file mode 100644 index d2ad5dd..0000000 --- a/src/plugins/sensors/blackberry/bbtemperaturesensor.cpp +++ /dev/null @@ -1,52 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Research In Motion -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL21$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** 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 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** As a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include "bbtemperaturesensor.h" - -BbTemperatureSensor::BbTemperatureSensor(QSensor *sensor) - : BbSensorBackend<QAmbientTemperatureReading>(devicePath(), SENSOR_TYPE_TEMPERATURE, sensor) -{ - setDescription(QLatin1String("Temperature in degrees Celsius")); -} - -QString BbTemperatureSensor::devicePath() -{ - return QLatin1String("/dev/sensor/temp"); -} - -bool BbTemperatureSensor::updateReadingFromEvent(const sensor_event_t &event, QAmbientTemperatureReading *reading) -{ - // TODO: I was unable to test this since the device I was testing this with did not have - // a temperature sensor. Verify that this works and check that the units are correct. - reading->setTemperature(event.temperature_s.temperature); - return true; -} diff --git a/src/plugins/sensors/blackberry/bbtemperaturesensor.h b/src/plugins/sensors/blackberry/bbtemperaturesensor.h deleted file mode 100644 index 6e05f3d..0000000 --- a/src/plugins/sensors/blackberry/bbtemperaturesensor.h +++ /dev/null @@ -1,52 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Research In Motion -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL21$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** 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 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** As a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#ifndef BBTEMPERATURESENSOR_H -#define BBTEMPERATURESENSOR_H - -#include "bbsensorbackend.h" -#include <qambienttemperaturesensor.h> - -class BbTemperatureSensor : public BbSensorBackend<QAmbientTemperatureReading> -{ - Q_OBJECT - -public: - explicit BbTemperatureSensor(QSensor *sensor); - - static QString devicePath(); - -protected: - bool updateReadingFromEvent(const sensor_event_t &event, QAmbientTemperatureReading *reading); -}; - -#endif diff --git a/src/plugins/sensors/blackberry/bbutil.cpp b/src/plugins/sensors/blackberry/bbutil.cpp deleted file mode 100644 index 301872d..0000000 --- a/src/plugins/sensors/blackberry/bbutil.cpp +++ /dev/null @@ -1,74 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Research In Motion -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL21$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** 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 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** As a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include "bbutil.h" - -#include <QtCore/qmath.h> - -namespace BbUtil { - -static float getMatrixElement(const float matrix[3*3], int index0, int index1) -{ - return matrix[index0 * 3 + index1]; -} - -void matrixToEulerZXY(const float matrix[3*3], - float &thetaX, float &thetaY, float& thetaZ) -{ - thetaX = asin( getMatrixElement(matrix, 2, 1)); - if ( thetaX < M_PI_2 ) { - if ( thetaX > -M_PI_2 ) { - thetaZ = atan2( -getMatrixElement(matrix, 0, 1), - getMatrixElement(matrix, 1, 1) ); - thetaY = atan2( -getMatrixElement(matrix, 2, 0), - getMatrixElement(matrix, 2, 2) ); - } else { - // Not a unique solution - thetaZ = -atan2( getMatrixElement(matrix, 0, 2), - getMatrixElement(matrix, 0, 0) ); - thetaY = 0.0; - } - } else { - // Not a unique solution - thetaZ = atan2( getMatrixElement(matrix, 0, 2), - getMatrixElement(matrix, 0, 0) ); - thetaY = 0.0; - } -} - -qreal radiansToDegrees(qreal radians) -{ - static const qreal radToDeg = 180.0f / M_PI; - return radians * radToDeg; -} - -} diff --git a/src/plugins/sensors/blackberry/bbutil.h b/src/plugins/sensors/blackberry/bbutil.h deleted file mode 100644 index 79c75de..0000000 --- a/src/plugins/sensors/blackberry/bbutil.h +++ /dev/null @@ -1,45 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Research In Motion -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL21$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** 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 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** As a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#ifndef BBUTIL_H -#define BBUTIL_H - -#include <QtCore/qglobal.h> - -namespace BbUtil { - -void matrixToEulerZXY(const float matrix[3*3], float &thetaX, float &thetaY, float& thetaZ); -qreal radiansToDegrees(qreal radians); - -} - -#endif diff --git a/src/plugins/sensors/blackberry/blackberry.pro b/src/plugins/sensors/blackberry/blackberry.pro deleted file mode 100644 index 84437a8..0000000 --- a/src/plugins/sensors/blackberry/blackberry.pro +++ /dev/null @@ -1,59 +0,0 @@ -TARGET = qtsensors_blackberry -QT = sensors core -DEFINES += QT_NO_CAST_FROM_ASCII QT_NO_CAST_TO_ASCII - -PLUGIN_TYPE = sensors -PLUGIN_CLASS_NAME = BbSensorPlugin -load(qt_plugin) - -config_bbsensor_compass { - DEFINES += HAVE_COMPASS_SENSOR -} - -config_bbsensor_holster { - DEFINES += HAVE_HOLSTER_SENSOR -} - -HEADERS += bbsensorbackend.h \ - bbaccelerometer.h \ - bbaltimeter.h \ - bbambientlightsensor.h \ - bbcompass.h \ - bbdistancesensor.h \ - bbgyroscope.h \ - bbirproximitysensor.h \ - bblightsensor.h \ - bbmagnetometer.h \ - bborientationsensor.h \ - bbpressuresensor.h \ - bbproximitysensor.h \ - bbrotationsensor.h \ - bbtemperaturesensor.h \ - bbguihelper.h \ - bbutil.h - -SOURCES += bbsensorbackend.cpp \ - bbaccelerometer.cpp \ - bbaltimeter.cpp \ - bbambientlightsensor.cpp \ - bbcompass.cpp \ - bbdistancesensor.cpp \ - bbgyroscope.cpp \ - bbirproximitysensor.cpp \ - bblightsensor.cpp \ - bbmagnetometer.cpp \ - bborientationsensor.cpp \ - bbpressuresensor.cpp \ - bbproximitysensor.cpp \ - bbrotationsensor.cpp \ - bbtemperaturesensor.cpp \ - bbguihelper.cpp \ - bbutil.cpp \ - main.cpp - -config_bbsensor_holster { - HEADERS += bbholstersensor.h - SOURCES += bbholstersensor.cpp -} - -OTHER_FILES = plugin.json diff --git a/src/plugins/sensors/blackberry/main.cpp b/src/plugins/sensors/blackberry/main.cpp deleted file mode 100644 index d21fc12..0000000 --- a/src/plugins/sensors/blackberry/main.cpp +++ /dev/null @@ -1,165 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Research In Motion -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL21$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** 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 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** As a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include "bbaccelerometer.h" -#include "bbaltimeter.h" -#include "bbambientlightsensor.h" -#include "bbcompass.h" -#include "bbgyroscope.h" -#ifdef HAVE_HOLSTER_SENSOR -#include "bbholstersensor.h" -#endif -#include "bbirproximitysensor.h" -#include "bblightsensor.h" -#include "bbmagnetometer.h" -#include "bborientationsensor.h" -#include "bbpressuresensor.h" -#include "bbproximitysensor.h" -#include "bbrotationsensor.h" -#include "bbtemperaturesensor.h" -#include "bbdistancesensor.h" -#include "bbguihelper.h" - -#include <qsensormanager.h> -#include <qsensorplugin.h> - -static const char *bbAccelerometerId = "bbAccelerometer"; -static const char *bbAltitmeterId = "bbAltimeter"; -static const char *bbAmbientLightSensorId = "bbAmbientLightSensor"; -static const char *bbCompassId = "bbCompass"; -static const char *bbGyroscopeId = "bbGyroscope"; -#ifdef HAVE_HOLSTER_SENSOR -static const char *bbHolsterSensorId = "bbHolsterSensor"; -#endif -static const char *bbIRProximitySensorId = "bbIRProximitySensor"; -static const char *bbLightSensorId = "bbLightSensor"; -static const char *bbMagnetometerId = "bbMagnetometer"; -static const char *bbOrientationSensorId = "bbOrientationSensor"; -static const char *bbPressureSensorId = "bbPressureSensor"; -static const char *bbProximitySensorId = "bbProximitySensor"; -static const char *bbRotationSensorId = "bbRotationSensor"; -static const char *bbTemperatureSensorId = "bbTemperatureSensor"; -static const char *bbDistanceSensorId = "bbDistanceSensor"; - -class BbSensorPlugin : public QObject, public QSensorPluginInterface, public QSensorBackendFactory -{ - Q_OBJECT - Q_PLUGIN_METADATA(IID "com.qt-project.Qt.QSensorPluginInterface/1.0" FILE "plugin.json") - Q_INTERFACES(QSensorPluginInterface) - -public: - void registerSensors() Q_DECL_OVERRIDE - { - if (sensorSupported(BbAccelerometer::devicePath())) - QSensorManager::registerBackend(QAccelerometer::type, bbAccelerometerId, this); - if (sensorSupported(BbAltimeter::devicePath())) - QSensorManager::registerBackend(QAltimeter::type, bbAltitmeterId, this); - if (sensorSupported(BbAmbientLightSensor::devicePath())) - QSensorManager::registerBackend(QAmbientLightSensor::type, bbAmbientLightSensorId, this); - if (sensorSupported(BbCompass::devicePath())) - QSensorManager::registerBackend(QCompass::type, bbCompassId, this); - if (sensorSupported(BbGyroscope::devicePath())) - QSensorManager::registerBackend(QGyroscope::type, bbGyroscopeId, this); -#ifdef HAVE_HOLSTER_SENSOR - if (sensorSupported(BbHolsterSensor::devicePath())) - QSensorManager::registerBackend(QHolsterSensor::type, bbHolsterSensorId, this); -#endif - if (sensorSupported(BbIRProximitySensor::devicePath())) - QSensorManager::registerBackend(QIRProximitySensor::type, bbIRProximitySensorId, this); - if (sensorSupported(BbLightSensor::devicePath())) - QSensorManager::registerBackend(QLightSensor::type, bbLightSensorId, this); - if (sensorSupported(BbMagnetometer::devicePath())) - QSensorManager::registerBackend(QMagnetometer::type, bbMagnetometerId, this); - if (sensorSupported(BbOrientationSensor::devicePath())) - QSensorManager::registerBackend(QOrientationSensor::type, bbOrientationSensorId, this); - if (sensorSupported(BbPressureSensor::devicePath())) - QSensorManager::registerBackend(QPressureSensor::type, bbPressureSensorId, this); - if (sensorSupported(BbProximitySensor::devicePath())) - QSensorManager::registerBackend(QProximitySensor::type, bbProximitySensorId, this); - if (sensorSupported(BbRotationSensor::devicePath())) - QSensorManager::registerBackend(QRotationSensor::type, bbRotationSensorId, this); - if (sensorSupported(BbTemperatureSensor::devicePath())) - QSensorManager::registerBackend(QAmbientTemperatureSensor::type, bbTemperatureSensorId, this); - if (sensorSupported(BbDistanceSensor::devicePath())) - QSensorManager::registerBackend(QDistanceSensor::type, bbDistanceSensorId, this); - } - - QSensorBackend *createBackend(QSensor *sensor) Q_DECL_OVERRIDE - { - BbSensorBackendBase *backend = 0; - if (sensor->identifier() == bbAccelerometerId) - backend = new BbAccelerometer(sensor); - if (sensor->identifier() == bbAltitmeterId) - backend = new BbAltimeter(sensor); - if (sensor->identifier() == bbAmbientLightSensorId) - backend = new BbAmbientLightSensor(sensor); - if (sensor->identifier() == bbCompassId) - backend = new BbCompass(sensor); - if (sensor->identifier() == bbGyroscopeId) - backend = new BbGyroscope(sensor); -#ifdef HAVE_HOLSTER_SENSOR - if (sensor->identifier() == bbHolsterSensorId) - backend = new BbHolsterSensor(sensor); -#endif - if (sensor->identifier() == bbIRProximitySensorId) - backend = new BbIRProximitySensor(sensor); - if (sensor->identifier() == bbLightSensorId) - backend = new BbLightSensor(sensor); - if (sensor->identifier() == bbMagnetometerId) - backend = new BbMagnetometer(sensor); - if (sensor->identifier() == bbOrientationSensorId) - backend = new BbOrientationSensor(sensor); - if (sensor->identifier() == bbPressureSensorId) - backend = new BbPressureSensor(sensor); - if (sensor->identifier() == bbProximitySensorId) - backend = new BbProximitySensor(sensor); - if (sensor->identifier() == bbRotationSensorId) - backend = new BbRotationSensor(sensor); - if (sensor->identifier() == bbTemperatureSensorId) - backend = new BbTemperatureSensor(sensor); - if (sensor->identifier() == bbDistanceSensorId) - backend = new BbDistanceSensor(sensor); - backend->initSensorInfo(); - backend->setGuiHelper(&m_guiHelper); - return backend; - } - -private: - bool sensorSupported(const QString &devicePath) - { - return QFile::exists(devicePath); - } - - BbGuiHelper m_guiHelper; -}; - -#include "main.moc" diff --git a/src/plugins/sensors/blackberry/plugin.json b/src/plugins/sensors/blackberry/plugin.json deleted file mode 100644 index 5350abb..0000000 --- a/src/plugins/sensors/blackberry/plugin.json +++ /dev/null @@ -1 +0,0 @@ -{ "Keys": [ "blackberry" ] } diff --git a/src/plugins/sensors/generic/generic.pro b/src/plugins/sensors/generic/generic.pro index 9226cab..cdb9300 100644 --- a/src/plugins/sensors/generic/generic.pro +++ b/src/plugins/sensors/generic/generic.pro @@ -11,16 +11,14 @@ SOURCES += main.cpp\ generictiltsensor.cpp DEFINES += QTSENSORS_GENERICTILTSENSOR -!blackberry { - HEADERS += genericorientationsensor.h\ - genericalssensor.h +HEADERS += genericorientationsensor.h\ + genericalssensor.h - SOURCES += genericorientationsensor.cpp\ - genericalssensor.cpp - DEFINES += QTSENSORS_GENERICORIENTATIONSENSOR QTSENSORS_GENERICALSSENSOR -} +SOURCES += genericorientationsensor.cpp\ + genericalssensor.cpp +DEFINES += QTSENSORS_GENERICORIENTATIONSENSOR QTSENSORS_GENERICALSSENSOR -!blackberry:!android { +!android { HEADERS += genericrotationsensor.h SOURCES += genericrotationsensor.cpp diff --git a/src/plugins/sensors/sensors.pro b/src/plugins/sensors/sensors.pro index a66ed4a..e232a85 100644 --- a/src/plugins/sensors/sensors.pro +++ b/src/plugins/sensors/sensors.pro @@ -1,9 +1,5 @@ TEMPLATE = subdirs -blackberry { - isEmpty(SENSORS_PLUGINS): SENSORS_PLUGINS = blackberry generic -} - android { isEmpty(SENSORS_PLUGINS): SENSORS_PLUGINS = android generic } @@ -31,7 +27,6 @@ linux { contains(SENSORS_PLUGINS, dummy):SUBDIRS += dummy isEmpty(SENSORS_PLUGINS)|contains(SENSORS_PLUGINS, generic):SUBDIRS += generic isEmpty(SENSORS_PLUGINS)|contains(SENSORS_PLUGINS, simulator):qtHaveModule(simulator):SUBDIRS += simulator -isEmpty(SENSORS_PLUGINS)|contains(SENSORS_PLUGINS, blackberry):blackberry:SUBDIRS += blackberry isEmpty(SENSORS_PLUGINS)|contains(SENSORS_PLUGINS, linux):linux:SUBDIRS += linux isEmpty(SENSORS_PLUGINS)|contains(SENSORS_PLUGINS, android):android:SUBDIRS += android isEmpty(SENSORS_PLUGINS)|contains(SENSORS_PLUGINS, sensorfw):sensorfw:SUBDIRS += sensorfw |