tools: debug-gui: show pressure/distance as vertical bar
authorPeter Hutterer <peter.hutterer@who-t.net>
Thu, 31 Oct 2019 22:20:07 +0000 (08:20 +1000)
committerPeter Hutterer <peter.hutterer@who-t.net>
Thu, 31 Oct 2019 22:38:59 +0000 (08:38 +1000)
Both of these are normalized so let's draw a bar that shows the values
accordingly. This makes it a lot easier to check whether pressure values go to
the maximum, etc.

A little extra square is shown whenever the tip is logically down.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
tools/libinput-debug-gui.c
tools/libinput-debug-gui.man

index ea31e178e7c7a5c975c593ca1fa77aade62c02ee..516d8c48b24399087308251c18294a8029946bf5 100644 (file)
@@ -139,6 +139,7 @@ struct window {
                double tilt_x, tilt_y;
                double rotation;
                double size_major, size_minor;
+               bool is_down;
 
                /* these are for the delta coordinates, but they're not
                 * deltas, they are converted into abs positions */
@@ -535,6 +536,30 @@ draw_tablet(struct window *w, cairo_t *cr)
        double x, y;
        int first, last;
        size_t mask;
+       int rx, ry;
+
+       /* pressure/distance bars */
+       rx = w->width/2 + 100;
+       ry = w->height/2 + 50;
+       cairo_save(cr);
+       cairo_set_source_rgb(cr, .2, .6, .6);
+       cairo_rectangle(cr, rx, ry, 20, 100);
+       cairo_stroke(cr);
+
+       if (w->tool.distance > 0) {
+               double pos = w->tool.distance * 100;
+               cairo_rectangle(cr, rx, ry + 100 - pos, 20, 5);
+               cairo_fill(cr);
+       }
+       if (w->tool.pressure > 0) {
+               double pos = w->tool.pressure * 100;
+               if (w->tool.is_down)
+                       cairo_rectangle(cr, rx + 25, ry + 95, 5, 5);
+               cairo_rectangle(cr, rx, ry + 100 - pos, 20, pos);
+               cairo_fill(cr);
+       }
+       cairo_restore(cr);
+
 
        /* tablet tool, square for prox-in location */
        cairo_save(cr);
@@ -1309,9 +1334,11 @@ handle_event_tablet(struct libinput_event *ev, struct window *w)
                    LIBINPUT_TABLET_TOOL_TIP_DOWN) {
                        w->tool.x_down = x;
                        w->tool.y_down = y;
+                       w->tool.is_down = true;
                } else {
                        w->tool.x_up = x;
                        w->tool.y_up = y;
+                       w->tool.is_down = false;
                }
                /* fallthrough */
        case LIBINPUT_EVENT_TABLET_TOOL_AXIS:
index 3a1b2957d6a74826c860239e2f954553119add72..5b03ec41f28d464254b4e11c4c7f0f5fd318ae06 100644 (file)
@@ -73,11 +73,13 @@ respectively, at the touch point or absolute position.
 .B Tablet tools
 Events from tablet tools show a cyan square at the proximity-in and
 proximity-out positions. The tool position is shown as circle and increases
-in radius with increasing pressure or distance. Where tilt is available, the
-circle changes to an ellipsis to indicate the tilt angle. Relative events
-from the tablet tool are displayed as a yellow snake, always starting from
-the center of the window on proximity in. Button events are displayed in the
-bottom-most button oblong, with the name of the button displayed on press.
+in radius with increasing pressure or distance. Pressure and distance are
+also shown in the vertical bar south-east of center. Where tilt is
+available, the circle changes to an ellipsis to indicate the tilt angle.
+Relative events from the tablet tool are displayed as a yellow snake, always
+starting from the center of the window on proximity in. Button events are
+displayed in the bottom-most button oblong, with the name of the button
+displayed on press.
 .TP 8
 .B Tablet pads
 Button events are displayed in the bottom-most button oblong, with the name