On Mon, Apr 21, 2014 at 07:11:25PM +0200, Carlos Garnacho wrote:
> Those are normalized to be in the [-1..1] range.
> 
> Signed-off-by: Carlos Garnacho <[email protected]>
> ---
>  src/evdev-tablet.c | 25 +++++++++++++++++++++++++
>  1 file changed, 25 insertions(+)
> 
> diff --git a/src/evdev-tablet.c b/src/evdev-tablet.c
> index 70f3210..cc55c74 100644
> --- a/src/evdev-tablet.c
> +++ b/src/evdev-tablet.c
> @@ -245,6 +245,16 @@ normalize_axis(const struct axis_info *axis_info)
>       double range = axis_info->abs.maximum - axis_info->abs.minimum;
>       double value = (axis_info->abs.value + axis_info->abs.minimum) / range;
>  
> +     switch (axis_info->axis) {
> +     case LIBINPUT_POINTER_AXIS_VERTICAL_TILT:
> +     case LIBINPUT_POINTER_AXIS_HORIZONTAL_TILT:
> +             /* Map to the (-1,1) range */
> +             value = (value * 2) - 1;
> +             break;
> +     default:
> +             break;
> +     }
> +
>       return value;
>  }
>  
> @@ -412,6 +422,19 @@ static struct evdev_dispatch_interface tablet_interface 
> = {
>       tablet_destroy
>  };
>  
> +static void
> +tablet_init_axes(struct tablet_dispatch *tablet,
> +              struct evdev_device *device)
> +{
> +     if (libevdev_has_event_code(device->evdev, EV_ABS, ABS_TILT_X) &&
> +         libevdev_has_event_code(device->evdev, EV_ABS, ABS_TILT_Y)) {
> +             tablet_add_axis(tablet, device, ABS_TILT_X,
> +                             LIBINPUT_POINTER_AXIS_HORIZONTAL_TILT);
> +             tablet_add_axis(tablet, device, ABS_TILT_Y,
> +                             LIBINPUT_POINTER_AXIS_VERTICAL_TILT);
> +     }

this should be documented. i'm not sure whether there's a tablet that only
does one direction of tilt and I'm fine with not worrying about it. but it
should be documented.

Cheers,
   Peter

> +}
> +
>  static int
>  tablet_init(struct tablet_dispatch *tablet,
>           struct evdev_device *device)
> @@ -421,6 +444,8 @@ tablet_init(struct tablet_dispatch *tablet,
>       tablet->status = TABLET_NONE;
>       tablet->state.tool = LIBINPUT_TOOL_NONE;
>  
> +     tablet_init_axes(tablet, device);
> +
>       return 0;
>  }
>  
> -- 
> 1.9.0
_______________________________________________
wayland-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/wayland-devel

Reply via email to