summaryrefslogtreecommitdiffstats
path: root/src/plugins/sensors/blackberry
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/sensors/blackberry')
-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: