tablet: add tablet tool scrolling to debug tools

This commit is contained in:
Louis Goyard 2024-03-12 00:08:31 +09:00
parent 0ae8e69ca8
commit 78d2bd9dad
2 changed files with 52 additions and 3 deletions

View file

@ -496,8 +496,39 @@ print_tablet_button_event(struct libinput_event *ev)
static void static void
print_tablet_tool_scroll_event(struct libinput_event *ev) print_tablet_tool_scroll_event(struct libinput_event *ev)
{ {
// FIXME: done in a later commit struct libinput_event_tablet_tool *t = libinput_event_get_tablet_tool_event(ev);
printq("FIXME"); double v = 0, h = 0;
const char *have_vert = "",
*have_horiz = "";
const char *source = NULL;
enum libinput_pointer_axis axis;
enum libinput_event_type type;
type = libinput_event_get_type(ev);
switch (type) {
case LIBINPUT_EVENT_TABLET_TOOL_SCROLL_CONTINUOUS:
source = "continuous";
break;
default:
abort();
break;
}
axis = LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL;
if (libinput_event_tablet_tool_has_axis(t, axis)) {
v = libinput_event_tablet_tool_get_scroll_value(t, axis);
have_vert = "*";
}
axis = LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL;
if (libinput_event_tablet_tool_has_axis(t, axis)) {
h = libinput_event_tablet_tool_get_scroll_value(t, axis);
have_horiz = "*";
}
printq("vert %.2f%s horiz %.2f%s (%s)\n",
v, have_vert,
h, have_horiz, source);
} }
static void static void

View file

@ -1513,7 +1513,25 @@ handle_event_pointer_axis(struct libinput_event *ev, struct window *w)
static void static void
handle_event_tablet_tool_axis(struct libinput_event *ev, struct window *w) handle_event_tablet_tool_axis(struct libinput_event *ev, struct window *w)
{ {
// FIXME: done in a later commit struct libinput_event_tablet_tool *p = libinput_event_get_tablet_tool_event(ev);
double value;
enum libinput_pointer_axis axis;
assert(p != NULL);
axis = LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL;
if (libinput_event_tablet_tool_has_axis(p, axis)) {
value = libinput_event_tablet_tool_get_scroll_value(p, axis);
w->scroll.vy += value;
w->scroll.vy = clip(w->scroll.vy, 0, w->height);
}
axis = LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL;
if (libinput_event_tablet_tool_has_axis(p, axis)) {
value = libinput_event_tablet_tool_get_scroll_value(p, axis);
w->scroll.hx += value;
w->scroll.hx = clip(w->scroll.hx, 0, w->width);
}
} }
static void static void