[PATCH libinput 1/2] tablet: Add libinput_tablet_has_axis()

Peter Hutterer peter.hutterer at who-t.net
Tue Aug 5 18:58:04 PDT 2014


On Tue, Aug 05, 2014 at 05:49:38PM -0400, Stephen Chandler Paul wrote:
> Checks whether or not the tablet can report the specified axis, so callers can
> get an idea of a tablet's capabilities.

we discussed this on IRC but for the archives: I'm thinking that this may
actually be better solved by pushing it into the tool, either as a generic
function on the tool itself or to work on the proximity event.

The reason simply being that just because a tablet provides a given axis
doesn't mean a specific tool makes use of it. So having the capabilities as
part of the tool seems to make the most sense here.

Cheers,
   Peter


> 
> Signed-off-by: Stephen Chandler Paul <thatslyude at gmail.com>
> ---
>  src/evdev-tablet.c |  8 ++++++++
>  src/evdev.h        |  3 +++
>  src/libinput.c     | 14 ++++++++++++++
>  src/libinput.h     | 13 +++++++++++++
>  4 files changed, 38 insertions(+)
> 
> diff --git a/src/evdev-tablet.c b/src/evdev-tablet.c
> index 31dd8d7..954c77b 100644
> --- a/src/evdev-tablet.c
> +++ b/src/evdev-tablet.c
> @@ -512,3 +512,11 @@ evdev_tablet_create(struct evdev_device *device)
>  
>  	return &tablet->base;
>  }
> +
> +int
> +evdev_tablet_has_axis(struct evdev_device *device, enum libinput_tablet_axis axis)
> +{
> +	return libevdev_has_event_code(device->evdev,
> +				       EV_ABS,
> +				       axis_to_evcode(axis));
> +}
> diff --git a/src/evdev.h b/src/evdev.h
> index bfa47b1..5447503 100644
> --- a/src/evdev.h
> +++ b/src/evdev.h
> @@ -130,6 +130,9 @@ evdev_mt_touchpad_create(struct evdev_device *device);
>  struct evdev_dispatch *
>  evdev_tablet_create(struct evdev_device *device);
>  
> +int
> +evdev_tablet_has_axis(struct evdev_device *device, enum libinput_tablet_axis axis);
> +
>  void
>  evdev_device_proces_event(struct libinput_event *event);
>  
> diff --git a/src/libinput.c b/src/libinput.c
> index 9aa7cbc..a7de795 100644
> --- a/src/libinput.c
> +++ b/src/libinput.c
> @@ -587,6 +587,20 @@ libinput_event_tablet_get_seat_button_count(struct libinput_event_tablet *event)
>  	return event->seat_button_count;
>  }
>  
> +LIBINPUT_EXPORT int
> +libinput_tablet_has_axis(struct libinput_device *device,
> +			 enum libinput_tablet_axis axis)
> +{
> +	struct evdev_device *evdev_device = NULL;
> +
> +	if (!libinput_device_has_capability(device, LIBINPUT_DEVICE_CAP_TABLET))
> +		return 0;
> +
> +	evdev_device = container_of(device, evdev_device, base);
> +
> +	return evdev_tablet_has_axis(evdev_device, axis);
> +}
> +
>  LIBINPUT_EXPORT enum libinput_tool_type
>  libinput_tool_get_type(struct libinput_tool *tool)
>  {
> diff --git a/src/libinput.h b/src/libinput.h
> index a9ad379..bde15a1 100644
> --- a/src/libinput.h
> +++ b/src/libinput.h
> @@ -362,6 +362,19 @@ struct libinput_device *
>  libinput_event_get_device(struct libinput_event *event);
>  
>  /**
> + * @ingroup device
> + *
> + * Checks whether or not a tablet supports the specified axis. The device must
> + * have the @ref LIBINPUT_DEVICE_CAP_TABLET capability.
> + *
> + * @return 1 if the axis is supported, 0 if the axis is not supported or the
> + * device does not have the @ref LIBINPUT_DEVICE_CAP_TABLET capability.
> + */
> +int
> +libinput_tablet_has_axis(struct libinput_device *device,
> +			 enum libinput_tablet_axis axis);
> +
> +/**
>   * @ingroup event
>   *
>   * Return the pointer event that is this input event. If the event type does
> -- 
> 1.8.5.5
> 


More information about the wayland-devel mailing list