[PATCH libinput 9/9] Add libinput_device_get_name() to advertise the kernel name

Jonas Ådahl jadahl at gmail.com
Tue Apr 8 13:22:23 PDT 2014


On Fri, Mar 28, 2014 at 02:38:52PM +1000, Peter Hutterer wrote:
> Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
> ---

Sorry, had forgotten about these, but have some comments (in a previous
e-mail and in this one). Anyhow, consider the patches in this series
Reviewed-by: me.

> I didn't end up needing this but it seems a nice to have. However, it does
> lead to a discussion on how much of the device should we expose to the
> caller through libinput.

Is it really needed to start exposing information without existing use
cases using them?

In this case, its already useful in event-debug, so it makes sense to
add immediately.

> 
> Right now libinput hides virtually everthing but the sysname and even that
> may not be enough to even get a udev reference. It is enough for now though
> because we only handle one subsystem.
> 
> If a caller needs settings or get other information on the device, they need
> to be able to query udev or the fd, but the latter then needs 
> needs open_restricted-like hooks.

Maybe libinput could allow reopening a device returning a new fd. Not a
dup() but using the already existing open_restricted hooks in libinput
internally to open a new fd.

> 
>  src/libinput.c      |  6 ++++++
>  src/libinput.h      | 12 ++++++++++++
>  tools/event-debug.c |  5 +++--
>  3 files changed, 21 insertions(+), 2 deletions(-)
> 
> diff --git a/src/libinput.c b/src/libinput.c
> index 1e31be3..2863f1d 100644
> --- a/src/libinput.c
> +++ b/src/libinput.c
> @@ -1043,6 +1043,12 @@ libinput_device_get_user_data(struct libinput_device *device)
>  }
>  
>  LIBINPUT_EXPORT const char *
> +libinput_device_get_name(struct libinput_device *device)
> +{
> +	return ((struct evdev_device *) device)->devname;
> +}
> +
> +LIBINPUT_EXPORT const char *
>  libinput_device_get_sysname(struct libinput_device *device)
>  {
>  	return evdev_device_get_sysname((struct evdev_device *) device);
> diff --git a/src/libinput.h b/src/libinput.h
> index 6e43181..f291ce8 100644
> --- a/src/libinput.h
> +++ b/src/libinput.h
> @@ -1158,6 +1158,18 @@ libinput_device_get_user_data(struct libinput_device *device);
>  /**
>   * @ingroup device
>   *
> + * Get the name of the device.

Maybe mention that the name is descriptive and in human readable form
i.e. not enumerated device name on the filesystem.

> + *
> + * @param device A previously obtained device
> + * @return The product name of the device
> + *
> + */
> +const char*
> +libinput_device_get_name(struct libinput_device *device);
> +
> +/**
> + * @ingroup device
> + *
>   * Get the system name of the device.
>   *
>   * @param device A previously obtained device
> diff --git a/tools/event-debug.c b/tools/event-debug.c
> index c0a08a7..3d0a383 100644
> --- a/tools/event-debug.c
> +++ b/tools/event-debug.c
> @@ -231,9 +231,10 @@ print_device_notify(struct libinput_event *ev)
>  	struct libinput_device *dev = libinput_event_get_device(ev);
>  	struct libinput_seat *seat = libinput_device_get_seat(dev);
>  
> -	printf("%s	%s\n",
> +	printf("%s	%s	%s\n",
>  	       libinput_seat_get_physical_name(seat),
> -	       libinput_seat_get_logical_name(seat));
> +	       libinput_seat_get_logical_name(seat),
> +	       libinput_device_get_name(dev));
>  }
>  
>  static void
> -- 
> 1.8.5.3
> 
> _______________________________________________
> wayland-devel mailing list
> wayland-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/wayland-devel


More information about the wayland-devel mailing list