[PATCH evdev 4/5] Dummy process MT events.

Peter Hutterer peter.hutterer at who-t.net
Thu Apr 8 22:44:27 PDT 2010


On Sun, Mar 28, 2010 at 01:58:12PM +0200, Benjamin Tissoires wrote:
> In case the driver receive a mt event, it stores it at the first
> available place, i.e. it does not overrides older mt values.
> 
> At the end, in the EV_SYNC event, it only send the values it has
> filled.
> 
> Signed-off-by: Benjamin Tissoires <tissoire at cena.fr>
> ---
>  src/evdev.c |   31 ++++++++++++++++++++++++++++---
>  src/evdev.h |    1 +
>  2 files changed, 29 insertions(+), 3 deletions(-)
> 
> diff --git a/src/evdev.c b/src/evdev.c
> index 7e59601..76af8dc 100644
> --- a/src/evdev.c
> +++ b/src/evdev.c
> @@ -422,6 +422,8 @@ EvdevProcessValuators(InputInfoPtr pInfo, int v[MAX_VALUATORS], int *num_v,
>       */
>      else if (pEvdev->abs && pEvdev->tool) {
>          memcpy(v, pEvdev->vals, sizeof(int) * pEvdev->num_vals);
> +        if (pEvdev->current_num_multitouch > EVDEV_MAX_TOUCHPOINTS)
> +            pEvdev->current_num_multitouch = EVDEV_MAX_TOUCHPOINTS;

do I understand this correctly that if you get 6 touchpoints the last one
overwrites touchpoint 5? is this preferable to just dropping them once they
overflow?

also, can we rename current_num_multitouch to mt_current_touchpoint?
otherwise this may get confused with the number of touchpoints supported by
the device.

>          if (pEvdev->swap_axes) {
>              int tmp = v[0];
> @@ -448,7 +450,8 @@ EvdevProcessValuators(InputInfoPtr pInfo, int v[MAX_VALUATORS], int *num_v,
>              v[1] = (pEvdev->absinfo[ABS_Y].maximum - v[1] +
>                      pEvdev->absinfo[ABS_Y].minimum);
>  
> -        *num_v = pEvdev->num_vals;
> +        *num_v = pEvdev->mt_first_axis +
> +                    pEvdev->current_num_multitouch * pEvdev->mt_num_valuators;

on an absolute, non-MT device this always gives you a num_v of 0?

>          *first_v = 0;
>      }
>  }
> @@ -551,7 +554,15 @@ EvdevProcessAbsoluteMotionEvent(InputInfoPtr pInfo, struct input_event *ev)
>      if (EvdevWheelEmuFilterMotion(pInfo, ev))
>          return;
>  
> -    pEvdev->vals[pEvdev->axis_map[ev->code]] = value;
> +    if (ev->code < ABS_MT_TOUCH_MAJOR)
> +        pEvdev->vals[pEvdev->axis_map[ev->code]] = value;
> +    else if (pEvdev->current_num_multitouch < EVDEV_MAX_TOUCHPOINTS) {
> +        /* MT value -> store it at the first available place */
> +        pEvdev->vals[pEvdev->axis_map[ev->code] +
> +                        pEvdev->current_num_multitouch * pEvdev->mt_num_valuators] = value;
> +    } else
> +        return; /* mt-event, but not enough place to store it */
> +
>      if (ev->code == ABS_X)
>          pEvdev->abs |= ABS_X_VALUE;
>      else if (ev->code == ABS_Y)
> @@ -693,6 +704,17 @@ EvdevProcessSyncEvent(InputInfoPtr pInfo, struct input_event *ev)
>      pEvdev->num_queue = 0;
>      pEvdev->abs = 0;
>      pEvdev->rel = 0;
> +    pEvdev->current_num_multitouch = 0;
> +}
> +
> +/**
> + * Take the mt-synchronization input event and process it accordingly.
> + */

meh. not the most descriptive comment. every time you see a "process it
accordingly" comment that just means that there was either nothing to say or
the developer was too lazy to say anything useful. You pick which one it is
in this case ;)

> +static void
> +EvdevProcessMTSyncReport(InputInfoPtr pInfo, struct input_event *ev)
> +{
> +    EvdevPtr pEvdev = pInfo->private;
> +    pEvdev->current_num_multitouch++;
>  }
>  
>  /**
> @@ -713,7 +735,10 @@ EvdevProcessEvent(InputInfoPtr pInfo, struct input_event *ev)
>              EvdevProcessKeyEvent(pInfo, ev);
>              break;
>          case EV_SYN:
> -            EvdevProcessSyncEvent(pInfo, ev);
> +            if (ev->code == SYN_MT_REPORT)
> +                EvdevProcessMTSyncReport(pInfo, ev);
> +            else
> +                EvdevProcessSyncEvent(pInfo, ev);
>              break;
>      }
>  }
> diff --git a/src/evdev.h b/src/evdev.h
> index 383a904..0dba366 100644
> --- a/src/evdev.h
> +++ b/src/evdev.h
> @@ -198,6 +198,7 @@ typedef struct {
>  
>      unsigned int mt_first_axis;
>      unsigned int mt_num_valuators;
> +    unsigned int current_num_multitouch;
>  } EvdevRec, *EvdevPtr;
>  
>  /* Event posting functions */
> -- 
> 1.6.6.1
> 
Cheers,
  Peter


More information about the xorg-devel mailing list