From 2fa4ef48c98860859d48810d870567fe99b5d76f Mon Sep 17 00:00:00 2001 From: Jason Gerecke Date: Fri, 8 Dec 2017 13:55:32 -0800 Subject: Do not overwrite raw device state with filtered coordinate values By performing coordinate filtering in wcmEvent and overwriting the raw device state stored in pChannel, we loose the ability to see the actual (but noisy) hardware coordinates at later points in the code. By moving this filtering into commonDispatchDevice we can apply the result to only the 'filtered' DeviceState sample that is ultimately passed along to wcmSendEvents. Signed-off-by: Jason Gerecke Reviewed-by: Ping Cheng --- src/wcmCommon.c | 32 +++++++++++++++----------------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/src/wcmCommon.c b/src/wcmCommon.c index dc6ecbd..900544b 100644 --- a/src/wcmCommon.c +++ b/src/wcmCommon.c @@ -897,7 +897,6 @@ static Bool check_arbitrated_control(InputInfoPtr pInfo, WacomDeviceStatePtr ds) void wcmEvent(WacomCommonPtr common, unsigned int channel, const WacomDeviceState* pState) { - WacomDeviceState* pLast; WacomDeviceState ds; WacomChannelPtr pChannel; enum WacomSuppressMode suppress; @@ -905,7 +904,6 @@ void wcmEvent(WacomCommonPtr common, unsigned int channel, WacomToolPtr tool; WacomDevicePtr priv; pChannel = common->wcmChannel + channel; - pLast = &pChannel->valid.state; DBG(10, common, "channel = %d\n", channel); @@ -962,21 +960,6 @@ void wcmEvent(WacomCommonPtr common, unsigned int channel, ds.tilty = 0; } - /* Optionally filter values only while in proximity */ - if (ds.proximity && ds.device_type != PAD_ID) - { - /* Start filter fresh when entering proximity */ - if (!pLast->proximity) - wcmResetSampleCounter(pChannel); - - wcmFilterCoord(common,pChannel,&ds); - } - - /* skip event if we don't have enough movement */ - suppress = wcmCheckSuppress(common, pLast, &ds); - if (suppress == SUPPRESS_ALL) - return; - /* JEJ - Do not move this code without discussing it with me. * The device state is invariant of any filtering performed below. * Changing the device state after this point can and will cause @@ -1251,6 +1234,21 @@ static void commonDispatchDevice(InputInfoPtr pInfo, filtered.pressure = applyPressureCurve(priv,&filtered); } + /* Optionally filter values only while in proximity */ + if (filtered.proximity && filtered.device_type != PAD_ID) + { + /* Start filter fresh when entering proximity */ + if (!priv->oldState.proximity) + wcmResetSampleCounter(pChannel); + + wcmFilterCoord(common,pChannel,&filtered); + } + + /* skip event if we don't have enough movement */ + suppress = wcmCheckSuppress(common, &priv->oldState, &filtered); + if (suppress == SUPPRESS_ALL) + return; + /* Store cursor hardware prox for next use */ if (IsCursor(priv)) priv->oldCursorHwProx = ds->proximity; -- cgit v1.2.1