diff --git a/src/evdev-tablet.c b/src/evdev-tablet.c index 013038b7..479d6800 100644 --- a/src/evdev-tablet.c +++ b/src/evdev-tablet.c @@ -62,6 +62,11 @@ tablet_process_absolute(struct tablet_dispatch *tablet, set_bit(tablet->changed_axes, axis); tablet_set_status(tablet, TABLET_AXES_UPDATED); break; + /* tool_id is the identifier for the tool we can use in libwacom + * to identify it (if we have one anyway) */ + case ABS_MISC: + tablet->current_tool_id = e->value; + break; default: log_info(device->base.seat->libinput, "Unhandled ABS event code %#x\n", e->code); @@ -324,6 +329,7 @@ tablet_process_misc(struct tablet_dispatch *tablet, static struct libinput_tool * tablet_get_tool(struct tablet_dispatch *tablet, enum libinput_tool_type type, + uint32_t tool_id, uint32_t serial) { struct libinput_tool *tool = NULL, *t; @@ -362,6 +368,7 @@ tablet_get_tool(struct tablet_dispatch *tablet, *tool = (struct libinput_tool) { .type = type, .serial = serial, + .tool_id = tool_id, .refcount = 1, }; @@ -499,6 +506,7 @@ tablet_flush(struct tablet_dispatch *tablet, struct libinput_tool *tool = tablet_get_tool(tablet, tablet->current_tool_type, + tablet->current_tool_id, tablet->current_tool_serial); if (tablet_has_status(tablet, TABLET_TOOL_LEAVING_PROXIMITY)) { diff --git a/src/evdev-tablet.h b/src/evdev-tablet.h index eee69047..6226d63b 100644 --- a/src/evdev-tablet.h +++ b/src/evdev-tablet.h @@ -59,6 +59,7 @@ struct tablet_dispatch { struct button_state prev_button_state; enum libinput_tool_type current_tool_type; + uint32_t current_tool_id; uint32_t current_tool_serial; }; diff --git a/src/libinput-private.h b/src/libinput-private.h index f6c4dccc..b2dc4069 100644 --- a/src/libinput-private.h +++ b/src/libinput-private.h @@ -188,6 +188,7 @@ struct libinput_device { struct libinput_tool { struct list link; uint32_t serial; + uint32_t tool_id; enum libinput_tool_type type; unsigned char axis_caps[NCHARS(LIBINPUT_TABLET_AXIS_MAX + 1)]; int refcount; diff --git a/src/libinput.c b/src/libinput.c index 1abd1637..b165c59b 100644 --- a/src/libinput.c +++ b/src/libinput.c @@ -662,6 +662,12 @@ libinput_tool_get_type(struct libinput_tool *tool) return tool->type; } +LIBINPUT_EXPORT uint32_t +libinput_tool_get_tool_id(struct libinput_tool *tool) +{ + return tool->tool_id; +} + LIBINPUT_EXPORT uint32_t libinput_tool_get_serial(struct libinput_tool *tool) { diff --git a/src/libinput.h b/src/libinput.h index 7dae9238..bf3b40cf 100644 --- a/src/libinput.h +++ b/src/libinput.h @@ -160,6 +160,7 @@ struct libinput_tool; * usage of the tool as advertised by the manufacturer. Multiple different * physical tools may share the same tool type, e.g. a Wacom Classic Pen, * Wacom Pro Pen and a Wacom Grip Pen are all of type LIBINPUT_TOOL_PEN. + * Use libinput_tool_get_tool_id() to get a specific model where applicable. * * Note that on some device, the eraser tool is on the tail end of a pen * device. On other devices, e.g. MS Surface 3, the eraser is the pen tip @@ -1192,10 +1193,30 @@ libinput_event_tablet_get_time(struct libinput_event_tablet *event); * * @param tool The libinput tool * @return The tool type for this tool object + * + * @see libinput_tool_get_tool_id */ enum libinput_tool_type libinput_tool_get_type(struct libinput_tool *tool); +/** + * @ingroup event_tablet + * + * Return the tool ID for a tool object. If nonzero, this number identifies + * the specific type of the tool with more precision than the type returned in + * libinput_tool_get_type(). Not all tablets support a tool ID. + * + * Tablets known to support tool IDs include the Wacom Intuos 3, 4, 5, Wacom + * Cintiq and Wacom Intuos Pro series. + * + * @param tool The libinput tool + * @return The tool ID for this tool object or 0 if none is provided + * + * @see libinput_tool_get_type + */ +uint32_t +libinput_tool_get_tool_id(struct libinput_tool *tool); + /** * @ingroup event_tablet * diff --git a/src/libinput.sym b/src/libinput.sym index e4b76c64..dbd4d0f5 100644 --- a/src/libinput.sym +++ b/src/libinput.sym @@ -153,6 +153,7 @@ LIBINPUT_0.12.0 { libinput_event_tablet_get_x_transformed; libinput_event_tablet_get_y_transformed; libinput_tool_get_serial; + libinput_tool_get_tool_id; libinput_tool_get_type; libinput_tool_get_user_data; libinput_tool_has_axis;