summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin Ottens <kevin.ottens.qnx@kdab.com>2012-05-03 10:54:41 +0200
committerQt by Nokia <qt-info@nokia.com>2012-05-04 14:15:08 +0200
commit0cadbe2057f47e6bb4c72441b8f62ef574125e6b (patch)
tree8a2ec59c35323f9034cf0d53898beae68c829dff
parentbf3dde61cc7d611b1e5f2a18e533c535c4cd7ff8 (diff)
Add support for the IR proximity sensor
Change-Id: I04e1c1eb7702626f4ce5e19b301f8774e604b930 Reviewed-by: Tennessee Carmel-Veilleux <tcarmelveilleux@rim.com> Reviewed-by: Lincoln Ramsay <lincoln.ramsay@nokia.com>
-rw-r--r--src/plugins/sensors/blackberry/bbirproximitysensor.cpp58
-rw-r--r--src/plugins/sensors/blackberry/bbirproximitysensor.h60
-rw-r--r--src/plugins/sensors/blackberry/blackberry.pro2
-rw-r--r--src/plugins/sensors/blackberry/main.cpp6
4 files changed, 126 insertions, 0 deletions
diff --git a/src/plugins/sensors/blackberry/bbirproximitysensor.cpp b/src/plugins/sensors/blackberry/bbirproximitysensor.cpp
new file mode 100644
index 00000000..7790688d
--- /dev/null
+++ b/src/plugins/sensors/blackberry/bbirproximitysensor.cpp
@@ -0,0 +1,58 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Research In Motion
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtSensors module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include "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
new file mode 100644
index 00000000..534b8901
--- /dev/null
+++ b/src/plugins/sensors/blackberry/bbirproximitysensor.h
@@ -0,0 +1,60 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Research In Motion
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtSensors module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#ifndef 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);
+};
+
+#endif
diff --git a/src/plugins/sensors/blackberry/blackberry.pro b/src/plugins/sensors/blackberry/blackberry.pro
index 15c6626d..2b849e51 100644
--- a/src/plugins/sensors/blackberry/blackberry.pro
+++ b/src/plugins/sensors/blackberry/blackberry.pro
@@ -12,6 +12,7 @@ HEADERS += bbsensorbackend.h \
bbaccelerometer.h \
bbaltimeter.h \
bbgyroscope.h \
+ bbirproximitysensor.h \
bblightsensor.h \
bbmagnetometer.h \
bborientationsensor.h \
@@ -24,6 +25,7 @@ SOURCES += bbsensorbackend.cpp \
bbaccelerometer.cpp \
bbaltimeter.cpp \
bbgyroscope.cpp \
+ bbirproximitysensor.cpp \
bblightsensor.cpp \
bbmagnetometer.cpp \
bborientationsensor.cpp \
diff --git a/src/plugins/sensors/blackberry/main.cpp b/src/plugins/sensors/blackberry/main.cpp
index abe5972c..61ec0cd4 100644
--- a/src/plugins/sensors/blackberry/main.cpp
+++ b/src/plugins/sensors/blackberry/main.cpp
@@ -41,6 +41,7 @@
#include "bbaccelerometer.h"
#include "bbaltimeter.h"
#include "bbgyroscope.h"
+#include "bbirproximitysensor.h"
#include "bblightsensor.h"
#include "bbmagnetometer.h"
#include "bborientationsensor.h"
@@ -54,6 +55,7 @@
static const char *bbAccelerometerId = "bbAccelerometer";
static const char *bbAltitmeterId = "bbAltimeter";
static const char *bbGyroscopeId = "bbGyroscope";
+static const char *bbIRProximitySensorId = "bbIRProximitySensor";
static const char *bbLightSensorId = "bbLightSensor";
static const char *bbMagnetometerId = "bbMagnetometer";
static const char *bbOrientationSensorId = "bbOrientationSensor";
@@ -76,6 +78,8 @@ public:
QSensorManager::registerBackend("BbAltimeter", bbAltitmeterId, this);
if (sensorSupported(BbGyroscope::devicePath()))
QSensorManager::registerBackend("QGyroscope", bbGyroscopeId, this);
+ if (sensorSupported(BbIRProximitySensor::devicePath()))
+ QSensorManager::registerBackend("QIRProximitySensor", bbIRProximitySensorId, this);
if (sensorSupported(BbLightSensor::devicePath()))
QSensorManager::registerBackend("QLightSensor", bbLightSensorId, this);
if (sensorSupported(BbMagnetometer::devicePath()))
@@ -99,6 +103,8 @@ public:
backend = new BbAltimeter(sensor);
if (sensor->identifier() == bbGyroscopeId)
backend = new BbGyroscope(sensor);
+ if (sensor->identifier() == bbIRProximitySensorId)
+ backend = new BbIRProximitySensor(sensor);
if (sensor->identifier() == bbLightSensorId)
backend = new BbLightSensor(sensor);
if (sensor->identifier() == bbMagnetometerId)