[PATCH] add two additional valuators: pressure and number of fingers down

Peter Hutterer peter.hutterer at who-t.net
Tue Oct 12 17:53:22 PDT 2010


yes to the pressure, no to the fingers down valuator. that is not a value
that should be exposed as an axis. it's better to provide this through
proper multitouch support.

On Tue, Oct 12, 2010 at 02:46:34PM -0400, Joe Shaw wrote:
> Signed-off-by: Joe Shaw <joe at joeshaw.org>
> ---
>  src/synaptics.c |   46 +++++++++++++++++++++++++++++++++++++++++++---
>  1 files changed, 43 insertions(+), 3 deletions(-)
> 
> diff --git a/src/synaptics.c b/src/synaptics.c
> index b490009..a1cbe87 100644
> --- a/src/synaptics.c
> +++ b/src/synaptics.c
> @@ -114,6 +114,8 @@ typedef enum {
>  
>  #define INPUT_BUFFER_SIZE 200
>  
> +#define NUM_AXES 4
> +
>  /*****************************************************************************
>   * Forward declaration
>   ****************************************************************************/
> @@ -926,6 +928,10 @@ static void InitAxesLabels(Atom *labels, int nlabels)
>      switch(nlabels)
>      {
>          default:
> +        case 4:
> +            labels[3] = None; // FIXME? Not sure how to do this given there's no corresponding property

/* */ c style comments please

> +        case 3:
> +            labels[2] = XIGetKnownProperty(AXIS_LABEL_PROP_ABS_PRESSURE);
>          case 2:
>              labels[1] = XIGetKnownProperty(AXIS_LABEL_PROP_REL_Y);
>          case 1:
> @@ -971,10 +977,10 @@ DeviceInit(DeviceIntPtr dev)
>      int min, max;
>  #if GET_ABI_MAJOR(ABI_XINPUT_VERSION) >= 7
>      Atom btn_labels[SYN_MAX_BUTTONS] = { 0 };
> -    Atom axes_labels[2] = { 0 };
> +    Atom axes_labels[NUM_AXES] = { 0 };
>      DeviceVelocityPtr pVel;
>  
> -    InitAxesLabels(axes_labels, 2);
> +    InitAxesLabels(axes_labels, NUM_AXES);

At this point, has_pressure is set, so this needs to be conditional on
whether the touchpad reports pressure.

>      InitButtonLabels(btn_labels, SYN_MAX_BUTTONS);
>  #endif
>  
> @@ -991,7 +997,7 @@ DeviceInit(DeviceIntPtr dev)
>                              btn_labels,
>  #endif
>  			    SynapticsCtrl,
> -			    GetMotionHistorySize(), 2
> +			    GetMotionHistorySize(), NUM_AXES
>  #if GET_ABI_MAJOR(ABI_XINPUT_VERSION) >= 7
>                              , axes_labels
>  #endif
> @@ -1076,6 +1082,37 @@ DeviceInit(DeviceIntPtr dev)
>              min, max, priv->resy * 1000, 0, priv->resy * 1000);
>      xf86InitValuatorDefaults(dev, 1);
>  
> +    /* Z/pressure valuator */
> +    if (priv->minp < priv->maxp)
> +    {
> +        min = priv->minp;
> +        max = priv->maxp;
> +    } else
> +    {
> +        min = 0;
> +        max = -1;
> +    }
> +
> +    xf86InitValuatorAxisStruct(dev, 2,
> +#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) >= 7
> +            axes_labels[2],
> +#endif
> +            min, max, 1, 0, 1);
> +    xf86InitValuatorDefaults(dev, 2);

same for this bit, conditional on has_pressure please.

> +
> +    /* Valuator for number of fingers */
> +    xf86InitValuatorAxisStruct(dev, 3,
> +#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) >= 7
> +            axes_labels[3],
> +#endif
> +            0, 3, /* Supports up to 3 fingers for now */
> +            1, 0, 1);
> +    xf86InitValuatorDefaults(dev, 3);
> +
> +#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) == 0
> +    xf86MotionHistoryAllocate(local);
> +#endif
> +

we don't support ABI 0 anymore, so you can skip the last few lines.

>      if (!alloc_param_data(pInfo))
>  	return !Success;
>  
> @@ -2461,6 +2498,9 @@ HandleState(InputInfoPtr pInfo, struct SynapticsHwState *hw)
>          }
>      }
>  
> +    if (inside_active_area)
> +        xf86PostMotionEvent(local->dev, 1, 2, 2, hw->z, hw->numFingers);
> +

Please post the pressure as part of the other events, there's no need for a
separate event.

Cheers,
  Peter

>      if (priv->mid_emu_state == MBE_LEFT_CLICK)
>      {
>  	post_button_click(pInfo, 1);
> -- 
> 1.7.3.1



More information about the xorg-devel mailing list