From: Egbert Eich <e...@suse.com>

If the initial pressure of a device is != 0 the driver recalibrates
the pressure range. This is to account for worn out devices.
The downside is that when the user hits the tablet very hard the
initial pressure reading may be unequal to zero even for a perfectly
good pen. If the consecutive pressure readings are not higher than
the initial pressure by a threshold no button event will be generated.
This option allows to disable the recalibration.

Signed-off-by: Egbert Eich <e...@suse.com>
---
 include/wacom-properties.h |  4 ++++
 man/wacom.man              | 10 ++++++++++
 man/xsetwacom.man          |  9 +++++++++
 src/wcmCommon.c            |  8 +++++---
 src/wcmValidateDevice.c    |  6 ++++++
 src/wcmXCommand.c          | 23 +++++++++++++++++++++++
 src/xf86WacomDefs.h        |  2 ++
 tools/xsetwacom.c          | 11 ++++++++++-
 8 files changed, 69 insertions(+), 4 deletions(-)

diff --git a/include/wacom-properties.h b/include/wacom-properties.h
index dd7e7f3..cb94ffc 100644
--- a/include/wacom-properties.h
+++ b/include/wacom-properties.h
@@ -103,6 +103,10 @@
  */
 #define WACOM_PROP_DEBUGLEVELS "Wacom Debug Levels"
 
+/* BOOL, 1 value,
+   TRUE == pressure renormalization enabled, FALSE == pressure renormalization 
disabled
+*/
+#define WACOM_PROP_PRESSURE_RECAL "Wacom Pressure Recalibration"
 
 /* The following are tool types used by the driver in WACOM_PROP_TOOL_TYPE
  * or in the 'type' field for XI1 clients. Clients may check for one of
diff --git a/man/wacom.man b/man/wacom.man
index 98dec37..ae042f6 100644
--- a/man/wacom.man
+++ b/man/wacom.man
@@ -257,6 +257,16 @@ recognized as tap. A press and release event shorter than
 generates button press and release events. Presses longer than
 .B TapTime
 do not generate button events, only motion events.
+.TP 4
+.B Option \fI"PressureRecalibration"\fP \fI"bool"\fP
+Allows to disable pressure recalibration. Default: true.
+If the initial pressure of a device is != 0 the driver recalibrates
+the pressure range. This is to account for worn out devices.
+The downside is that when the user hits the tablet very hard the
+initial pressure reading may be unequal to zero even for a perfectly
+good pen. If the consecutive pressure readings are not higher than
+the initial pressure by a threshold no button event will be generated.
+This option allows to disable the recalibration.
 .RE
 .SH "TOUCH GESTURES"
 .SS Single finger (1FG)
diff --git a/man/xsetwacom.man b/man/xsetwacom.man
index 978b104..6255352 100644
--- a/man/xsetwacom.man
+++ b/man/xsetwacom.man
@@ -227,6 +227,15 @@ code paths that are specific to a given tool. A higher 
level means more
 fine-grained debug messages, a level of 0 turns debugging off for this
 tool. Requires the driver to be built with debugging enabled. See also
 TabletDebugLevel.  Default:  0, range of 0 to 12.
+.TP
+\fBPressureRecalibration\fR on|off
+If the initial pressure of a device is != 0 the driver recalibrates
+the pressure range. This is to account for worn out devices.
+The downside is that when the user hits the tablet very hard the
+initial pressure reading may be unequal to zero even for a perfectly
+good pen. If the consecutive pressure readings are not higher than
+the initial pressure by a threshold no button event will be generated.
+This option allows to disable the recalibration.  Default:  on
 
 
 .SH "AUTHORS"
diff --git a/src/wcmCommon.c b/src/wcmCommon.c
index 0ea7be8..5fa2ef9 100644
--- a/src/wcmCommon.c
+++ b/src/wcmCommon.c
@@ -1266,8 +1266,10 @@ 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 (common->wcmPressureRecalibration) {
+                       priv->minPressure = rebasePressure(priv, &filtered);
+                       filtered.pressure = normalizePressure(priv, &filtered);
+               }
                if (IsPen(priv))
                        filtered.buttons = setPressureButton(priv, &filtered);
                filtered.pressure = applyPressureCurve(priv,&filtered);
@@ -1501,7 +1503,7 @@ WacomCommonPtr wcmNewCommon(void)
                        /* transmit position if increment is superior */
        common->wcmRawSample = DEFAULT_SAMPLES;
                        /* number of raw data to be used to for filtering */
-
+       common->wcmPressureRecalibration = 1;
        return common;
 }
 
diff --git a/src/wcmValidateDevice.c b/src/wcmValidateDevice.c
index cc0b807..2f3b7b7 100644
--- a/src/wcmValidateDevice.c
+++ b/src/wcmValidateDevice.c
@@ -965,6 +965,12 @@ Bool wcmPreInitParseOptions(InputInfoPtr pInfo, Bool 
is_primary,
                        common->wcmGestureParameters.wcmTapTime);
        }
 
