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_PRESSUREHOLD            3       /* 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
> +++ b/src/xf86Wacom.c
> @@ -436,6 +436,7 @@ static int wcmDevInit(DeviceIntPtr pWcm)
>       {
>               wcmInitialToolSize(pInfo);
>               wcmMappingFactor(pInfo);
> +             priv->holdPressure = -1;
>       }
>  
>       if (!wcmInitAxes(pWcm))
> diff --git a/src/xf86WacomDefs.h b/src/xf86WacomDefs.h
> index 94eee2e..9980202 100644
> --- a/src/xf86WacomDefs.h
> +++ b/src/xf86WacomDefs.h
> @@ -320,6 +320,12 @@ struct _WacomDeviceRec
>       Atom strip_actions[4];
>  
>       OsTimerPtr serial_timer; /* timer used for serial number property 
> update */
> +
> +     /* If negative, pressure hold is disabled and the driver will report
> +      * actual HW pressure. Otherwise, pressure hold is enabled and the
> +      * value contained is used in lieu of HW pressure.
> +      */
> +     int holdPressure;
>  };
>  
>  
> /******************************************************************************
> diff --git a/tools/xsetwacom.c b/tools/xsetwacom.c
> index e8cc8db..4438b4a 100644
> --- a/tools/xsetwacom.c
> +++ b/tools/xsetwacom.c
> @@ -861,6 +861,7 @@ static int special_map_button(Display *dpy, int argc, 
> char **argv, unsigned long
>  static int special_map_core(Display *dpy, int argc, char **argv, unsigned 
> long *ndata, unsigned long *data);
>  static int special_map_modetoggle(Display *dpy, int argc, char **argv, 
> unsigned long *ndata, unsigned long *data);
>  static int special_map_displaytoggle(Display *dpy, int argc, char **argv, 
> unsigned long *ndata, unsigned long *data);
> +static int special_map_pressurehold(Display *dpy, int argc, char **argv, 
> unsigned long *ndata, unsigned long *data);
>  
>  /* Valid keywords for the --set ButtonX options */
>  struct keywords {
> @@ -872,6 +873,7 @@ struct keywords {
>       {"core", special_map_core},
>       {"modetoggle", special_map_modetoggle},
>       {"displaytoggle", special_map_displaytoggle},
> +     {"pressurehold", special_map_pressurehold},
>       { NULL, NULL }
>  };
>  
> @@ -907,6 +909,15 @@ static int special_map_displaytoggle(Display *dpy, int 
> argc, char **argv, unsign
>       return 0;
>  }
>  
> +static int special_map_pressurehold(Display *dpy, int argc, char **argv, 
> unsigned long *ndata, unsigned long *data)
> +{
> +     data[*ndata] = AC_CUSTOM | CODE_PRESSUREHOLD;
> +
> +     *ndata += 1;
> +
> +     return 0;
> +}
> +
>  static inline int is_valid_keyword(const char *keyword)
>  {
>       struct keywords *kw = keywords;
> -- 
> 1.7.6
> 
> 
> ------------------------------------------------------------------------------
> FREE DOWNLOAD - uberSVN with Social Coding for Subversion.
> Subversion made easy with a complete admin console. Easy 
> to use, easy to manage, easy to install, easy to extend. 
> Get a Free download of the new open ALM Subversion platform now.
> http://p.sf.net/sfu/wandisco-dev2dev
> _______________________________________________
> Linuxwacom-devel mailing list
> Linuxwacom-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/linuxwacom-devel
> 

------------------------------------------------------------------------------
Get a FREE DOWNLOAD! and learn more about uberSVN rich system, 
user administration capabilities and model configuration. Take 
the hassle out of deploying and managing Subversion and the 
tools developers use with it. http://p.sf.net/sfu/wandisco-d2d-2
_______________________________________________
Linuxwacom-devel mailing list
Linuxwacom-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxwacom-devel

Reply via email to