summaryrefslogtreecommitdiff
path: root/libevdev/libevdev-uinput.c
Commit message (Collapse)AuthorAgeFilesLines
* cosmetic: fix a couple of duplicate/missing empty linesPeter Hutterer2015-03-041-2/+0
| | | | Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
* libevdev_uinput_destroy: don't close non-open FDOwen W. Taylor2015-01-211-3/+5
| | | | | | | | | | | The returned errno from libevdev_input_create_from_device was returned incorrectly because libevdev_uinput_destroy() would try to close the unset value of ->fd, overwriting errno. That was fixed in debe9b030c8069cdf78307888ef3b65830b25122, this patch avoids the ioctl/close calls if the fd isn't set. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
* uinput: explicitly ignore the UI_DEV_DESTROY return valuePeter Hutterer2014-08-251-1/+1
| | | | | | | | | This can't fail in the kernel anyway, so cast it to shut up Coverity. Error message: "Calling function "ioctl(int, unsigned long, ...)" without checking return value (as is done elsewhere 35 out of 36 times)." Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
* uinput: close the managed fd on errorPeter Hutterer2014-08-221-0/+3
| | | | | | | | | Using LIBEVDEV_UINPUT_OPEN_MANAGED can leak the fd if an error occurs after opening it. Found by Coverity. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
* uinput: preserve the errno before cleaning upPeter Hutterer2014-08-151-1/+2
| | | | | | | libevdev_uinput_destroy() may/will botch the errno, make sure we save it before use. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
* uinput: check errno against the positive valuePeter Hutterer2014-08-151-1/+1
| | | | | | | | | We use the negative errno internally, but the proper errno is always positive. Fixes device creation failures on kernels that don't support UI_SET_PROPBIT. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: David Herrmann <dh.herrmann@gmail.com>
* uinput: change strcpy/strcat usage for snprintfPeter Hutterer2014-06-201-5/+14
| | | | | | | | | | | | Better protection against buffer overflow, though by the time someone is manipulating your sysfs, libevdev is unlikely to be the biggest worry. Slight change in functionality: before we checked the timestamp of /sys/devices/virtual/input/inputXYZ before looking at /inputXYZ/name, now we just check the name file for the timestamp. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
* uinput: use the UI_GET_SYSNAME ioctl if availablePeter Hutterer2014-06-201-3/+11
| | | | | Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
* Add per-device log handlersPeter Hutterer2014-06-051-3/+3
| | | | | | | | | | | | | | | | | | | | | | The global log handler isn't a good choice for a low-level library. In the caser of the X server, both evdev and synaptics are now using the libevdev but are loaded from the same server process. Thus, there's only one log handler, but evdev and synaptics don't talk to each other (a bit childish, I know). Add a per-device log handler that overrides the global log handler, and fall back to the global log handler if no device log handler is set. The log macros take care of that automatically, especially as we can't do per-device log handlers for the uinput code. Note that we use the same struct for the global and device logging, so in each instance one of the two function pointers is NULL. Suicide triggers are in place in case we mess that up. This also makes libevdev_new_from_fd() a bit less useful since we can't set the log handler beforehand. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: David Herrmann <dh.herrmann@gmail.com>
* Ignore NULL as argument in libevdev_uinput_destroy()Peter Hutterer2014-05-071-0/+3
| | | | | | | | | | | Triggered by the tests when run as non-root. Simply ignore any attempt to destroy a NULL device, which also matches the behaviour of libevdev_free(). Reported-by: Andreas Radke <a.radke@arcor.de> Reviewed-by: Daniel Martin <consume.noise@gmail.com> Tested-by: Daniel Martin <consume.noise@gmail.com> Reviewed-by: David Herrmann <dh.herrmann@gmail.com> Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
* uinput: check for asprintf failurePeter Hutterer2014-03-191-1/+2
| | | | | | | | | | This doesn't really do much here, but strictly speaking: if asprintf returns -1, devnode is undefined. So reset it to NULL to avoid weird pointers. And also free the rest of the names if we ever have more than one device - which also shouldn't happen. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
* Fix memory leaks when failing to create a uinput devicePeter Hutterer2014-02-271-13/+4
| | | | | | | | | | For an invalid fd, or a failure to open the device, the pre-allocated uinput device struct would leak. We can drop the open_uinput() function now, since skipping to the error handling means we'll return -errno anyway. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
* Make uinput-code backwards-compatible to missing UI_SET_PROPBIT ioctlPeter Hutterer2013-10-231-1/+18
| | | | | Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: David Herrmann <dh.herrmann@gmail.com>
* Revamp the API once againPeter Hutterer2013-09-101-1/+1
| | | | | | | | | | | | | | | | | Another look at the current API showed some inconsistencies, rectified in this commit: libevdev_kernel_*: modify the underlying kernel device libevdev_event_type_*: something with an event type libevdev_event_code_*: something with an event code libevdev_event_*: struct input_event-related functions (i.e. not device-related) libevdev_property_*: something with a property libevdev_*: anything applying to a device Hopefully that's the last API change. Current symbols deprecated and aliased. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Acked-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
* Warn if there are multiple devices with the same syspathPeter Hutterer2013-09-031-5/+10
| | | | | | | | | Change to the previous code in that we continue looking at devices even after we've found one. However, this way we can warn the user when we can't guarantee syspath correctness. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
* Log a few errors, specifically application bugsPeter Hutterer2013-09-031-1/+4
| | | | | Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
* uinput: don't try to set the syspath twicePeter Hutterer2013-08-311-0/+1
| | | | | | | | If we have it, stop searching for it. Otherwise a second device with the same name would overwrite the first, causing a leak. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
* Fix off-by-one errors when dealing with *_MAX values.Peter Hutterer2013-08-301-3/+3
| | | | | | | LED_MAX, KEY_MAX, ABS_MT_MAX, etc. are all valid event codes Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
* Use AC_USE_SYSTEM_EXTENSIONSPeter Hutterer2013-08-291-1/+0
| | | | | | | Defines _GNU_SOURCE for us. http://www.gnu.org/software/autoconf/manual/autoconf-2.67/html_node/Posix-Variants.html Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
* Add support for uinput device creationPeter Hutterer2013-08-291-0/+361
This lets libevdev provide a relatively generic interface for the creation of uinput devices so we don't need to duplicate this across multiple projects. Most of this is lifted from the current test implementation, with a couple of minor changes. EV_REP needs special handling: Kernel allows to set the EV_REP bit, it doesn't set REP_* bits (which we wrap anyway) but it will also set the default values (500, 33). Device node is guessed based on the sysfs path: The sysfs path contains a eventN file, that corresponds to our /dev/input/eventN number. Use it so clients can quickly get the device node, without a libudev dependency. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>