From 9765439856149570be41d1e2f2492e620822d492 Mon Sep 17 00:00:00 2001 From: Egbert Eich Date: Mon, 17 Mar 2014 21:08:40 +0100 Subject: Attempt to not lose events to pressure recalibration Worn out devices send a non-zero pressure even when not in contact with the tablet. To compensate for this the driver detects if the pressure sent by the device immediately after indicating proximity is non-zero. It subtracts this value from any pressure value sent later and rescales the pressure range to the full device range. If it later on sees the pressure value fall below this initial value it will readjust it this lower value. The downside of this is that when the pen is pushed onto the tablet really fast the initial pressure reading may be non-zero also the pen isn't worn. This can lead to lost events. This patch tries to address this: If the first pressure reading is != 0 it is recorded. If the recorded maximum value is >0 but a later pressure reading is higher the maximum value is replaced. If no button press event is generated the 'normal' way it is checked of the recorded maximum would trigger one when minPressure decreases. Once a 'normal' button event is generated or an 'alternative' button event is generated and minPressure doesn't decrease any more the recorded maximum is set to 0 which will disable the checks until the next prox in. Signed-off-by: Egbert Eich Reviewed-by: Jason Gerecke --- test/wacom-tests.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) (limited to 'test') diff --git a/test/wacom-tests.c b/test/wacom-tests.c index f44d3ab..a245021 100644 --- a/test/wacom-tests.c +++ b/test/wacom-tests.c @@ -179,7 +179,6 @@ test_normalize_pressure(void) InputInfoRec pInfo = {0}; WacomDeviceRec priv = {0}; WacomCommonRec common = {0}; - WacomDeviceState ds = {0}; int pressure, prev_pressure = -1; int i, j; @@ -198,9 +197,9 @@ test_normalize_pressure(void) for (i = 0; i <= common.wcmMaxZ; i++) { - ds.pressure = i; + pressure = i; - pressure = normalizePressure(&priv, &ds); + pressure = normalizePressure(&priv, pressure); assert(pressure >= 0); assert(pressure <= FILTER_PRESSURE_RES); @@ -216,14 +215,12 @@ test_normalize_pressure(void) * minPressure and ignores actual pressure. This would be a bug in the * driver code, but we might as well test for it. */ priv.minPressure = 10; - ds.pressure = 0; - prev_pressure = normalizePressure(&priv, &ds); + prev_pressure = normalizePressure(&priv, 0); for (i = 0; i < priv.minPressure; i++) { - ds.pressure = i; - pressure = normalizePressure(&priv, &ds); + pressure = normalizePressure(&priv, i); assert(pressure >= 0); assert(pressure < FILTER_PRESSURE_RES); -- cgit v1.2.1