[PATCH libevdev 1/6] Add support for uinput device creation

Peter Hutterer peter.hutterer at who-t.net
Wed Aug 14 16:59:41 PDT 2013


On Wed, Aug 14, 2013 at 03:05:33PM +0200, David Herrmann wrote:
> Hi
> 
> On Wed, Aug 14, 2013 at 2:45 PM, Benjamin Tissoires
> <benjamin.tissoires at gmail.com> wrote:
> > On Tue, Aug 13, 2013 at 12:39 PM, Peter Hutterer
> > <peter.hutterer at who-t.net> wrote:
[...]

> >> +int
> >> +libevdev_uinput_create_from_device(const struct libevdev *dev, int fd, struct libevdev_uinput** uinput_dev)
> >
> > The code looks good, but I don't really like the parameter "fd". To
> > me, it looks like this parameter can only be a fresh open of
> > /dev/uinput node, with the right permissions and parameters. Besides,
> > having this as a parameter, would allow a user to use it twice for two
> > different uinput devices.
> >
> > To my mind, the parameter should be omitted and the open called in
> > libevdev_uinput_create_from_device(). If the user wants to have a
> > handle to it, it can call libevdev_uinput_get_fd(), and it will also
> > allows us to close the fd in libevdev_uinput_destroy().
> 
> You might not have permissions to access /dev/uinput and get the fd
> via a unix socket. That's quite common practice. But we could allow
> "-1" and then open the fd inside of the constructor.
> 
> But I agree that libevdev should own the fd. uinput doesn't allow
> multiplexing on a single fd so I cannot see any reason why a user
> would want access to it after calling create_from_device().
 
well, the fd is just a number, so it's a bit hard to 'own' it, the caller
could call close() on it any time.

also, quick check of the kernel source shows that while we can't have two
uinput devices at the same time, we can have multiple serially on the same
fd.

anyway, got a patch to open it from libevdev coming up soon.

Cheers,
   Peter



More information about the Input-tools mailing list