[PATCH xf86-input-synaptics 10/12] Add right button area property

Peter Hutterer peter.hutterer at who-t.net
Wed Feb 22 19:58:56 PST 2012


On Thu, Feb 09, 2012 at 06:53:04PM -0800, Chase Douglas wrote:
> Some clickpad devices have a right button area painted on them. Set this
> property to the area of the right button to enable right click actions
> when tapping or clicking in this area.
> 
> Signed-off-by: Chase Douglas <chase.douglas at canonical.com>
> ---
>  include/synaptics-properties.h |    3 ++
>  man/synaptics.man              |   45 ++++++++++++++++++++++++++++++++++++++++
>  src/properties.c               |   21 ++++++++++++++++++
>  src/synaptics.c                |   28 ++++++++++++++++++++++++-
>  src/synapticsstr.h             |    1 +
>  5 files changed, 97 insertions(+), 1 deletions(-)
> 
> diff --git a/include/synaptics-properties.h b/include/synaptics-properties.h
> index 712a10b..0a253b2 100644
> --- a/include/synaptics-properties.h
> +++ b/include/synaptics-properties.h
> @@ -161,6 +161,9 @@
>  /* 32 bit, 4 values, left, right, top, bottom */
>  #define SYNAPTICS_PROP_AREA "Synaptics Area"
>  
> +/* 32 bit, 4 values, left, right, top, buttom */
> +#define SYNAPTICS_PROP_RIGHTBUTTON_AREA "Synaptics Right Button Area"
> +

AFAIK, some devices have a middle button painted on too, so this needs to be
more flexible. How about a property that takes sets of 4 coordinates for
each button, with the driver deciding whether it's the right button or right
+ middle based on the number of values in the property? 

Cheers,
  Peter

