[PATCH libinput 23/26] tools: only print the tablet axes we have on the tool

Benjamin Tissoires benjamin.tissoires at gmail.com
Tue Feb 24 09:55:23 PST 2015


On Tue, Feb 24, 2015 at 1:21 AM, Peter Hutterer
<peter.hutterer at who-t.net> wrote:
> This doesn't really have an effect, since we don't set the per-tool axes
> correctly yet.

Actually we do now. :)

Cheers,
Benjamin

>
> Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
> ---
>  tools/event-debug.c | 106 +++++++++++++++++++++++++++-------------------------
>  1 file changed, 56 insertions(+), 50 deletions(-)
>
> diff --git a/tools/event-debug.c b/tools/event-debug.c
> index 225e12f..94a90ec 100644
> --- a/tools/event-debug.c
> +++ b/tools/event-debug.c
> @@ -288,48 +288,77 @@ tablet_axis_changed_sym(struct libinput_event_tablet *t,
>  }
>
>  static void
> -print_tablet_axis_event(struct libinput_event *ev)
> +print_tablet_axes(struct libinput_event_tablet *t)
>  {
> -       struct libinput_event_tablet *t = libinput_event_get_tablet_event(ev);
> +       struct libinput_tool *tool = libinput_event_tablet_get_tool(t);
>         double x, y;
>         double dist, pressure;
>         double rotation, slider;
>
> -       print_event_time(libinput_event_tablet_get_time(t));
> -
>         x = libinput_event_tablet_get_axis_value(t, LIBINPUT_TABLET_AXIS_X);
>         y = libinput_event_tablet_get_axis_value(t, LIBINPUT_TABLET_AXIS_Y);
>         printf("\t%.2f%s/%.2f%s",
>                x, tablet_axis_changed_sym(t, LIBINPUT_TABLET_AXIS_X),
>                y, tablet_axis_changed_sym(t, LIBINPUT_TABLET_AXIS_Y));
>
> -       x = libinput_event_tablet_get_axis_value(t, LIBINPUT_TABLET_AXIS_TILT_X);
> -       y = libinput_event_tablet_get_axis_value(t, LIBINPUT_TABLET_AXIS_TILT_Y);
> -       printf("\ttilt: %.2f%s/%.2f%s ",
> -              x, tablet_axis_changed_sym(t, LIBINPUT_TABLET_AXIS_TILT_X),
> -              y, tablet_axis_changed_sym(t, LIBINPUT_TABLET_AXIS_TILT_Y));
> +       if (libinput_tool_has_axis(tool, LIBINPUT_TABLET_AXIS_TILT_X) ||
> +           libinput_tool_has_axis(tool, LIBINPUT_TABLET_AXIS_TILT_Y)) {
> +               x = libinput_event_tablet_get_axis_value(t,
> +                                        LIBINPUT_TABLET_AXIS_TILT_X);
> +               y = libinput_event_tablet_get_axis_value(t,
> +                                        LIBINPUT_TABLET_AXIS_TILT_Y);
> +               printf("\ttilt: %.2f%s/%.2f%s ",
> +                      x, tablet_axis_changed_sym(t,
> +                                         LIBINPUT_TABLET_AXIS_TILT_X),
> +                      y, tablet_axis_changed_sym(t,
> +                                         LIBINPUT_TABLET_AXIS_TILT_Y));
> +       }
>
> -       dist = libinput_event_tablet_get_axis_value(t, LIBINPUT_TABLET_AXIS_DISTANCE);
> -       pressure = libinput_event_tablet_get_axis_value(t, LIBINPUT_TABLET_AXIS_PRESSURE);
> -       if (dist)
> -               printf("distance: %.2f%s",
> -                      dist, tablet_axis_changed_sym(t, LIBINPUT_TABLET_AXIS_DISTANCE));
> -       else
> -               printf("pressure: %.2f%s",
> -                      pressure, tablet_axis_changed_sym(t, LIBINPUT_TABLET_AXIS_PRESSURE));
> +       if (libinput_tool_has_axis(tool, LIBINPUT_TABLET_AXIS_DISTANCE) ||
> +           libinput_tool_has_axis(tool, LIBINPUT_TABLET_AXIS_PRESSURE)) {
> +               dist = libinput_event_tablet_get_axis_value(t,
> +                                       LIBINPUT_TABLET_AXIS_DISTANCE);
> +               pressure = libinput_event_tablet_get_axis_value(t,
> +                                       LIBINPUT_TABLET_AXIS_PRESSURE);
> +               if (dist) {
> +                       printf("\tdistance: %.2f%s",
> +                              dist,
> +                              tablet_axis_changed_sym(t,
> +                                              LIBINPUT_TABLET_AXIS_DISTANCE));
> +               } else {
> +                       printf("\tpressure: %.2f%s",
> +                              pressure,
> +                              tablet_axis_changed_sym(t,
> +                                              LIBINPUT_TABLET_AXIS_PRESSURE));
> +               }
> +       }
>
> -       rotation = libinput_event_tablet_get_axis_value(t,
> +       if (libinput_tool_has_axis(tool, LIBINPUT_TABLET_AXIS_ROTATION_Z)) {
> +               rotation = libinput_event_tablet_get_axis_value(t,
>                                         LIBINPUT_TABLET_AXIS_ROTATION_Z);
> -       printf(" rotation: %.2f%s",
> -              rotation,
> -              tablet_axis_changed_sym(t, LIBINPUT_TABLET_AXIS_ROTATION_Z));
> +               printf("\trotation: %.2f%s",
> +                      rotation,
> +                      tablet_axis_changed_sym(t,
> +                                      LIBINPUT_TABLET_AXIS_ROTATION_Z));
> +       }
>
> -       slider = libinput_event_tablet_get_axis_value(t,
> +       if (libinput_tool_has_axis(tool, LIBINPUT_TABLET_AXIS_SLIDER)) {
> +               slider = libinput_event_tablet_get_axis_value(t,
>                                         LIBINPUT_TABLET_AXIS_SLIDER);
> -       printf(" slider: %.2f%s",
> -              slider,
> -              tablet_axis_changed_sym(t, LIBINPUT_TABLET_AXIS_SLIDER));
> +               printf("\tslider: %.2f%s",
> +                      slider,
> +                      tablet_axis_changed_sym(t,
> +                                      LIBINPUT_TABLET_AXIS_SLIDER));
> +       }
> +}
>
> +static void
> +print_tablet_axis_event(struct libinput_event *ev)
> +{
> +       struct libinput_event_tablet *t = libinput_event_get_tablet_event(ev);
> +
> +       print_event_time(libinput_event_tablet_get_time(t));
> +       print_tablet_axes(t);
>         printf("\n");
>  }
>
> @@ -350,8 +379,6 @@ print_proximity_event(struct libinput_event *ev)
>         enum libinput_tool_proximity_state state;
>         const char *tool_str,
>                    *state_str;
> -       double x, y;
> -       double dist, pressure;
>
>         switch (libinput_tool_get_type(tool)) {
>         case LIBINPUT_TOOL_PEN:
> @@ -387,28 +414,7 @@ print_proximity_event(struct libinput_event *ev)
>         print_event_time(libinput_event_tablet_get_time(t));
>
>         if (state == LIBINPUT_TOOL_PROXIMITY_IN) {
> -               x = libinput_event_tablet_get_axis_value(
> -                                       t, LIBINPUT_TABLET_AXIS_X);
> -               y = libinput_event_tablet_get_axis_value(
> -                                       t, LIBINPUT_TABLET_AXIS_Y);
> -               printf("\t%.2f/%.2f", x, y);
> -
> -               x = libinput_event_tablet_get_axis_value(
> -                                       t, LIBINPUT_TABLET_AXIS_TILT_X);
> -               y = libinput_event_tablet_get_axis_value(
> -                                       t, LIBINPUT_TABLET_AXIS_TILT_Y);
> -               printf("\ttilt: %.2f/%.2f ", x, y);
> -
> -               dist = libinput_event_tablet_get_axis_value(
> -                                       t, LIBINPUT_TABLET_AXIS_DISTANCE);
> -               pressure = libinput_event_tablet_get_axis_value(
> -                                       t, LIBINPUT_TABLET_AXIS_PRESSURE);
> -
> -               if (dist)
> -                       printf("\tdistance: %.2f ", dist);
> -               else
> -                       printf("\tpressure: %.2f ", pressure);
> -
> +               print_tablet_axes(t);
>                 state_str = "proximity-in";
>         } else if (state == LIBINPUT_TOOL_PROXIMITY_OUT) {
>                 state_str = "proximity-out";
> @@ -417,7 +423,7 @@ print_proximity_event(struct libinput_event *ev)
>                 abort();
>         }
>
> -       printf("%s (%#x) %s",
> +       printf("\t%s (%#x) %s",
>                tool_str, libinput_tool_get_serial(tool), state_str);
>
>         printf("\taxes:");
> --
> 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