{ .type = EV_ABS, .code = ABS_X, .value = LITEST_AUTO_ASSIGN },
{ .type = EV_ABS, .code = ABS_Y, .value = LITEST_AUTO_ASSIGN },
{ .type = EV_ABS, .code = ABS_PRESSURE, .value = LITEST_AUTO_ASSIGN },
- { .type = EV_KEY, .code = BTN_TOOL_PEN, .value = 1 },
+ { .type = EV_KEY, .code = LITEST_BTN_TOOL_AUTO, .value = 1 },
{ .type = EV_SYN, .code = SYN_REPORT, .value = 0 },
{ .type = -1, .code = -1 },
};
static struct input_event proximity_out[] = {
- { .type = EV_KEY, .code = BTN_TOOL_PEN, .value = 0 },
+ { .type = EV_KEY, .code = LITEST_BTN_TOOL_AUTO, .value = 0 },
{ .type = EV_SYN, .code = SYN_REPORT, .value = 0 },
{ .type = -1, .code = -1 },
};
{ .type = EV_ABS, .code = ABS_X, .value = LITEST_AUTO_ASSIGN },
{ .type = EV_ABS, .code = ABS_Y, .value = LITEST_AUTO_ASSIGN },
{ .type = EV_ABS, .code = ABS_PRESSURE, .value = LITEST_AUTO_ASSIGN },
- { .type = EV_KEY, .code = BTN_TOOL_PEN, .value = 1 },
+ { .type = EV_KEY, .code = LITEST_BTN_TOOL_AUTO, .value = 1 },
{ .type = EV_SYN, .code = SYN_REPORT, .value = 0 },
{ .type = -1, .code = -1 },
};
{ .type = EV_ABS, .code = ABS_Y, .value = LITEST_AUTO_ASSIGN },
{ .type = EV_ABS, .code = ABS_DISTANCE, .value = LITEST_AUTO_ASSIGN },
{ .type = EV_ABS, .code = ABS_PRESSURE, .value = LITEST_AUTO_ASSIGN },
- { .type = EV_KEY, .code = BTN_TOOL_PEN, .value = 1 },
+ { .type = EV_KEY, .code = LITEST_BTN_TOOL_AUTO, .value = 1 },
{ .type = EV_SYN, .code = SYN_REPORT, .value = 0 },
{ .type = -1, .code = -1 },
};
{ .type = EV_ABS, .code = ABS_X, .value = 0 },
{ .type = EV_ABS, .code = ABS_Y, .value = 0 },
{ .type = EV_ABS, .code = ABS_DISTANCE, .value = 0 },
- { .type = EV_KEY, .code = BTN_TOOL_PEN, .value = 0 },
+ { .type = EV_KEY, .code = LITEST_BTN_TOOL_AUTO, .value = 0 },
{ .type = EV_SYN, .code = SYN_REPORT, .value = 0 },
{ .type = -1, .code = -1 },
};
{ .type = EV_ABS, .code = ABS_Y, .value = LITEST_AUTO_ASSIGN },
{ .type = EV_ABS, .code = ABS_DISTANCE, .value = LITEST_AUTO_ASSIGN },
{ .type = EV_ABS, .code = ABS_PRESSURE, .value = LITEST_AUTO_ASSIGN },
- { .type = EV_KEY, .code = BTN_TOOL_PEN, .value = 1 },
+ { .type = EV_KEY, .code = LITEST_BTN_TOOL_AUTO, .value = 1 },
{ .type = EV_SYN, .code = SYN_REPORT, .value = 0 },
{ .type = -1, .code = -1 },
};
{ .type = EV_ABS, .code = ABS_X, .value = 0 },
{ .type = EV_ABS, .code = ABS_Y, .value = 0 },
{ .type = EV_ABS, .code = ABS_DISTANCE, .value = 0 },
- { .type = EV_KEY, .code = BTN_TOOL_PEN, .value = 0 },
+ { .type = EV_KEY, .code = LITEST_BTN_TOOL_AUTO, .value = 0 },
{ .type = EV_SYN, .code = SYN_REPORT, .value = 0 },
{ .type = -1, .code = -1 },
};
{ .type = EV_ABS, .code = ABS_TILT_Y, .value = LITEST_AUTO_ASSIGN },
{ .type = EV_ABS, .code = ABS_MISC, .value = 2083 },
{ .type = EV_MSC, .code = MSC_SERIAL, .value = 297797542 },
- { .type = EV_KEY, .code = BTN_TOOL_PEN, .value = 1 },
+ { .type = EV_KEY, .code = LITEST_BTN_TOOL_AUTO, .value = 1 },
{ .type = EV_SYN, .code = SYN_REPORT, .value = 0 },
{ .type = -1, .code = -1 },
};
{ .type = EV_ABS, .code = ABS_TILT_Y, .value = 0 },
{ .type = EV_ABS, .code = ABS_MISC, .value = 0 },
{ .type = EV_MSC, .code = MSC_SERIAL, .value = 297797542 },
- { .type = EV_KEY, .code = BTN_TOOL_PEN, .value = 0 },
+ { .type = EV_KEY, .code = LITEST_BTN_TOOL_AUTO, .value = 0 },
{ .type = EV_SYN, .code = SYN_REPORT, .value = 0 },
{ .type = -1, .code = -1 },
};
{ .type = EV_ABS, .code = ABS_TILT_Y, .value = LITEST_AUTO_ASSIGN },
{ .type = EV_ABS, .code = ABS_MISC, .value = 2083 },
{ .type = EV_MSC, .code = MSC_SERIAL, .value = 297797542 },
- { .type = EV_KEY, .code = BTN_TOOL_PEN, .value = 1 },
+ { .type = EV_KEY, .code = LITEST_BTN_TOOL_AUTO, .value = 1 },
{ .type = EV_SYN, .code = SYN_REPORT, .value = 0 },
{ .type = -1, .code = -1 },
};
{ .type = EV_ABS, .code = ABS_TILT_Y, .value = 0 },
{ .type = EV_ABS, .code = ABS_MISC, .value = 0 },
{ .type = EV_MSC, .code = MSC_SERIAL, .value = 297797542 },
- { .type = EV_KEY, .code = BTN_TOOL_PEN, .value = 0 },
+ { .type = EV_KEY, .code = LITEST_BTN_TOOL_AUTO, .value = 0 },
{ .type = EV_SYN, .code = SYN_REPORT, .value = 0 },
{ .type = -1, .code = -1 },
};
{ .type = EV_ABS, .code = ABS_TILT_Y, .value = LITEST_AUTO_ASSIGN },
{ .type = EV_ABS, .code = ABS_MISC, .value = 2083 },
{ .type = EV_MSC, .code = MSC_SERIAL, .value = 297797542 },
- { .type = EV_KEY, .code = BTN_TOOL_PEN, .value = 1 },
+ { .type = EV_KEY, .code = LITEST_BTN_TOOL_AUTO, .value = 1 },
{ .type = EV_SYN, .code = SYN_REPORT, .value = 0 },
{ .type = -1, .code = -1 },
};
{ .type = EV_ABS, .code = ABS_TILT_Y, .value = 0 },
{ .type = EV_ABS, .code = ABS_MISC, .value = 0 },
{ .type = EV_MSC, .code = MSC_SERIAL, .value = 297797542 },
- { .type = EV_KEY, .code = BTN_TOOL_PEN, .value = 0 },
+ { .type = EV_KEY, .code = LITEST_BTN_TOOL_AUTO, .value = 0 },
{ .type = EV_SYN, .code = SYN_REPORT, .value = 0 },
{ .type = -1, .code = -1 },
};
{ .type = EV_ABS, .code = ABS_TILT_Y, .value = LITEST_AUTO_ASSIGN },
{ .type = EV_ABS, .code = ABS_MISC, .value = 2083 },
{ .type = EV_MSC, .code = MSC_SERIAL, .value = 297797542 },
- { .type = EV_KEY, .code = BTN_TOOL_PEN, .value = 1 },
+ { .type = EV_KEY, .code = LITEST_BTN_TOOL_AUTO, .value = 1 },
{ .type = EV_SYN, .code = SYN_REPORT, .value = 0 },
{ .type = -1, .code = -1 },
};
{ .type = EV_ABS, .code = ABS_TILT_Y, .value = 0 },
{ .type = EV_ABS, .code = ABS_MISC, .value = 0 },
{ .type = EV_MSC, .code = MSC_SERIAL, .value = 297797542 },
- { .type = EV_KEY, .code = BTN_TOOL_PEN, .value = 0 },
+ { .type = EV_KEY, .code = LITEST_BTN_TOOL_AUTO, .value = 0 },
{ .type = EV_SYN, .code = SYN_REPORT, .value = 0 },
{ .type = -1, .code = -1 },
};
{ .type = EV_ABS, .code = ABS_X, .value = LITEST_AUTO_ASSIGN },
{ .type = EV_ABS, .code = ABS_Y, .value = LITEST_AUTO_ASSIGN },
{ .type = EV_ABS, .code = ABS_PRESSURE, .value = LITEST_AUTO_ASSIGN },
- { .type = EV_KEY, .code = BTN_TOOL_PEN, .value = 1 },
+ { .type = EV_KEY, .code = LITEST_BTN_TOOL_AUTO, .value = 1 },
{ .type = EV_MSC, .code = MSC_SERIAL, .value = 297797542 },
{ .type = EV_SYN, .code = SYN_REPORT, .value = 0 },
{ .type = -1, .code = -1 },
{ .type = EV_ABS, .code = ABS_X, .value = 0 },
{ .type = EV_ABS, .code = ABS_Y, .value = 0 },
{ .type = EV_MSC, .code = MSC_SERIAL, .value = 297797542 },
- { .type = EV_KEY, .code = BTN_TOOL_PEN, .value = 0 },
+ { .type = EV_KEY, .code = LITEST_BTN_TOOL_AUTO, .value = 0 },
{ .type = EV_SYN, .code = SYN_REPORT, .value = 0 },
{ .type = -1, .code = -1 },
};
{ .type = EV_ABS, .code = ABS_TILT_Y, .value = LITEST_AUTO_ASSIGN },
{ .type = EV_ABS, .code = ABS_MISC, .value = 1050626 },
{ .type = EV_MSC, .code = MSC_SERIAL, .value = 578837976 },
- { .type = EV_KEY, .code = BTN_TOOL_PEN, .value = 1 },
+ { .type = EV_KEY, .code = LITEST_BTN_TOOL_AUTO, .value = 1 },
{ .type = EV_SYN, .code = SYN_REPORT, .value = 0 },
{ .type = -1, .code = -1 },
};
{ .type = EV_ABS, .code = ABS_TILT_Y, .value = 0 },
{ .type = EV_ABS, .code = ABS_MISC, .value = 0 },
{ .type = EV_MSC, .code = MSC_SERIAL, .value = 578837976 },
- { .type = EV_KEY, .code = BTN_TOOL_PEN, .value = 0 },
+ { .type = EV_KEY, .code = LITEST_BTN_TOOL_AUTO, .value = 0 },
{ .type = EV_SYN, .code = SYN_REPORT, .value = 0 },
{ .type = -1, .code = -1 },
};
{ .type = EV_ABS, .code = ABS_X, .value = LITEST_AUTO_ASSIGN },
{ .type = EV_ABS, .code = ABS_Y, .value = LITEST_AUTO_ASSIGN },
{ .type = EV_ABS, .code = ABS_PRESSURE, .value = LITEST_AUTO_ASSIGN },
- { .type = EV_KEY, .code = BTN_TOOL_PEN, .value = 1 },
+ { .type = EV_KEY, .code = LITEST_BTN_TOOL_AUTO, .value = 1 },
{ .type = EV_SYN, .code = SYN_REPORT, .value = 0 },
{ .type = -1, .code = -1 },
};
static struct input_event proximity_out[] = {
- { .type = EV_KEY, .code = BTN_TOOL_PEN, .value = 0 },
+ { .type = EV_KEY, .code = LITEST_BTN_TOOL_AUTO, .value = 0 },
{ .type = EV_SYN, .code = SYN_REPORT, .value = 0 },
{ .type = -1, .code = -1 },
};
{ .type = EV_ABS, .code = ABS_X, .value = LITEST_AUTO_ASSIGN },
{ .type = EV_ABS, .code = ABS_Y, .value = LITEST_AUTO_ASSIGN },
{ .type = EV_ABS, .code = ABS_PRESSURE, .value = LITEST_AUTO_ASSIGN },
- { .type = EV_KEY, .code = BTN_TOOL_PEN, .value = 1 },
+ { .type = EV_KEY, .code = LITEST_BTN_TOOL_AUTO, .value = 1 },
{ .type = EV_SYN, .code = SYN_REPORT, .value = 0 },
{ .type = -1, .code = -1 },
};
static struct input_event proximity_out[] = {
- { .type = EV_KEY, .code = BTN_TOOL_PEN, .value = 0 },
+ { .type = EV_KEY, .code = LITEST_BTN_TOOL_AUTO, .value = 0 },
{ .type = EV_SYN, .code = SYN_REPORT, .value = 0 },
{ .type = -1, .code = -1 },
};
{ .type = EV_ABS, .code = ABS_TILT_X, .value = LITEST_AUTO_ASSIGN },
{ .type = EV_ABS, .code = ABS_TILT_Y, .value = LITEST_AUTO_ASSIGN },
{ .type = EV_ABS, .code = ABS_PRESSURE, .value = LITEST_AUTO_ASSIGN },
- { .type = EV_KEY, .code = BTN_TOOL_PEN, .value = 1 },
+ { .type = EV_KEY, .code = LITEST_BTN_TOOL_AUTO, .value = 1 },
{ .type = EV_SYN, .code = SYN_REPORT, .value = 0 },
{ .type = -1, .code = -1 },
};
{ .type = EV_ABS, .code = ABS_Y, .value = 0 },
{ .type = EV_ABS, .code = ABS_TILT_X, .value = 0 },
{ .type = EV_ABS, .code = ABS_TILT_Y, .value = 0 },
- { .type = EV_KEY, .code = BTN_TOOL_PEN, .value = 0 },
+ { .type = EV_KEY, .code = LITEST_BTN_TOOL_AUTO, .value = 0 },
{ .type = EV_SYN, .code = SYN_REPORT, .value = 0 },
{ .type = -1, .code = -1 },
};
/* Use as designater for litest to change the value */
#define LITEST_AUTO_ASSIGN INT_MIN
+/* Special event code to auto-assign the BTN_TOOL_PEN and friends */
+#define LITEST_BTN_TOOL_AUTO (KEY_MAX << 1)
+
struct litest_test_device {
struct list node; /* global test device list */
int min[2]; /* x/y axis minimum */
int max[2]; /* x/y axis maximum */
+
+ unsigned int tool_type;
};
struct path {
#include <linux/kd.h>
+#define evbit(t, c) ((t) << 16U | (c & 0xffff))
+
#define UDEV_RULES_D "/run/udev/rules.d"
#define UDEV_FUZZ_OVERRIDE_RULE_FILE UDEV_RULES_D \
"/91-litest-fuzz-override-REMOVEME-XXXXXX.rules"
d->interface->min[ABS_Y] = libevdev_get_abs_minimum(d->evdev, code);
d->interface->max[ABS_Y] = libevdev_get_abs_maximum(d->evdev, code);
}
+ d->interface->tool_type = BTN_TOOL_PEN;
}
return d;
}
}
void
+litest_tablet_set_tool_type(struct litest_device *d, unsigned int code)
+{
+ switch (code) {
+ case BTN_TOOL_PEN:
+ case BTN_TOOL_RUBBER:
+ case BTN_TOOL_BRUSH:
+ case BTN_TOOL_PENCIL:
+ case BTN_TOOL_AIRBRUSH:
+ case BTN_TOOL_MOUSE:
+ case BTN_TOOL_LENS:
+ break;
+ default:
+ abort();
+ }
+
+ d->interface->tool_type = code;
+}
+
+static void
+litest_tool_event(struct litest_device *d, int value)
+{
+ unsigned int tool = d->interface->tool_type;
+
+ litest_event(d, EV_KEY, tool, value);
+}
+
+void
litest_tablet_proximity_in(struct litest_device *d, int x, int y, struct axis_replacement *axes)
{
struct input_event *ev;
ev = d->interface->tablet_proximity_in_events;
while (ev && (int16_t)ev->type != -1 && (int16_t)ev->code != -1) {
- int value = auto_assign_tablet_value(d, ev, x, y, axes);
- if (!tablet_ignore_event(ev, value))
- litest_event(d, ev->type, ev->code, value);
+ int value;
+
+ switch (evbit(ev->type, ev->code)) {
+ case evbit(EV_KEY, LITEST_BTN_TOOL_AUTO):
+ litest_tool_event(d, ev->value);
+ break;
+ default:
+ value = auto_assign_tablet_value(d, ev, x, y, axes);
+ if (!tablet_ignore_event(ev, value))
+ litest_event(d, ev->type, ev->code, value);
+ }
ev++;
}
}
ev = d->interface->tablet_proximity_out_events;
while (ev && (int16_t)ev->type != -1 && (int16_t)ev->code != -1) {
- int value = auto_assign_tablet_value(d, ev, -1, -1, NULL);
- if (!tablet_ignore_event(ev, value))
- litest_event(d, ev->type, ev->code, value);
+ int value;
+
+ switch (evbit(ev->type, ev->code)) {
+ case evbit(EV_KEY, LITEST_BTN_TOOL_AUTO):
+ litest_tool_event(d, ev->value);
+ break;
+ default:
+ value = auto_assign_tablet_value(d, ev, -1, -1, NULL);
+ if (!tablet_ignore_event(ev, value))
+ litest_event(d, ev->type, ev->code, value);
+ break;
+ }
ev++;
}
}
int steps);
void
+litest_tablet_set_tool_type(struct litest_device *d,
+ unsigned int code);
+
+void
litest_tablet_proximity_in(struct litest_device *d,
int x, int y,
struct axis_replacement *axes);
!tablet_has_mouse(dev))
continue;
- litest_push_event_frame(dev);
- litest_filter_event(dev, EV_KEY, BTN_TOOL_PEN);
+ litest_tablet_set_tool_type(dev, tt->code);
litest_tablet_proximity_in(dev, 50, 50, axes);
- litest_unfilter_event(dev, EV_KEY, BTN_TOOL_PEN);
- litest_event(dev, EV_KEY, tt->code, 1);
- litest_pop_event_frame(dev);
libinput_dispatch(li);
event = libinput_get_event(li);
libinput_event_destroy(event);
litest_assert_empty_queue(li);
- litest_push_event_frame(dev);
- litest_filter_event(dev, EV_KEY, BTN_TOOL_PEN);
litest_tablet_proximity_out(dev);
- litest_unfilter_event(dev, EV_KEY, BTN_TOOL_PEN);
- litest_event(dev, EV_KEY, tt->code, 0);
- litest_pop_event_frame(dev);
litest_drain_events(li);
}
}