summaryrefslogtreecommitdiff
path: root/libevdev
Commit message (Collapse)AuthorAgeFilesLines
* Don't bother sanitizing disabled event codesPeter Hutterer2016-08-171-0/+3
| | | | | | | | | | | | | | | Filter them immediately instead of passing them on and relying on the actual event handling code to filter them. Reproducer: if EV_ABS is disabled on an Apple MagicMouse we still get events passed into sanitize_event(). But the code handling EV_ABS events doesn't update the state, so we end up complaining about double tracking IDs, even though that is not actually correct. https://bugzilla.redhat.com/show_bug.cgi?id=1361325 Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
* libevdev: Properly distribute uinput.hArmin K2016-05-161-1/+1
| | | | | Signed-off-by: Armin K <krejzi@email.com> Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
* Fix typo in doc stringPeter Hutterer2016-04-201-1/+1
| | | | Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
* uinput: support the new UI_DEV_SETUP/UI_ABS_SETUP ioctlsPeter Hutterer2016-04-071-10/+64
| | | | | | | | Available in kernel 4.5 and later (uinput version 5), these ioctls allow us to set the absinfo correctly, i.e. including the resolution. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
* uinput: split uinput device creation into a helper functionPeter Hutterer2016-04-071-20/+36
| | | | | | | | No functional changes. This is prep work for supporting the new UIDEV_DEV_SETUP ioctl. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
* uinput: drop an unused argumentPeter Hutterer2016-04-071-2/+2
| | | | | Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
* Add parsing linux/input-event-codes.h, update to kernel v4.5Peter Hutterer2016-03-302-7/+8
| | | | | | | | | | The kernel has split most of the event codes out to a new header but the FF_ bits are missing from that header. Until this is fixed upstream, change the event code parsing so it can take two files (using cat and stdin) so we can update the kernel headers again. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
* uinput: fix race condition in uinput syspath checkPeter Hutterer2016-01-041-8/+8
| | | | | | | | In theory, the device could change between stat() call and open(), resulting in us opening the new device. Change to open() first, then fstat() on the fd. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: David Herrmann <dh.herrmann@gmail.com>
* Document that the fd should be drained before libevdev_set_fdPeter Hutterer2015-12-171-1/+11
| | | | | | | | | | | | | | | | | This is the caller's responsibility, for two reasons: * we don't know if O_NONBLOCK is set, so draining the fd isn't a simple matter of read() until EAGAIN. A select() + read() could work around this of course. * for stateless information, keys and relative data, it is not a problem when there are events waiting on the fd already, they are processed correctly, albeit with a delay. So punt this decision to the caller, they openend the fd, they know if they care about delayed events, they can drain the fd before handing it to us. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Acked-by: Benjamin Tissoires <benjamin.tissoires@gmail.com> Acked-by: David Herrmann <dh.herrmann@gmail.com>
* Fix invalid absinfo range values reported by certain mtk socAndreas Pokorny2015-08-241-0/+23
| | | | | | | | | | | | | | This change will only affect certain touch screens, for which the driver integration code does not provide meaningful values for the allowed range of ABS_MT_TRACKING_IDs. The reported range [0, 0] will be overwritten with [-1, 0xFFFF] Signed-off-by: Andreas Pokorny <andreas.pokorny@canonical.com> [Changed from INT_MAX to 0xFFFF to match the kernel, add device name to log message] Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
* Note that libevdev_free() does not close the fdPeter Hutterer2015-06-291-0/+3
| | | | Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
* Accept LIBEVDEV_READ_FLAG_BLOCKING as valid flagPeter Hutterer2015-04-081-1/+5
| | | | | | | https://bugs.freedesktop.org/show_bug.cgi?id=89798 Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
* ABS_MAX counts as MT axis for the event queuePeter Hutterer2015-03-231-1/+1
| | | | Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
* cosmetic: fix a commentPeter Hutterer2015-03-231-1/+1
| | | | Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
* cosmetic: fix a couple of duplicate/missing empty linesPeter Hutterer2015-03-046-14/+5
| | | | Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
* Use memcpy/memmove instead of loop operationsThilo Schulz2015-02-021-9/+8
| | | | | Signed-off-by: Thilo Schulz <thilo@tjps.eu> 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>
* Shut up clang compiler warningsPeter Hutterer2015-01-071-0/+9
| | | | | | | | clang looks at GCC pragmas, but doesn't understand -Woverride-init. Instead, it uses -Winitializer-overrides. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: David Herrmann <dh.herrmann@gmail.com>
* doc: add the prefixing * to all @code doxygen sectionsPeter Hutterer2014-11-182-226/+226
| | | | | | | | These were removed in (7da329b) because for some reason they got copied into the output. That was either a buggy doxygen or just some other problem. Add them again, makes it much easier to read the header file. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
* Remove superfluous linebreak in an error messagePeter Hutterer2014-11-181-1/+1
| | | | Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
* doc: fix uinput example codePeter Hutterer2014-11-181-7/+13
| | | | Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
* Fix a confusing commentPeter Hutterer2014-11-171-1/+1
| | | | Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
* doc: fix slightly confusing code/type commentsRan Benita2014-08-281-3/+3
| | | | | Signed-off-by: Ran Benita <ran234@gmail.com> Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
* Add some minimal documentation about static linkingPeter Hutterer2014-08-251-0/+14
| | | | | | | I can't recommend it, but I can't stop people from doing it, so at least document the ground rules. 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>
* Rename symbols leaking from static library to avoid name clashesPeter Hutterer2014-08-202-12/+12
| | | | | | | | The static library currently leaks log_msg and log_priority. Both are too generic, so rename them, with a leading underscore to hint they're supposed to be private. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
* Add libevdev_property_from_name()Peter Hutterer2014-08-204-1/+56
| | | | | | | | | 12717d79 "Add libevdev_event_type/code_from_name() resolvers" added the lookup functions for types and codes, this commit adds the missing ones for input properties. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
* 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>
* include: add uinput.h header as wellPeter Hutterer2014-06-251-1/+2
| | | | | | | | | Older kernels don't have UI_GET_SYSNAME, and upstream is adding a few more ioctls to the uinput code. So ship the header we're using to avoid compilation errors. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Benjamin Tissoires <benjamin.tissoires@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-202-15/+20
| | | | | Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
* whitespace fixPeter Hutterer2014-06-191-1/+1
| | | | Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
* Add per-device log handlersPeter Hutterer2014-06-055-49/+203
| | | | | | | | | | | | | | | | | | | | | | 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>
* Mark the log functions with the printf format attributePeter Hutterer2014-06-052-3/+5
| | | | | Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: David Herrmann <dh.herrmann@gmail.com>
* Document that we need uinput in the kernel for the test suitePeter Hutterer2014-05-221-1/+2
| | | | Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
* 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>
* Drain all events before synchronizing after SYN_DROPPEDPeter Hutterer2014-04-242-20/+83
| | | | | | | | | | | | | | | | | | | | The kernel ring buffer drops all events on SYN_DROPPED, but then continues to fill up again. So by the time we read the events, the kernel's client buffer is essentially like this: SYN_DROPPED, ev1, ev2, ev3, ...., evN The kernel's device state represents the device after evN, and that is what the ioctls return. For EV_KEY, EV_SND, EV_LED and EV_SW the kernel removes potential duplicates from the client buffer [1], it doesn't do so for EV_ABS. So we can't actually sync while there are events on the wire because the events represent an earlier state. So simply discard all events in the kernel buffer, synchronize, and then start processing again. We lose some granularity but at least the events are correct. [1] http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/drivers/input/evdev.c?id=483180281f0ac60d1138710eb21f4b9961901294 Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
* Move read_more_events() up in the filePeter Hutterer2014-04-241-25/+25
| | | | | | | No functional change Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
* Actually make the min queue size a minimumPeter Hutterer2014-04-101-1/+1
| | | | | Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
* Clarify what signal-safe meansPeter Hutterer2014-04-101-3/+4
| | | | | | Just in case... Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
* Calling libevdev_enable_event_code() overwrites EV_ABS/EV_REP valuesPeter Hutterer2014-04-081-0/+4
| | | | | | Document this behaviour Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
* Split the SYN_DROPPED page into a few sectionsPeter Hutterer2014-04-071-0/+9
| | | | Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
* Fix a typo, add a @ref in the documentationPeter Hutterer2014-04-071-2/+2
| | | | Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
* Drop invalid ABS_MT_TRACKING_ID changesPeter Hutterer2014-04-031-11/+36
| | | | | | | | | | | | | | | | | | | | | | Follow-up to commit 41334b5b40cd5456f5f584b55d8888aaafa1f26e Author: Peter Hutterer <peter.hutterer@who-t.net> Date: Thu Mar 6 11:54:00 2014 +1000 If the tracking ID changes during SYN_DROPPED, terminate the touch first In normal mode, we may get double tracking ID events in the same slot, but only if we either have a user-generated event sequence (uinput) or a malicious device that tries to send data on a slot > dev->num_slots. Since the client is unlikely to be able to handle these events, discard the ABS_MT_TRACKING_ID completely. This is a bug somewhere in the stack, so complain and hobble on along. Note: the kernel doesn't allow that, but we cap to num_slots anyway, see 66fee1bec4c4b021e1b54adcd775cf6e2aa84869. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
* Move slot-related initialization downPeter Hutterer2014-04-031-30/+33
| | | | | | | No real effects, but improves readability Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
* Drop hardcoded MAX_SLOTS in favour of pre-allocated memoryPeter Hutterer2014-04-033-21/+49
| | | | | | | | | | | | | | | | | | | | | We can't allocate in sync_mt_state since it may be called in the signal handler. So pre-allocate based on the device's number of slots, store that in the libevdev struct and use it for the sync process. This fixes a remaining bug with the handling of ABS_MT_TRACKING_ID. If a device had > MAX_SLOTS and a slot above that limit would start or stop during a SYN_DROPPED event, the slot would not be synced, and a subsequent touch in that slot may double-terminate or double-open a touchpoint in the client. For the effects of that see commit 41334b5b40cd5456f5f584b55d8888aaafa1f26e Author: Peter Hutterer <peter.hutterer@who-t.net> Date: Thu Mar 6 11:54:00 2014 +1000 If the tracking ID changes during SYN_DROPPED, terminate the touch first Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
* Only sync the initial MT state for Protocol B devicesPeter Hutterer2014-04-031-1/+3
| | | | | | | | For protocol A devices we won't get the information from the kernel anyway and we expect all axes to be updated in the next event. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
* Drop unnecessary memsetPeter Hutterer2014-04-031-1/+0
| | | | | | | | | | The EVICOCGMTSLOTS ioctl returns all slot values for the requested code or an error code, it doesn't return the number of bytes successfully transferred. Thus all values in the input array are always defined (on success), we don't need to memset it. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>