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>
This commit is contained in:
Peter Hutterer 2019-11-01 08:20:07 +10:00
parent 7bd96ec923
commit 12021c860e
2 changed files with 34 additions and 5 deletions

View 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:

View 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