I ack on patch concept.  Its easy to see this invalid data on
synaptics hardware and needs to be accounted for.

I'm not up on current proximity support in evdev but patch makes sense
overall.  Just two comments to consider.

1) Will BTN_TOUCH always be sent when you need it to?  I'm wondering
if an if() is needed at BTN_TOOL_FINGER to prevent in_proximity from
being set in first place.  The below is needed to re-turn it back on.

2) Touchscreens have same concept.  Until BTN_TOUCH, it would be
safest to ignore the reported X/Y values.  Of course, majority of
touchscreens do not send BTN_TOOL_FINGER right now but that will
change I think.

Chris

On Mon, Dec 20, 2010 at 7:21 PM, Peter Hutterer
<[email protected]> wrote:
> Touchpads send garbage data between BTN_TOOL_FINGER and BTN_TOUCH. This
> leads to cursor movement towards invalid positions (bottom left corner,
> usually).
>
> Add a new flag "use_proximity" as a delimiter for BTN_TOUCH handling. If
> unset, the actual proximity bits are ignored, no proximity events are sent
> and BTN_TOUCH is used for the tool handling.
>
> Example event stream for synaptics:
>
> Event: time 1292893041.002731, -------------- Report Sync ------------
> Event: time 1292893041.015807, type 1 (Key), code 330 (Touch), value 0
> Event: time 1292893041.015812, type 3 (Absolute), code 0 (X), value 4283
> Event: time 1292893041.015813, type 3 (Absolute), code 1 (Y), value 4860
> Event: time 1292893041.015815, type 3 (Absolute), code 24 (Pressure), value 23
> Event: time 1292893041.015817, type 3 (Absolute), code 28 (Tool Width), value 
> 5
> Event: time 1292893041.027537, -------------- Report Sync ------------
> Event: time 1292893041.038854, type 3 (Absolute), code 0 (X), value 1
> Event: time 1292893041.038857, type 3 (Absolute), code 1 (Y), value 5855
> Event: time 1292893041.038859, type 3 (Absolute), code 24 (Pressure), value 1
> Event: time 1292893041.038861, type 3 (Absolute), code 28 (Tool Width), value 
> 5
> Event: time 1292893041.038864, -------------- Report Sync ------------
> Event: time 1292893041.062432, type 3 (Absolute), code 24 (Pressure), value 0
> Event: time 1292893041.062435, type 3 (Absolute), code 28 (Tool Width), value > 0
> Event: time 1292893041.062437, type 1 (Key), code 325 (ToolFinger), value 0
> Event: time 1292893041.062438, -------------- Report Sync ------------
>
> Reported-by: Dave Airlie <[email protected]>
> Signed-off-by: Peter Hutterer <[email protected]>
> ---
>  src/evdev.c |   13 ++++++++++++-
>  src/evdev.h |    1 +
>  2 files changed, 13 insertions(+), 1 deletions(-)
>
> diff --git a/src/evdev.c b/src/evdev.c
> index b6591ce..50847a8 100644
> --- a/src/evdev.c
> +++ b/src/evdev.c
> @@ -486,6 +486,9 @@ EvdevProcessProximityEvent(InputInfoPtr pInfo, struct 
> input_event *ev)
>  {
>     EvdevPtr pEvdev = pInfo->private;
>
> +    if (!pEvdev->use_proximity)
> +        return;
> +
>     pEvdev->prox_queued = 1;
>
>     EvdevQueueProximityEvent(pInfo, ev->value);
> @@ -679,7 +682,10 @@ EvdevProcessKeyEvent(InputInfoPtr pInfo, struct 
> input_event *ev)
>
>     switch (ev->code) {
>         case BTN_TOUCH:
> -            pEvdev->in_proximity = value ? ev->code : 0;
> +            /* For devices that have but don't use proximity, use
> +             * BTN_TOUCH as the proximity notifier */
> +            if (!pEvdev->use_proximity)
> +                pEvdev->in_proximity = value ? ev->code : 0;
>             if (!(pEvdev->flags & (EVDEV_TOUCHSCREEN | EVDEV_TABLET)))
>                 break;
>             /* Treat BTN_TOUCH from devices that only have BTN_TOUCH as
> @@ -1346,6 +1352,9 @@ EvdevAddAbsClass(DeviceIntPtr device)
>
>     for (i = 0; i < ArrayLength(proximity_bits); i++)
>     {
> +        if (!pEvdev->use_proximity)
> +            break;
> +
>         if (TestBit(proximity_bits[i], pEvdev->key_bitmask))
>         {
>             InitProximityClassDeviceStruct(device);
> @@ -2039,6 +2048,7 @@ EvdevProbe(InputInfoPtr pInfo)
>        if (pEvdev->flags & EVDEV_TOUCHPAD) {
>            xf86Msg(X_INFO, "%s: Configuring as touchpad\n", pInfo->name);
>            pInfo->type_name = XI_TOUCHPAD;
> +           pEvdev->use_proximity = 0;
>        } else if (pEvdev->flags & EVDEV_TABLET) {
>            xf86Msg(X_INFO, "%s: Configuring as tablet\n", pInfo->name);
>            pInfo->type_name = XI_TABLET;
> @@ -2205,6 +2215,7 @@ EvdevPreInit(InputDriverPtr drv, InputInfoPtr pInfo, 
> int flags)
>      * proximity will still report events.
>      */
>     pEvdev->in_proximity = 1;
> +    pEvdev->use_proximity = 1;
>
>     /* Grabbing the event device stops in-kernel event forwarding. In other
>        words, it disables rfkill and the "Macintosh mouse button emulation".
> diff --git a/src/evdev.h b/src/evdev.h
> index b04f961..f640fdd 100644
> --- a/src/evdev.h
> +++ b/src/evdev.h
> @@ -126,6 +126,7 @@ typedef struct {
>
>     int flags;
>     int in_proximity;           /* device in proximity */
> +    int use_proximity;          /* using the proximity bit? */
>     int num_buttons;            /* number of buttons */
>     BOOL swap_axes;
>     BOOL invert_x;
> --
> 1.7.3.4
>
> _______________________________________________
> [email protected]: X.Org development
> Archives: http://lists.x.org/archives/xorg-devel
> Info: http://lists.x.org/mailman/listinfo/xorg-devel
>
_______________________________________________
[email protected]: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel

Reply via email to