[PATCH libinput 18/26] tablet: rely on libwacom to give us the right tablet axes

Benjamin Tissoires benjamin.tissoires at gmail.com
Tue Feb 24 09:48:47 PST 2015


On Tue, Feb 24, 2015 at 1:21 AM, Peter Hutterer
<peter.hutterer at who-t.net> wrote:
> Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
> ---
>  src/evdev-tablet.c | 50 +++++++++++++++++++++++++++++++++-----------------
>  1 file changed, 33 insertions(+), 17 deletions(-)
>
> diff --git a/src/evdev-tablet.c b/src/evdev-tablet.c
> index 2b90e08..52742cf 100644
> --- a/src/evdev-tablet.c
> +++ b/src/evdev-tablet.c
> @@ -408,7 +408,7 @@ copy_button_cap(const struct tablet_dispatch *tablet,
>                 set_bit(tool->buttons, button);
>  }
>
> -static void
> +static int
>  tool_set_bits_from_libwacom(const struct tablet_dispatch *tablet,
>                             struct libinput_tool *tool)
>  {
> @@ -416,6 +416,8 @@ tool_set_bits_from_libwacom(const struct tablet_dispatch *tablet,
>         WacomDeviceDatabase *db;
>         const WacomStylus *s = NULL;
>         int code;
> +       WacomStylusType type;
> +       int rc = 1;
>
>         db = libwacom_database_new();
>         if (!db)
> @@ -424,7 +426,8 @@ tool_set_bits_from_libwacom(const struct tablet_dispatch *tablet,
>         if (!s)
>                 goto out;
>
> -       if (libwacom_stylus_get_type(s) == WSTYLUS_PUCK) {
> +       type = libwacom_stylus_get_type(s);
> +       if (type == WSTYLUS_PUCK) {
>                 for (code = BTN_LEFT;
>                      code < BTN_LEFT + libwacom_stylus_get_num_buttons(s);
>                      code++)
> @@ -437,9 +440,29 @@ tool_set_bits_from_libwacom(const struct tablet_dispatch *tablet,
>                 copy_button_cap(tablet, tool, BTN_TOUCH);
>         }
>
> +       /* Eventually we want libwacom to tell us each axis on each device
> +          separately. */
> +       switch(type) {
> +       case WSTYLUS_AIRBRUSH:
> +       case WSTYLUS_MARKER:
> +       case WSTYLUS_GENERAL:
> +       case WSTYLUS_INKING:
> +       case WSTYLUS_CLASSIC:
> +       case WSTYLUS_STROKE:
> +               copy_axis_cap(tablet, tool, LIBINPUT_TABLET_AXIS_PRESSURE);
> +               copy_axis_cap(tablet, tool, LIBINPUT_TABLET_AXIS_DISTANCE);
> +               copy_axis_cap(tablet, tool, LIBINPUT_TABLET_AXIS_TILT_X);
> +               copy_axis_cap(tablet, tool, LIBINPUT_TABLET_AXIS_TILT_Y);
> +               break;
> +       default:
> +               break;
> +       }
> +
> +       rc = 0;
>  out:
>         if (db)
>                 libwacom_database_destroy(db);
> +       return rc;
>  #endif
>  }
>
> @@ -449,23 +472,20 @@ tool_set_bits(const struct tablet_dispatch *tablet,
>  {
>         enum libinput_tool_type type = tool->type;
>
> -       /* Determine the axis capabilities of the tool. Here's a break
> -        * down of the heuristics used here:
> -        * - The Wacom art pen supports all of the extra axes, along
> -        *   with rotation
> -        * - The Wacom airbrush supports a wheel with a ~90 deg
> -        *   range.
> -        * - All of normal pens and the airbrush support all of the
> -        *   extra axes if the tablet can report them
> -        * - All of the mouse-like devices don't report any of
> -        *   the extra axes except for rotation (calculated from tilt x/y).
> +#if HAVE_LIBWACOM
> +       if (tool_set_bits_from_libwacom(tablet, tool) == 0)
> +               return;
> +#endif
> +       /* If we don't have libwacom, we simply copy any axis we have on the
> +          tablet onto the tool. Except we know that mice only have rotation
> +          anyway.
>          */
>         switch (type) {
> +       case LIBINPUT_TOOL_AIRBRUSH:
>         case LIBINPUT_TOOL_PEN:
>         case LIBINPUT_TOOL_ERASER:
>         case LIBINPUT_TOOL_PENCIL:
>         case LIBINPUT_TOOL_BRUSH:
> -       case LIBINPUT_TOOL_AIRBRUSH:

nitpicking: no need to move around LIBINPUT_TOOL_AIRBRUSH.

>                 copy_axis_cap(tablet, tool, LIBINPUT_TABLET_AXIS_PRESSURE);
>                 copy_axis_cap(tablet, tool, LIBINPUT_TABLET_AXIS_DISTANCE);
>                 copy_axis_cap(tablet, tool, LIBINPUT_TABLET_AXIS_TILT_X);
> @@ -475,9 +495,6 @@ tool_set_bits(const struct tablet_dispatch *tablet,
>                 break;
>         }
>
> -#if HAVE_LIBWACOM
> -       tool_set_bits_from_libwacom(tablet, tool);
> -#else
>         /* If we don't have libwacom, copy all pen-related ones from the
>            tablet vs all mouse-related ones */
>         switch (type) {
> @@ -501,7 +518,6 @@ tool_set_bits(const struct tablet_dispatch *tablet,
>         default:
>                 break;
>         }
> -#endif
>  }
>
>  static struct libinput_tool *
> --
> 2.1.0
>
> _______________________________________________
> wayland-devel mailing list
> wayland-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/wayland-devel


More information about the wayland-devel mailing list