On Mon, Feb 17, 2014 at 11:26:49AM +0100, Egbert Eich wrote:
> From: Egbert Eich <e...@suse.com>
> 
> Worn out pens have an initial pressure != 0. If this pressure
> persists while the pen is in proximity and still exists when
> going out of proximity, warn about worn out tool.
> Some devices seem to send a zero pressure when going out of
> proximity. Thus we record the last pressure when still in
> proximity.
> Also we count the number of events we have received while in
> proximity so the risk of false reports on 'quick taps' is lower.
> 
> This condition may also occur intermittently on abusive operation.
> 
> Signed-off-by: Egbert Eich <e...@suse.com>
> ---
> Algorithm has been reworked, suggestions have been incorporated.
> I'm not sure about the Wiki page, though, it seems that one cannot
> link to any but the main page using http://linuxwacom.sourceforge.net.

The full link would be something along the line of:
http://sourceforge.net/apps/mediawiki/linuxwacom/index.php?title=Main_Page
with the obvious change to the wiki page explaining this issue.

You'll need a wiki account, ping me when you have one so I can give you edit
rights.

>  src/wcmCommon.c     | 45 +++++++++++++++++++++++++++++++++++++++++++++
>  src/xf86WacomDefs.h |  3 ++-
>  2 files changed, 47 insertions(+), 1 deletion(-)
> 
> diff --git a/src/wcmCommon.c b/src/wcmCommon.c
> index 209565c..73aeeea 100644
> --- a/src/wcmCommon.c
> +++ b/src/wcmCommon.c
> @@ -1121,6 +1121,50 @@ setPressureButton(const WacomDevicePtr priv, const 
> WacomDeviceState *ds)
>       return buttons;
>  }
>  
> +/*
> + * Broken pen with a broken tip might give high pressure values
> + * all the time. We want to warn about this. To avoid getting
> + * spurious warnings when the tablet is hit quickly will wait
> + * until the device goes out of proximity and check if the minimum
> + * pressure is still above a threshold of 20 percent of the maximum
> + * pressure. Also we make sure the device has seen a sufficient number
> + * of events while in proximity that it had a chance to see decreasing
> + * pressure values.
> + */
> +#define  LIMIT_LOW_PRESSURE 20 /* percentage of max value */

extra space here

> +#define PERCENT_TOLERANCE 10

you don't seem to be using this define

> +#define MIN_EVENT_COUNT 15
> +
> +static void detectPressureIssue(WacomDevicePtr priv,
> +                             WacomCommonPtr common,
> +                             WacomDeviceStatePtr ds)
> +{
> +     /* pen is just going out of proximity */
> +     if (priv->oldProximity && !ds->proximity) {
> +
> +             int pressureThreshold = common->wcmMaxZ * LIMIT_LOW_PRESSURE / 
> 100;
> +             /* check if minPressure has persisted all the time
> +                and is too close to the maximum pressure */
> +             if (priv->oldMinPressure > pressureThreshold &&
> +                 priv->eventCount > MIN_EVENT_COUNT)
> +                     LogMessageVerbSigSafe(
> +                             X_WARNING, 0,
> +                             "%s(%d) has seen an initial pressure > 0\n\t"
> +                             "there is a base pressure of %d which 
> persists\n\t"
> +                             "while the pen is in proximity and "
> +                             "which is too close\n\tto the maximum value 
> (%d).\n\t"
> +                             "This indicates a worn out pen, "
> +                             "Time to change your tool. Also see:\n\t"
> +                             "http://linuxwacom.sourceforge.net/Pen_Wear.\n";,
> +                             priv->pInfo->name, priv->serial, 
> priv->minPressure,
> +                             common->wcmMaxZ);

This is a personal preference but I'd prefer a printf line to go >80 lines
and ends with a \n over a line that wraps and has the \n\t inside. Makes it
easier to grep for and most of us have screens that can handle the odd 80+
line :)

I think the algorithm is fine and should work well enough, thanks.

> +     } else if (!priv->oldProximity)
> +             priv->eventCount = 0;
> +
> +     priv->oldMinPressure = priv->minPressure;
> +     priv->eventCount++;
> +}
> +
>  static void commonDispatchDevice(WacomCommonPtr common, unsigned int channel,
>                                const WacomChannelPtr pChannel,
>                                enum WacomSuppressMode suppress)
> @@ -1203,6 +1247,7 @@ static void commonDispatchDevice(WacomCommonPtr common, 
> unsigned int channel,
>  
>       if ((IsPen(priv) || IsTouch(priv)) && common->wcmMaxZ)
>       {
> +             detectPressureIssue(priv, common, &filtered);
>               priv->minPressure = rebasePressure(priv, &filtered);
>               filtered.pressure = normalizePressure(priv, &filtered);
>               if (IsPen(priv))
> diff --git a/src/xf86WacomDefs.h b/src/xf86WacomDefs.h
> index 6de9645..09597a0 100644
> --- a/src/xf86WacomDefs.h
> +++ b/src/xf86WacomDefs.h
> @@ -303,7 +303,8 @@ struct _WacomDeviceRec
>       int pPressCurve[FILTER_PRESSURE_RES + 1]; /* pressure curve */
>       int nPressCtrl[4];      /* control points for curve */
>       int minPressure;        /* the minimum pressure a pen may hold */
> -
> +     int oldMinPressure;     /* to record the last minPressure before going 
> out of proximity */
> +     unsigned int eventCount; /* count number of events while in proximity */

bit more alignment of comments would be nice but I suspect the rest of the
file is messed up already, so with the above addressed

Reviewed-by: Peter Hutterer <peter.hutte...@who-t.net>

Cheers,
   Peter


>       WacomToolPtr tool;         /* The common tool-structure for this device 
> */
>  
>       int isParent;           /* set to 1 if the device is not 
> auto-hotplugged */
> -- 
> 1.8.1.4
> 

------------------------------------------------------------------------------
Managing the Performance of Cloud-Based Applications
Take advantage of what the Cloud has to offer - Avoid Common Pitfalls.
Read the Whitepaper.
http://pubads.g.doubleclick.net/gampad/clk?id=121054471&iu=/4140/ostg.clktrk
_______________________________________________
Linuxwacom-devel mailing list
Linuxwacom-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxwacom-devel

Reply via email to