From: Chris Bagwell <ch...@cnpbagwell.com>

We only filter X/Y values and when unrelated events such as
pressure come in it can cause us to dump older values and can
show up as cursor movements if those older values had large
deltas.

Allow older behavior though after a holdoff time period since
the longer between samples the less older values have meaning.

Signed-off-by: Chris Bagwell <ch...@cnpbagwell.com>
---
 src/wcmFilter.c     |   31 +++++++++++++++++++++++++++++++
 src/xf86WacomDefs.h |    1 +
 2 files changed, 32 insertions(+), 0 deletions(-)

diff --git a/src/wcmFilter.c b/src/wcmFilter.c
index e7e341d..4cb1bb7 100644
--- a/src/wcmFilter.c
+++ b/src/wcmFilter.c
@@ -25,6 +25,8 @@
 #include "xf86Wacom.h"
 #include "wcmFilter.h"
 
+#define WCM_FILTER_HOLDOFF 250
+
 /*****************************************************************************
  * Static functions
  ****************************************************************************/
@@ -224,6 +226,8 @@ static void storeRawSample(WacomCommonPtr common, 
WacomChannelPtr pChannel,
 {
        WacomFilterState *fs;
        int i;
+       int sample = (int)GetTimeInMillis();
+
 
        fs = &pChannel->rawFilter;
        if (!fs->npoints && ds->proximity)
@@ -234,6 +238,7 @@ static void storeRawSample(WacomCommonPtr common, 
WacomChannelPtr pChannel,
                {
                        fs->x[i]= ds->x;
                        fs->y[i]= ds->y;
+                       fs->sample = sample;
                }
                if (HANDLE_TILT(common) && (ds->device_type == STYLUS_ID ||
                                            ds->device_type == ERASER_ID))
@@ -246,6 +251,32 @@ static void storeRawSample(WacomCommonPtr common, 
WacomChannelPtr pChannel,
                }
                ++fs->npoints;
        } else if (ds->proximity) {
+               int no_change = 1;
+
+               if (fs->x[0] != ds->x && fs->y[0] != ds->y)
+                       no_change = 0;
+
+               if (HANDLE_TILT(common) && (ds->device_type == STYLUS_ID ||
+                                           ds->device_type == ERASER_ID))
+               {
+                       if (fs->tiltx[0] != ds->tiltx &&
+                           fs->tilty[0] != ds->tilty)
+                               no_change = 0;
+               }
+
+               /* A stream of pressure changes can cause cursor to move
+                * as it pushes old samples out of window.  Think of
+                * writing a signature fast and lifting up pen fast
+                * at end.
+                *
+                * Work around this by not recording samples when
+                * nothing has changed.  Allowing it to change
+                * after holdoff period is attempt to get large
+                * delta samples aged out when user stops drawing.
+                */
+               if (no_change && (sample - fs->sample) > WCM_FILTER_HOLDOFF)
+                       return;
+
                /* Shift window and insert latest sample */
                for (i=common->wcmRawSample - 1; i>0; i--)
                {
diff --git a/src/xf86WacomDefs.h b/src/xf86WacomDefs.h
index 6ced5df..9b26790 100644
--- a/src/xf86WacomDefs.h
+++ b/src/xf86WacomDefs.h
@@ -304,6 +304,7 @@ struct _WacomFilterState
         int y[MAX_SAMPLES];
         int tiltx[MAX_SAMPLES];
         int tilty[MAX_SAMPLES];
+        int sample;
 };
 
 struct _WacomChannel
-- 
1.7.3.1


------------------------------------------------------------------------------
Download new Adobe(R) Flash(R) Builder(TM) 4
The new Adobe(R) Flex(R) 4 and Flash(R) Builder(TM) 4 (formerly 
Flex(R) Builder(TM)) enable the development of rich applications that run
across multiple browsers and platforms. Download your free trials today!
http://p.sf.net/sfu/adobe-dev2dev
_______________________________________________
Linuxwacom-devel mailing list
Linuxwacom-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxwacom-devel

Reply via email to