Re: [Linuxwacom-devel] [PATCH 2/3] Add pressure hold to driver and xsetwacom

2011-08-22 Thread Peter Hutterer
On Fri, Aug 12, 2011 at 04:01:07PM -0700, Jason Gerecke wrote:
 This patch allows setting a button to a pressure hold switch.
 While the button is held, the pressure reported by the driver
 will remain at the level it was just before the button was
 pressed. When released, normal operation continues.
 
 Pressure hold is implemented by adding a 'holdPressure' variable
 to the _WacomDeviceRec struct. If non-negative, the driver will
 ignore the hardware pressure and report its value instead.

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

Cheers,
  Peter

 ---
  include/Xwacom.h|1 +
  man/xsetwacom.man   |   11 ++-
  src/wcmCommon.c |   15 +++
  src/xf86Wacom.c |1 +
  src/xf86WacomDefs.h |6 ++
  tools/xsetwacom.c   |   11 +++
  6 files changed, 40 insertions(+), 5 deletions(-)
 
 diff --git a/include/Xwacom.h b/include/Xwacom.h
 index 16ab578..f135ae3 100644
 --- a/include/Xwacom.h
 +++ b/include/Xwacom.h
 @@ -69,5 +69,6 @@
  
  #define CODE_MODETOGGLE  1   /* AC_CUSTOM toggle 
 absolute/relative mode */
  #define CODE_DISPLAYTOGGLE   2   /* AC_CUSTOM toggle among 
 screens */
 +#define CODE_PRESSUREHOLD3   /* AC_CUSTOM hold last hardware 
 pressure */
  
  #endif /* __XORG_XWACOM_H */
 diff --git a/man/xsetwacom.man b/man/xsetwacom.man
 index 539f405..d28a416 100644
 --- a/man/xsetwacom.man
 +++ b/man/xsetwacom.man
 @@ -107,11 +107,12 @@ should correspond to. For example, a mapping of 3 
 means a press of the given
  button-number will produce as a press of X11 button 3 (i.e. right click).
  
  Action mappings allow button presses to perform many events. They take the 
 form
 -of a string of keywords and arguments. For example, key +a +shift b -shift 
 -a
 -converts the button into a series of keystrokes, in this example press a, 
 press
 -shift, press and release b, release shift, release a. In addition to the 
 key
 -keyword, button and modetoggle are also recognized. Multiple keywords may
 -be present in one action if desired: for example key +ctrl button 5 key 
 -ctrl.
 +of a string of keywords and arguments. Recognized keywords include: key,
 +button, modetoggle, and pressurehold. Each keyword may have multiple
 +arguments. For example, key +a +shift b -shift -a converts the button
 +press into a series of keystrokes, in this example press a, press
 +shift, press and release b, release shift, release a. A single action may
 +consist of keywords as well; for example: key +ctrl button 5 key -ctrl.
  .TP
  \fBBindToSerial\fR [serial|0]
  Bind the device to the tool with the specified serial number. Once bound,
 diff --git a/src/wcmCommon.c b/src/wcmCommon.c
 index 4fb0610..341ea7c 100644
 --- a/src/wcmCommon.c
 +++ b/src/wcmCommon.c
 @@ -203,6 +203,7 @@ static void sendAction(InputInfoPtr pInfo, int press,
  unsigned int *keys, int nkeys,
  int first_val, int num_val, int *valuators)
  {
 + WacomDevicePtr priv = (WacomDevicePtr)pInfo-private;
   int i;
  
   /* Actions only trigger on press, not release */
 @@ -256,6 +257,10 @@ static void sendAction(InputInfoPtr pInfo, int press,
   
 wcmDevSwitchModeCall(pInfo,
   
 (is_absolute(pInfo)) ? Relative : Absolute); /* not a typo! */
   break;
 + case CODE_PRESSUREHOLD:
 + priv-holdPressure = priv-oldZ;
 + DBG(4, priv, Pressure hold 
 ENABLED at p=%d\n, priv-holdPressure);
 + break;
   }
   }
   }
 @@ -309,6 +314,14 @@ static void sendAction(InputInfoPtr pInfo, int press,
   if (countPresses(key_code, keys[i], 
 nkeys - i))
   wcmEmitKeycode(pInfo-dev, 
 key_code, 0);
   }
 + case AC_CUSTOM:
 + switch (action  AC_CODE)
 + {
 + case CODE_PRESSUREHOLD:
 + priv-holdPressure = -1;
 + DBG(4, priv, Pressure hold 
 DISABLED\n);
 + break;
 + }
   }
  
   }
 @@ -1210,6 +1223,8 @@ static void commonDispatchDevice(WacomCommonPtr common, 
 unsigned int channel,
   if (IsPen(priv))
   filtered.buttons = setPressureButton(priv, filtered);
   filtered.pressure = applyPressureCurve(priv,filtered);
 + if (priv-holdPressure = 0)
 + filtered.pressure = priv-holdPressure;
   if 

[Linuxwacom-devel] [PATCH 2/3] Add pressure hold to driver and xsetwacom

2011-08-12 Thread Jason Gerecke
This patch allows setting a button to a pressure hold switch.
While the button is held, the pressure reported by the driver
will remain at the level it was just before the button was
pressed. When released, normal operation continues.

Pressure hold is implemented by adding a 'holdPressure' variable
to the _WacomDeviceRec struct. If non-negative, the driver will
ignore the hardware pressure and report its value instead.
---
 include/Xwacom.h|1 +
 man/xsetwacom.man   |   11 ++-
 src/wcmCommon.c |   15 +++
 src/xf86Wacom.c |1 +
 src/xf86WacomDefs.h |6 ++
 tools/xsetwacom.c   |   11 +++
 6 files changed, 40 insertions(+), 5 deletions(-)

diff --git a/include/Xwacom.h b/include/Xwacom.h
index 16ab578..f135ae3 100644
--- a/include/Xwacom.h
+++ b/include/Xwacom.h
@@ -69,5 +69,6 @@
 
 #define CODE_MODETOGGLE  1 /* AC_CUSTOM toggle absolute/relative 
mode */
 #define CODE_DISPLAYTOGGLE   2 /* AC_CUSTOM toggle among screens */
+#define CODE_PRESSUREHOLD3 /* AC_CUSTOM hold last hardware 
pressure */
 
 #endif /* __XORG_XWACOM_H */
diff --git a/man/xsetwacom.man b/man/xsetwacom.man
index 539f405..d28a416 100644
--- a/man/xsetwacom.man
+++ b/man/xsetwacom.man
@@ -107,11 +107,12 @@ should correspond to. For example, a mapping of 3 means 
a press of the given
 button-number will produce as a press of X11 button 3 (i.e. right click).
 
 Action mappings allow button presses to perform many events. They take the form
-of a string of keywords and arguments. For example, key +a +shift b -shift -a
-converts the button into a series of keystrokes, in this example press a, 
press
-shift, press and release b, release shift, release a. In addition to the key
-keyword, button and modetoggle are also recognized. Multiple keywords may
-be present in one action if desired: for example key +ctrl button 5 key 
-ctrl.
+of a string of keywords and arguments. Recognized keywords include: key,
+button, modetoggle, and pressurehold. Each keyword may have multiple
+arguments. For example, key +a +shift b -shift -a converts the button
+press into a series of keystrokes, in this example press a, press
+shift, press and release b, release shift, release a. A single action may
+consist of keywords as well; for example: key +ctrl button 5 key -ctrl.
 .TP
 \fBBindToSerial\fR [serial|0]
 Bind the device to the tool with the specified serial number. Once bound,
diff --git a/src/wcmCommon.c b/src/wcmCommon.c
index 4fb0610..341ea7c 100644
--- a/src/wcmCommon.c
+++ b/src/wcmCommon.c
@@ -203,6 +203,7 @@ static void sendAction(InputInfoPtr pInfo, int press,
   unsigned int *keys, int nkeys,
   int first_val, int num_val, int *valuators)
 {
+   WacomDevicePtr priv = (WacomDevicePtr)pInfo-private;
int i;
 
/* Actions only trigger on press, not release */
@@ -256,6 +257,10 @@ static void sendAction(InputInfoPtr pInfo, int press,

wcmDevSwitchModeCall(pInfo,

(is_absolute(pInfo)) ? Relative : Absolute); /* not a typo! */
break;
+   case CODE_PRESSUREHOLD:
+   priv-holdPressure = priv-oldZ;
+   DBG(4, priv, Pressure hold 
ENABLED at p=%d\n, priv-holdPressure);
+   break;
}
}
}
@@ -309,6 +314,14 @@ static void sendAction(InputInfoPtr pInfo, int press,
if (countPresses(key_code, keys[i], 
nkeys - i))
wcmEmitKeycode(pInfo-dev, 
key_code, 0);
}
+   case AC_CUSTOM:
+   switch (action  AC_CODE)
+   {
+   case CODE_PRESSUREHOLD:
+   priv-holdPressure = -1;
+   DBG(4, priv, Pressure hold 
DISABLED\n);
+   break;
+   }
}
 
}
@@ -1210,6 +1223,8 @@ static void commonDispatchDevice(WacomCommonPtr common, 
unsigned int channel,
if (IsPen(priv))
filtered.buttons = setPressureButton(priv, filtered);
filtered.pressure = applyPressureCurve(priv,filtered);
+   if (priv-holdPressure = 0)
+   filtered.pressure = priv-holdPressure;
if (IsPen(priv))
common-wcmPenInProx = filtered.proximity;
}
diff --git a/src/xf86Wacom.c b/src/xf86Wacom.c
index 16561b5..8090e8d 100644
--- a/src/xf86Wacom.c
+++