[PATCH synaptics] Use ABS_MT events for the palm detection when supported

Peter Hutterer peter.hutterer at who-t.net
Tue Sep 16 22:38:22 PDT 2014


On Tue, Sep 16, 2014 at 05:20:15PM +0200, Gabriele Mazzotta wrote:
> Use ABS_MT_TOUCH_MAJOR and ABS_MT_PRESSURE instead of ABS_TOOL_WIDTH
> and ABS_PRESSURE when supported so that the pressure and the width of
> all the fingers is taken into account for the palm detection.
> 
> This also fixes the palm detection for those touchpads for which the
> kernel only sends ABS_MT_TOUCH_MAJOR and not ABS_TOOL_WIDTH.
> 
> Signed-off-by: Gabriele Mazzotta <gabriele.mzt at gmail.com>
> ---
> I didn't modify the existing code of the palm detection to handle
> multiple fingers. Relying on just the pressure and the width
> thresholds to detect palms proved to be enough, so I opted for a
> a quick solution that doesn't require major code changes.

thanks. I don't have a touchpad to test that with but it looks fine.

   41b2312..a897147  master -> master

Cheers,
   Peter

> 
>  src/eventcomm.c | 12 ++++++++++++
>  src/synaptics.c |  3 +++
>  2 files changed, 15 insertions(+)
> 
> diff --git a/src/eventcomm.c b/src/eventcomm.c
> index 37f16b2..5b18c44 100644
> --- a/src/eventcomm.c
> +++ b/src/eventcomm.c
> @@ -606,6 +606,14 @@ EventProcessTouchEvent(InputInfoPtr pInfo, struct SynapticsHwState *hw,
>                  hw->slot_state[slot_index] = SLOTSTATE_CLOSE;
>                  proto_data->num_touches--;
>              }
> +
> +            /* When there are no fingers on the touchpad, set width and
> +             * pressure to zero as ABS_MT_TOUCH_MAJOR and ABS_MT_PRESSURE
> +             * are not zero when fingers are released. */
> +            if (proto_data->num_touches == 0) {
> +                hw->fingerWidth = 0;
> +                hw->z = 0;
> +            }
>          }
>          else {
>              ValuatorMask *mask = proto_data->last_mt_vals[slot_index];
> @@ -618,6 +626,10 @@ EventProcessTouchEvent(InputInfoPtr pInfo, struct SynapticsHwState *hw,
>                      hw->cumulative_dx += ev->value - last_val;
>                  else if (ev->code == ABS_MT_POSITION_Y)
>                      hw->cumulative_dy += ev->value - last_val;
> +                else if (ev->code == ABS_MT_TOUCH_MAJOR)
> +                    hw->fingerWidth = ev->value;
> +                else if (ev->code == ABS_MT_PRESSURE)
> +                    hw->z = ev->value;
>              }
>  
>              valuator_mask_set(mask, map, ev->value);
> diff --git a/src/synaptics.c b/src/synaptics.c
> index 1b1ac64..2746565 100644
> --- a/src/synaptics.c
> +++ b/src/synaptics.c
> @@ -1857,6 +1857,9 @@ SynapticsDetectFinger(SynapticsPrivate * priv, struct SynapticsHwState *hw)
>      if ((hw->z > para->palm_min_z) && (hw->fingerWidth > para->palm_min_width))
>          return FS_BLOCKED;
>  
> +    if (priv->has_touch)
> +        return finger;
> +
>      if (hw->x == 0 || priv->finger_state == FS_UNTOUCHED)
>          priv->avg_width = 0;
>      else
> -- 
> 2.1.0
> 


More information about the xorg-devel mailing list