diff options
author | Peter Hutterer <peter.hutterer@who-t.net> | 2019-11-01 08:20:07 +1000 |
---|---|---|
committer | Peter Hutterer <peter.hutterer@who-t.net> | 2019-11-01 08:38:59 +1000 |
commit | 12021c860e796a9f28f3f47c2ff04f171e0846d6 (patch) | |
tree | 39d6e110d2eee4aef05b0df97e05653eaa972dcd /tools/libinput-debug-gui.c | |
parent | 7bd96ec92318359ed6c2f24521bb5122764baa32 (diff) | |
download | libinput-12021c860e796a9f28f3f47c2ff04f171e0846d6.tar.gz |
tools: debug-gui: show pressure/distance as vertical bar
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>
Diffstat (limited to 'tools/libinput-debug-gui.c')
-rw-r--r-- | tools/libinput-debug-gui.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/tools/libinput-debug-gui.c b/tools/libinput-debug-gui.c index ea31e178..516d8c48 100644 --- a/tools/libinput-debug-gui.c +++ b/tools/libinput-debug-gui.c @@ -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: |