[PATCH libinput 09/26] tablet: add libinput_tool_get_tool_id()
Lyude
thatslyude at gmail.com
Thu Feb 26 06:06:26 PST 2015
On Tue, 2015-02-24 at 16:21 +1000, Peter Hutterer wrote:
> The tool ID on wacom tablets is what really defines the tool, so one can
> differ between say an Intuos Grip Pen, Art Pen or Classic Pen. They're all
> BTN_TOOL_PEN in the kernel driver.
>
> Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
> ---
> src/evdev-tablet.c | 8 ++++++++
> src/evdev-tablet.h | 1 +
> src/libinput-private.h | 1 +
> src/libinput.c | 6 ++++++
> src/libinput.h | 20 ++++++++++++++++++++
> src/libinput.sym | 1 +
> 6 files changed, 37 insertions(+)
>
> diff --git a/src/evdev-tablet.c b/src/evdev-tablet.c
> index 013038b..479d680 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 eee6904..6226d63 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 f6c4dcc..b2dc406 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 1abd163..b165c59 100644
> --- a/src/libinput.c
> +++ b/src/libinput.c
> @@ -663,6 +663,12 @@ libinput_tool_get_type(struct libinput_tool *tool)
> }
>
> 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)
> {
> return tool->serial;
> diff --git a/src/libinput.h b/src/libinput.h
> index 984e8e3..f746671 100644
> --- a/src/libinput.h
> +++ b/src/libinput.h
> @@ -1193,6 +1193,8 @@ 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);
> @@ -1200,6 +1202,24 @@ 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);
> +
Glad to see you went with my idea here :)
Cheers,
Lyude
> +/**
> + * @ingroup event_tablet
> + *
> * Increment the ref count of tool by one
> *
> * @param tool The tool to increment the ref count of
> diff --git a/src/libinput.sym b/src/libinput.sym
> index e4b76c6..dbd4d0f 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;
More information about the wayland-devel
mailing list