summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEgbert Eich <eich@suse.com>2014-02-17 11:08:42 +0100
committerEgbert Eich <eich@suse.com>2014-02-19 14:08:58 +0100
commit67b403d9d927919132ea8c022860f6ffcc70ded4 (patch)
treec41f629ebedbb959859f8c36b8c17d8a73e83329
parent44e479042f612d02c754c16ace09761971aaf66c (diff)
Add an option to disable pressure recalibrationtesting
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 <eich@suse.com>
-rw-r--r--include/wacom-properties.h4
-rw-r--r--man/wacom.man10
-rw-r--r--man/xsetwacom.man9
-rw-r--r--src/wcmCommon.c11
-rw-r--r--src/wcmValidateDevice.c6
-rw-r--r--src/wcmXCommand.c23
-rw-r--r--src/xf86WacomDefs.h2
-rw-r--r--test/wacom-tests.c1
-rw-r--r--tools/xsetwacom.c11
9 files changed, 72 insertions, 5 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 afc09f9..f0c1cd1 100644
--- a/src/wcmCommon.c
+++ b/src/wcmCommon.c
@@ -1071,12 +1071,15 @@ normalizePressure(const WacomDevicePtr priv, const WacomDeviceState *ds)
WacomCommonPtr common = priv->common;
double pressure;
int p = ds->pressure;
- int range_left;
+ int range_left = common->wcmMaxZ;
+ if (common->wcmPressureRecalibration) {
+ p -= priv->minPressure;
+ range_left -= priv->minPressure;
+ }
/* normalize pressure to 0..FILTER_PRESSURE_RES */
- range_left = common->wcmMaxZ - priv->minPressure;
if (range_left >= 1)
- pressure = xf86ScaleAxis(p - priv->minPressure,
+ pressure = xf86ScaleAxis(p,
FILTER_PRESSURE_RES, 0,
range_left,
0);
@@ -1478,7 +1481,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 eb94d92..896ce92 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 afe6543..93a6593 100644
--- a/src/xf86WacomDefs.h
+++ b/src/xf86WacomDefs.h
@@ -487,6 +487,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/test/wacom-tests.c b/test/wacom-tests.c
index f44d3ab..59b5575 100644
--- a/test/wacom-tests.c
+++ b/test/wacom-tests.c
@@ -186,6 +186,7 @@ test_normalize_pressure(void)
priv.common = &common;
priv.pInfo = &pInfo;
pInfo.name = strdupa("Wacom test device");
+ common.wcmPressureRecalibration = 1;
priv.minPressure = 0;
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);
}