diff options
author | Andrew Inwood <[email protected]> | 2014-03-10 13:58:58 -0400 |
---|---|---|
committer | Andrew Inwood <[email protected]> | 2014-03-25 20:26:00 +0100 |
commit | 169da60c8f657b3b61309c0a570d296107181411 (patch) | |
tree | bb454bb09a0c5db769515b2a833980a5c2b1081b | |
parent | 4ead4a65f4d1e45e60eeeb22e58cf44f42489b65 (diff) |
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 <[email protected]>
Reviewed-by: Bernd Weimer <[email protected]>
Reviewed-by: Rafael Roquetto <[email protected]>
-rw-r--r-- | plugins/sensors/blackberry/bbproximitysensor.cpp | 9 |
1 files 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; } |