From 169da60c8f657b3b61309c0a570d296107181411 Mon Sep 17 00:00:00 2001 From: Andrew Inwood Date: Mon, 10 Mar 2014 13:58:58 -0400 Subject: BlackBerry: Update threshold for close detection back ported from qt5. SHA1: ab6c205f567bdba7c2907d4656c3af253f1c235e 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: Fabian Bumberger Reviewed-by: Bernd Weimer Reviewed-by: Rafael Roquetto --- plugins/sensors/blackberry/bbproximitysensor.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/plugins/sensors/blackberry/bbproximitysensor.cpp b/plugins/sensors/blackberry/bbproximitysensor.cpp index 1e6e541c98..43a6b1634f 100644 --- a/plugins/sensors/blackberry/bbproximitysensor.cpp +++ b/plugins/sensors/blackberry/bbproximitysensor.cpp @@ -53,10 +53,11 @@ QString BbProximitySensor::devicePath() bool BbProximitySensor::updateReadingFromEvent(const sensor_event_t &event, QProximityReading *reading) { - // TODO: I was unable to test this since the device I was testing this with did not have - // a proximity sensor. Verify that this works, check that the units are correct - // and that the threshold makes sense. 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; } -- cgit v1.2.3