>  /* 32 Bit Integer, 2 values, horizontal hysteresis, vertical hysteresis */
>  #define SYNAPTICS_PROP_NOISE_CANCELLATION "Synaptics Noise Cancellation"
>  
> diff --git a/man/synaptics.man b/man/synaptics.man
> index 9721038..99349a9 100644
> --- a/man/synaptics.man
> +++ b/man/synaptics.man
> @@ -526,6 +526,42 @@ AreaBottomEdge option to any integer value other than zero. If supported by the
>  server (version 1.9 and later), the edge may be specified in percent of
>  the total height of the touchpad. Property: "Synaptics Area"
>  .
> +.TP
> +.BI "Option \*qRightbuttonLeftEdge\*q \*q" integer \*q
> +Treat taps and clickpad presses which take place left of this position as right
> +button actions.
> +.
> +If supported by the server (version 1.9 and later), the edge may be specified in
> +percent of the total width of the touchpad. Property "Synaptics Right Button
> +Area".
> +.
> +.TP
> +.BI "Option \*qRightbuttonRightEdge\*q \*q" integer \*q
> +Treat taps and clickpad presses which take place right of this position as right
> +button actions.
> +.
> +If supported by the server (version 1.9 and later), the edge may be specified in
> +percent of the total width of the touchpad. Property "Synaptics Right Button
> +Area".
> +.
> +.TP
> +.BI "Option \*qRightbuttonTopEdge\*q \*q" integer \*q
> +Treat taps and clickpad presses which take place above this position as right
> +button actions.
> +.
> +If supported by the server (version 1.9 and later), the edge may be specified in
> +percent of the total height of the touchpad. Property "Synaptics Right Button
> +Area".
> +.
> +.TP
> +.BI "Option \*qRightbuttonBottomEdge\*q \*q" integer \*q
> +Treat taps and clickpad presses which take place below this position as right
> +button actions.
> +.
> +If supported by the server (version 1.9 and later), the edge may be specified in
> +percent of the total height of the touchpad. Property "Synaptics Right Button
> +Area".
> +.
>  
>  .SH CONFIGURATION DETAILS
>  .SS Area handling
> @@ -939,6 +975,15 @@ default.
>  32 bit, 4 values, left, right, top, bottom. 0 disables an element.
>  
>  .TP 7
> +.BI "Synaptics Right Button Area"
> +The RightbuttonLeftEdge, RightbuttonRightEdge, RightbuttonTopEdge and
> +RightbuttonBottomEdge parameters are used to define the area of the right button
> +of a clickpad. Taps and presses in this area are treated as right button
> +actions. Taps and presses anywhere else are treated as left button actions.
> +
> +32 bit, 4 values, left, right, top, bottom. 0 disables an element.
> +
> +.TP 7
>  .BI "Synaptics Capabilities"
>  This read-only property expresses the physical capability of the touchpad,
>  most notably whether the touchpad hardware supports multi-finger tapping and
> diff --git a/src/properties.c b/src/properties.c
> index f1bda8e..37d23ab 100644
> --- a/src/properties.c
> +++ b/src/properties.c
> @@ -93,6 +93,7 @@ Atom prop_gestures              = 0;
>  Atom prop_capabilities          = 0;
>  Atom prop_resolution            = 0;
>  Atom prop_area                  = 0;
> +Atom prop_rightbutton_area      = 0;
>  Atom prop_noise_cancellation    = 0;
>  Atom prop_product_id            = 0;
>  Atom prop_device_node           = 0;
> @@ -304,6 +305,12 @@ InitDeviceProperties(InputInfoPtr pInfo)
>      values[3] = para->area_bottom_edge;
>      prop_area = InitAtom(pInfo->dev, SYNAPTICS_PROP_AREA, 32, 4, values);
>  
> +    values[0] = para->rightbutton_left_edge;
> +    values[1] = para->rightbutton_right_edge;
> +    values[2] = para->rightbutton_top_edge;
> +    values[3] = para->rightbutton_bottom_edge;
> +    prop_rightbutton_area = InitAtom(pInfo->dev, SYNAPTICS_PROP_RIGHTBUTTON_AREA, 32, 4, values);
> +
>      values[0] = para->hyst_x;
>      values[1] = para->hyst_y;
>      prop_noise_cancellation = InitAtom(pInfo->dev,
> @@ -720,6 +727,20 @@ SetProperty(DeviceIntPtr dev, Atom property, XIPropertyValuePtr prop,
>          para->area_right_edge  = area[1];
>          para->area_top_edge    = area[2];
>          para->area_bottom_edge = area[3];
> +    } else if (property == prop_rightbutton_area)
> +    {
> +        INT32 *area;
> +        if (prop->size != 4 || prop->format != 32 || prop->type != XA_INTEGER)
> +            return BadMatch;
> +
> +        area = (INT32*)prop->data;
> +        if ((((area[0] != 0) && (area[1] != 0)) && (area[0] > area[1]) ) || (((area[2] != 0) && (area[3] != 0)) && (area[2] > area[3])))
> +            return BadValue;
> +
> +        para->rightbutton_left_edge   = area[0];
> +        para->rightbutton_right_edge  = area[1];
> +        para->rightbutton_top_edge    = area[2];
> +        para->rightbutton_bottom_edge = area[3];
>      } else if (property == prop_noise_cancellation) {
>          INT32 *hyst;
>          if (prop->size != 2 || prop->format != 32 || prop->type != XA_INTEGER)
> diff --git a/src/synaptics.c b/src/synaptics.c
> index 4a3b46f..dd138ea 100644
> --- a/src/synaptics.c
> +++ b/src/synaptics.c
> @@ -524,6 +524,11 @@ static void set_default_parameters(InputInfoPtr pInfo)
>      pars->area_left_edge = set_percent_option(opts, "AreaLeftEdge", width, priv->minx, 0);
>      pars->area_right_edge = set_percent_option(opts, "AreaRightEdge", width, priv->minx, 0);
>  
> +    pars->rightbutton_top_edge = set_percent_option(opts, "RightbuttonTopEdge", height, priv->miny, 0);
> +    pars->rightbutton_bottom_edge = set_percent_option(opts, "RightbuttonBottomEdge", height, priv->miny, 0);
> +    pars->rightbutton_left_edge = set_percent_option(opts, "RightbuttonLeftEdge", width, priv->minx, 0);
> +    pars->rightbutton_right_edge = set_percent_option(opts, "RightbuttonRightEdge", width, priv->minx, 0);
> +
>      pars->hyst_x = set_percent_option(opts, "HorizHysteresis", width, 0, horizHyst);
>      pars->hyst_y = set_percent_option(opts, "VertHysteresis", height, 0, vertHyst);
>  
> @@ -1347,6 +1352,24 @@ is_inside_active_area(SynapticsPrivate *priv, int x, int y)
>      return inside_area;
>  }
>  
> +static Bool
> +is_inside_rightbutton_area(SynapticsParameters *para, int x, int y)
> +{
> +    Bool inside_area = TRUE;
> +
> +    if (x < para->rightbutton_left_edge)
> +	inside_area = FALSE;
> +    else if (x > para->rightbutton_right_edge)
> +	inside_area = FALSE;
> +
> +    if (y < para->rightbutton_top_edge)
> +	inside_area = FALSE;
> +    else if (y > para->rightbutton_bottom_edge)
> +	inside_area = FALSE;
> +
> +    return inside_area;
> +}
> +
>  static CARD32
>  timerFunc(OsTimerPtr timer, CARD32 now, pointer arg)
>  {
> @@ -1557,7 +1580,10 @@ handle_clickfinger(SynapticsParameters *para, struct SynapticsHwState *hw)
>      int action = 0;
>      switch(hw->numFingers){
>          case 1:
> -            action = para->click_action[F1_CLICK1];
> +            if (is_inside_rightbutton_area(para, hw->x, hw->y))
> +                action = para->click_action[F2_CLICK1];
> +            else
> +                action = para->click_action[F1_CLICK1];
>              break;
>          case 2:
>              action = para->click_action[F2_CLICK1];
> diff --git a/src/synapticsstr.h b/src/synapticsstr.h
> index 3ea30fe..1f19880 100644
> --- a/src/synapticsstr.h
> +++ b/src/synapticsstr.h
> @@ -182,6 +182,7 @@ typedef struct _SynapticsParameters
>      unsigned int resolution_horiz;          /* horizontal resolution of touchpad in units/mm */
>      unsigned int resolution_vert;           /* vertical resolution of touchpad in units/mm */
>      int area_left_edge, area_right_edge, area_top_edge, area_bottom_edge; /* area coordinates absolute */
> +    int rightbutton_left_edge, rightbutton_right_edge, rightbutton_top_edge, rightbutton_bottom_edge; /* right button area coordinates absolute */
>      int hyst_x, hyst_y;                     /* x and y width of hysteresis box */
>  } SynapticsParameters;
>  
> -- 
> 1.7.8.3
> 


More information about the xorg-devel mailing list