[PATCH evemu 1/2] tools: evemu-device: rely on libevdev to retrieve the device node

Peter Hutterer peter.hutterer at who-t.net
Thu Jan 9 15:21:00 PST 2014


On Thu, Jan 09, 2014 at 06:08:14PM -0500, Benjamin Tissoires wrote:
> 
> 
> On 09/01/14 17:53, Peter Hutterer wrote:
> > On Thu, Jan 09, 2014 at 05:15:10PM -0500, Benjamin Tissoires wrote:
> >> Cleanup a little evemu-device now that we rely on libevdev for the internal
> >> stuffs.
> >> Needs to export a new function evemu_get_devnode, but we already have
> >> broken the ABI.
> >>
> >> Signed-off-by: Benjamin Tissoires <benjamin.tissoires at gmail.com>
> >> ---
> >>
> >> Not sure about the ABI breakage (new function) and the soname bump, but still,
> >> there has been no release since the last bump...
> > 
> > no bump needed then, people building against git versions cannot expect ABI
> > stability.
> > 
> > Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net>
> 
> Thanks
> 
> > 
> > note that we can pass LIBEVDEV_UINPUT_OPEN_MANAGED as fd, so it's likely we
> > can drop the rest of this file too.
> > 
> 
> So is this patch validated also?
> 
> From: Benjamin Tissoires <benjamin.tissoires at gmail.com>
> Date: Thu, 9 Jan 2014 18:06:15 -0500
> Subject: [PATCH evemu] tools: device: rely on libevdev to open the
> uinput node
> 
> libevdev can take care of the uinput node, I am glad to remove this part.
> 
> Signed-off-by: Benjamin Tissoires <benjamin.tissoires at gmail.com>
> ---
>  tools/Makefile.am    |  2 ++
>  tools/evemu-device.c | 12 ++----------
>  2 files changed, 4 insertions(+), 10 deletions(-)
> 
> diff --git a/tools/Makefile.am b/tools/Makefile.am
> index f61aca1..95d417f 100644
> --- a/tools/Makefile.am
> +++ b/tools/Makefile.am
> @@ -18,6 +18,8 @@ evemu_record_SOURCES = evemu-record.c
> find_event_devices.c find_event_devices.h
>  evemu_event_CFLAGS = $(LIBEVDEV_CFLAGS)
>  evemu_event_LDADD = $(LIBEVDEV_LIBS)
> 
> +evemu_device_CFLAGS = $(LIBEVDEV_CFLAGS)
> +
>  # man page generation
>  if HAVE_DOCTOOLS
>  # actual man pages
> diff --git a/tools/evemu-device.c b/tools/evemu-device.c
> index 46ffaeb..7dfe1d7 100644
> --- a/tools/evemu-device.c
> +++ b/tools/evemu-device.c
> @@ -49,8 +49,7 @@
>  #include <sys/stat.h>
>  #include <sys/types.h>
>  #include <unistd.h>
> -
> -#define UINPUT_NODE "/dev/uinput"
> +#include <libevdev/libevdev-uinput.h>
> 
>  /*
>   * Finds the newly created device node and holds it open.
> @@ -85,7 +84,6 @@ static int evemu_device(FILE *fp)
>  {
>  	struct evemu_device *dev;
>  	int ret = -ENOMEM;
> -	int fd;
> 
>  	dev = evemu_new(NULL);
>  	if (!dev)
> @@ -100,18 +98,12 @@ static int evemu_device(FILE *fp)
>  		evemu_set_name(dev, name);
>  	}
> 
> -	ret = fd = open(UINPUT_NODE, O_WRONLY);
> +	ret = evemu_create(dev, LIBEVDEV_UINPUT_OPEN_MANAGED);

I'd rather not make the evemu API explicitly dependent on a libevdev ABI
decision. this needs to be either documented (e.g. evemu_create() for an fd
< 0 opens it automatically) and handled in evemu_create directly or we add a
new call for evemu_create_managed() that handles everything. I'd go for the
latter.

Cheers,
   Peter


>  	if (ret < 0)
>  		goto out;
> -
> -	ret = evemu_create(dev, fd);
> -	if (ret < 0)
> -		goto out_close;
>  	hold_device(dev);
>  	evemu_destroy(dev);
> 
> -out_close:
> -	close(fd);
>  out:
>  	evemu_delete(dev);
> 
> -- 
> 1.8.3.1
> 
> Cheers,
> Benjamin


More information about the Input-tools mailing list