summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Inwood <ainwood@blackberry.com>2014-03-10 13:58:58 -0400
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-03-11 16:50:00 +0100
commit5ed59ab19c145afd5ff7db47ee4b0c3c11f47c7a (patch)
treebc69bfdd12a2874f8b15ff9cbb046526c85a28f1
parentf89b0fcffbb7907210d4d85d1245dc59f270c251 (diff)
downloadqtsensors-5ed59ab19c145afd5ff7db47ee4b0c3c11f47c7a.tar.gz
qtsensors-5ed59ab19c145afd5ff7db47ee4b0c3c11f47c7a.tar.bz2
qtsensors-5ed59ab19c145afd5ff7db47ee4b0c3c11f47c7a.zip
BlackBerry: Update threshold for close detection
The current algorithm for close detection in QProximitySensor will not work for sensors whose output is not binary (ie, close/far). The new algorithm will use the threshold of 8cm when the output is not binary. Change-Id: I2173e9afae0a2d29434e092e1afc09d1c6f5647c Reviewed-by: Bernd Weimer <bweimer@blackberry.com> Reviewed-by: Fabian Bumberger <fbumberger@rim.com>
-rw-r--r--src/plugins/sensors/blackberry/bbproximitysensor.cpp6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/plugins/sensors/blackberry/bbproximitysensor.cpp b/src/plugins/sensors/blackberry/bbproximitysensor.cpp
index 1177f74..2c08df4 100644
--- a/src/plugins/sensors/blackberry/bbproximitysensor.cpp
+++ b/src/plugins/sensors/blackberry/bbproximitysensor.cpp
@@ -54,6 +54,10 @@ QString BbProximitySensor::devicePath()
bool BbProximitySensor::updateReadingFromEvent(const sensor_event_t &event, QProximityReading *reading)
{
const qreal minProximity = sensor()->outputRanges().first().minimum;
- reading->setClose(event.proximity_s.distance <= minProximity);
+ 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;
}