summaryrefslogtreecommitdiffstats
path: root/src/plugins
diff options
context:
space:
mode:
authorThomas McGuire <thomas.mcguire.qnx@kdab.com>2013-01-09 13:57:16 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-01-23 18:33:03 +0100
commit1831170d56f32530e64bbd5484a6c2cc9e1817ca (patch)
tree3499dfc2e46b97d72b17a6cfc1087add660e6e8a /src/plugins
parent02285d735e7d3bd8ddfb61b7ea5e16da4ad522d1 (diff)
Add API for duplicate skipping
Duplicate skipping enables omitting reading values that are very similar to the previous one, thus saving processing power. Implement this for the Blackberry backend. Change-Id: Ic608d8ca795b5a2e0bca5a75a62e8005c283c620 Reviewed-by: Thomas McGuire <thomas.mcguire@kdab.com>
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/sensors/blackberry/bborientationsensor.cpp16
-rw-r--r--src/plugins/sensors/blackberry/bborientationsensor.h1
-rw-r--r--src/plugins/sensors/blackberry/bbsensorbackend.cpp11
3 files changed, 14 insertions, 14 deletions
diff --git a/src/plugins/sensors/blackberry/bborientationsensor.cpp b/src/plugins/sensors/blackberry/bborientationsensor.cpp
index 68ed735b..3d9d120c 100644
--- a/src/plugins/sensors/blackberry/bborientationsensor.cpp
+++ b/src/plugins/sensors/blackberry/bborientationsensor.cpp
@@ -44,6 +44,9 @@ 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()
@@ -51,19 +54,6 @@ QString BbOrientationSensor::devicePath()
return QLatin1String("/dev/sensor/orientation");
}
-void BbOrientationSensor::start()
-{
- BbSensorBackend<QOrientationReading>::start();
-
- // Orientation rarely changes, so enable skiping of duplicates
- sensor_devctl_skipdupevent_u deviceSkip;
- deviceSkip.tx.enable = 1;
- const int result = devctl(deviceFile().handle(), DCMD_SENSOR_SKIPDUPEVENT, &deviceSkip,
- sizeof(deviceSkip), NULL);
- if (result != EOK)
- perror("Enabling duplicate skipping for orientation sensor failed");
-}
-
void BbOrientationSensor::additionalDeviceInit()
{
// When querying the OS service for the range, it gives us the angles, which we don't need.
diff --git a/src/plugins/sensors/blackberry/bborientationsensor.h b/src/plugins/sensors/blackberry/bborientationsensor.h
index 07dc3d0f..85c7bd67 100644
--- a/src/plugins/sensors/blackberry/bborientationsensor.h
+++ b/src/plugins/sensors/blackberry/bborientationsensor.h
@@ -53,7 +53,6 @@ public:
static QString devicePath();
- void start() Q_DECL_OVERRIDE;
void additionalDeviceInit() Q_DECL_OVERRIDE;
bool addDefaultRange() Q_DECL_OVERRIDE;
diff --git a/src/plugins/sensors/blackberry/bbsensorbackend.cpp b/src/plugins/sensors/blackberry/bbsensorbackend.cpp
index 324929fd..9850d4dd 100644
--- a/src/plugins/sensors/blackberry/bbsensorbackend.cpp
+++ b/src/plugins/sensors/blackberry/bbsensorbackend.cpp
@@ -254,6 +254,16 @@ void BbSensorBackendBase::start()
}
}
+ // 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());
+ }
+
// 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)
@@ -299,6 +309,7 @@ bool BbSensorBackendBase::isFeatureSupported(QSensor::Feature feature) const
case QSensor::AlwaysOn:
case QSensor::Buffering:
case QSensor::AccelerationMode:
+ case QSensor::SkipDuplicates:
return true;
case QSensor::Reserved:
case QSensor::GeoValues: