summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEgbert Eich <eich@suse.com>2014-02-07 20:24:39 +0100
committerEgbert Eich <eich@suse.com>2014-02-19 14:08:58 +0100
commit93d232ac0140251b9b3ee4fe6e11ee65553f8284 (patch)
tree8779e0ec909bd3a18687cdb0d5069f195be78da1
parent77a7ac02107a00934c98b1955a17a2f5c0614bcf (diff)
Log when the pen device appears to be too worn outfor_Peter
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 <eich@suse.com> Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
-rw-r--r--src/wcmCommon.c40
-rw-r--r--src/xf86WacomDefs.h3
2 files changed, 42 insertions, 1 deletions
diff --git a/src/wcmCommon.c b/src/wcmCommon.c
index 209565c..a0db134 100644
--- a/src/wcmCommon.c
+++ b/src/wcmCommon.c
@@ -1121,6 +1121,45 @@ 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 */
+#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->eventCnt > MIN_EVENT_COUNT)
+ LogMessageVerbSigSafe(
+ X_WARNING, 0,
+ "On %s(%d) a base pressure of %d persists while the pen is in proximity.\n"
+ "\tThis is > %d percent of the maximum value (%d).\n"
+ "\tThis indicates a worn out pen, it is time to change your tool. Also see:\n"
+ "\thttp://sourceforge.net/apps/mediawiki/linuxwacom/index.php?title=Pen_Wear.\n",
+ priv->pInfo->name, priv->serial, priv->minPressure, LIMIT_LOW_PRESSURE, common->wcmMaxZ);
+ } else if (!priv->oldProximity)
+ priv->eventCnt = 0;
+
+ priv->oldMinPressure = priv->minPressure;
+ priv->eventCnt++;
+}
+
static void commonDispatchDevice(WacomCommonPtr common, unsigned int channel,
const WacomChannelPtr pChannel,
enum WacomSuppressMode suppress)
@@ -1203,6 +1242,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 3a64fd6..afe6543 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 eventCnt; /* count number of events while in proximity */
WacomToolPtr tool; /* The common tool-structure for this device */
int isParent; /* set to 1 if the device is not auto-hotplugged */