+       if (IsStylus(priv) || IsEraser(priv)) {
+               common->wcmPressureRecalibration
+                       = xf86SetBoolOption(pInfo->options,
+                                           "PressureRecalibration", 1);
+       }
+
        /* Swap stylus buttons 2 and 3 for Tablet PCs */
        if (TabletHasFeature(common, WCM_TPC) && IsStylus(priv))
        {
diff --git a/src/wcmXCommand.c b/src/wcmXCommand.c
index b2ba5a5..3596a8e 100644
--- a/src/wcmXCommand.c
+++ b/src/wcmXCommand.c
@@ -98,6 +98,7 @@ Atom prop_hover;
 Atom prop_tooltype;
 Atom prop_btnactions;
 Atom prop_product_id;
+Atom prop_pressure_recal;
 #ifdef DEBUG
 Atom prop_debuglevels;
 #endif
@@ -300,6 +301,13 @@ void InitWcmDeviceProperties(InputInfoPtr pInfo)
                        wcmResetWheelAction(pInfo, i);
        }
 
+       if (IsStylus(priv) || IsEraser(priv)) {
+               values[0] = !common->wcmPressureRecalibration;
+               prop_pressure_recal = InitWcmAtom(pInfo->dev,
+                                                 WACOM_PROP_PRESSURE_RECAL,
+                                                 XA_INTEGER, 8, 1, values);
+       }
+
        values[0] = common->vendor_id;
        values[1] = common->tablet_id;
        prop_product_id = InitWcmAtom(pInfo->dev, XI_PROP_PRODUCT_ID, 
XA_INTEGER, 32, 2, values);
@@ -848,6 +856,21 @@ int wcmSetProperty(DeviceIntPtr dev, Atom property, 
XIPropertyValuePtr prop,
        {
                int nbuttons = priv->nbuttons < 4 ? priv->nbuttons : 
priv->nbuttons + 4;
                return wcmSetActionsProperty(dev, property, prop, checkonly, 
nbuttons, priv->btn_actions, priv->keys);
+       } else if (property == prop_pressure_recal)
+       {
+               CARD8 *values = (CARD8*)prop->data;
+
+               if (prop->size != 1 || prop->format != 8)
+                       return BadValue;
+
+               if ((values[0] != 0) && (values[0] != 1))
+                       return BadValue;
+
+               if (!IsStylus(priv) && !IsEraser(priv))
+                       return BadMatch;
+
+               if (!checkonly)
+                       common->wcmPressureRecalibration = !values[0];
        } else
        {
                Atom *handler = NULL;
diff --git a/src/xf86WacomDefs.h b/src/xf86WacomDefs.h
index 6de9645..8a46c9b 100644
--- a/src/xf86WacomDefs.h
+++ b/src/xf86WacomDefs.h
@@ -486,6 +486,8 @@ struct _WacomCommonRec
        int wcmCursorProxoutDistDefault; /* Default max mouse distance for 
proxy-out */
        int wcmSuppress;                 /* transmit position on delta > 
supress */
        int wcmRawSample;            /* Number of raw data used to filter an 
event */
+       int wcmPressureRecalibration; /* Determine if pressure recalibration of
+                                        worn pens should be performed */
 
        int bufpos;                        /* position with buffer */
        unsigned char buffer[BUFFER_SIZE]; /* data read from device */
diff --git a/tools/xsetwacom.c b/tools/xsetwacom.c
index bbe25ea..4e062e8 100644
--- a/tools/xsetwacom.c
+++ b/tools/xsetwacom.c
@@ -433,6 +433,15 @@ static param_t parameters[] =
                .prop_flags = PROP_FLAG_READONLY
        },
        {
+               .name = "PressureRecalibration",
+               .desc = "Turns on/off Tablet pressure recalibration",
+               .prop_name = WACOM_PROP_PRESSURE_RECAL,
+               .prop_format = 8,
+               .prop_offset = 0,
+               .arg_count = 1,
+               .prop_flags = PROP_FLAG_BOOLEAN | PROP_FLAG_INVERTED
+       },
+       {
                .name = "MapToOutput",
                .desc = "Map the device to the given output. ",
                .set_func = set_output,
@@ -2791,7 +2800,7 @@ static void test_parameter_number(void)
         * deprecated them.
         * Numbers include trailing NULL entry.
         */
-       assert(ARRAY_SIZE(parameters) == 37);
+       assert(ARRAY_SIZE(parameters) == 38);
        assert(ARRAY_SIZE(deprecated_parameters) == 17);
 }
 
-- 
1.8.1.4


------------------------------------------------------------------------------
Android apps run on BlackBerry 10
Introducing the new BlackBerry 10.2.1 Runtime for Android apps.
Now with support for Jelly Bean, Bluetooth, Mapview and more.
Get your Android app in front of a whole new audience.  Start now.
http://pubads.g.doubleclick.net/gampad/clk?id=124407151&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