summaryrefslogtreecommitdiff
path: root/libevdev/libevdev.c
Commit message (Collapse)AuthorAgeFilesLines
* Actually filter by log priorityPeter Hutterer2014-02-131-1/+1
| | | | | | | | If a message is higher than the current priority, filter it. And add a few tests that the priority is handled the way it should. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: David Herrmann <dh.herrmann@gmail.com>
* Warn about a SYN_DROPPED right after finishing a syncPeter Hutterer2014-01-221-3/+8
| | | | | | | | | | | | If the first event after a completed device sync is a SYN_DROPPED, warn the user that they're not fast enough handling this device. The test for this is rather complicated since we can't write SYN_DROPPED through uinput so we have to juggle the device fd and a pipe and switch between the two at the right time (taking into account that libevdev will read events from the fd whenever it can). Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
* Count the number of events needed for a full syncPeter Hutterer2014-01-221-4/+30
| | | | | | | | | Make sure we have a queue that is at least large enough to do a full sync after a SYN_DROPPED, plus store a few extra events in case some came in after the sync. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: David Herrmann <dh.herrmann@gmail.com>
* Don't treat devices with (ABS_MT_SLOT - 1) as multitouch devicesPeter Hutterer2013-12-101-2/+7
| | | | | | | | | | | | | Some devices (PS3 sixaxis controller) merely have a bunch of axes, without the semantic information that linux/input.h requires. For those, the ABS_MT range may be merely another axis, not the special range that we need to treat it with. Use a simple heuristic: if ABS_MT_SLOT - 1 is enabled, don't treat ABS_MT as multitouch axes. The ABS_MT_SLOT - 1 axis is not used for a real axis. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: David Herrmann <dh.herrmann@gmail.com>
* Support EV_REP values through libevdev_get_event_valuePeter Hutterer2013-12-091-0/+13
| | | | | | | | | We shouldn't have a separate API for that, the whole point of libevdev is to abstract the quirkyness of the ioctls into a common interface. So let's export the two EV_REP values through libevdev_get_event_value. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: David Herrmann <dh.herrmann@gmail.com>
* Constify libevdev_get_repeatPeter Hutterer2013-12-091-1/+1
| | | | Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
* Drop some leftover deprecated constants.Peter Hutterer2013-11-281-6/+0
| | | | Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
* Drop semicolons after getter/setter macrosPeter Hutterer2013-11-221-16/+16
| | | | | | | | libevdev.c:921:134: warning: ISO C does not allow extra ';' outside of a function [-Wpedantic] Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: David Herrmann <dh.herrmann@gmail.com>
* Drop deprecated functionsPeter Hutterer2013-11-221-49/+0
| | | | | Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: David Herrmann <dh.herrmann@gmail.com>
* Check max to see if an event type is validPeter Hutterer2013-10-241-2/+14
| | | | | | | | There's a gap in the range between EV_SW and EV_LED. Trying to enable one of those bits will segfault. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: David Herrmann <dh.herrmann@gmail.com>
* Make sure EV_SYN is always setPeter Hutterer2013-10-241-1/+2
| | | | | | | | Set the bit during device reset and make sure that if we're checking for the event type we always return true for EV_SYN. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: David Herrmann <dh.herrmann@gmail.com>
* Disallow disabling EV_SYN event codesPeter Hutterer2013-10-241-1/+1
| | | | | | | The documentation already says that, make it happen. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: David Herrmann <dh.herrmann@gmail.com>
* Reset the struct on set_fdPeter Hutterer2013-10-231-7/+19
| | | | | | | | | | | libevdev_set_fd may fail at a number of points. If it does, it errors out but does nothing otherwise. Thus, a client may call set_fd again for the same struct but on a different fd and have it succeed. Depending on when set_fd bailed out the first time, some fields may already be set. Thus, reset the whole struct at set_fd time to make sure we're nulled out appropriately. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: David Herrmann <dh.herrmann@gmail.com>
* Work around missing EVIOCGMTSLOTS ioctlPeter Hutterer2013-10-231-2/+12
| | | | Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
* When running against a kernel without properties, continue as usualPeter Hutterer2013-10-231-1/+5
| | | | | | Missing out on properties is not fatal. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
* Don't allow a negative fd in libevdev_set_fdPeter Hutterer2013-10-141-1/+2
| | | | | | Everything else responds with -EBADF, let's do so here as well. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
* Allow -1 as valid fd in libevdev_change_fdPeter Hutterer2013-10-141-14/+23
| | | | | | | | | | | Add a new flag for "initialized" and separate that from the fd logic. This way, we can call libevdev_change_fd(dev, -1) to signal that the current fd should be dropped. Otherwise libevdev can't be told to release the fd and always keeps a reference to it. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
* Print an error on an invalid log priorityPeter Hutterer2013-09-181-0/+1
| | | | Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
* wrap EVIOCSCLOCKID into an API callPeter Hutterer2013-09-131-0/+11
| | | | | Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
* Name-space the read flags betterPeter Hutterer2013-09-111-5/+11
| | | | | | | | Rename from LIBEVDEV_READ_foo to LIBEVDEV_READ_FLAG_foo to differentiate better from LIBEVDEV_READ_STATUS_foo. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Acked-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
* Enumerate libevdev_next_event() return codesPeter Hutterer2013-09-111-4/+4
| | | | | | | | | | | | | | | | Improved readability in callers, changing magic numbers 0 and 1 to rc = libevdev_next_event(); if (rc == LIBEVDEV_READ_STATUS_SUCCESS) do_something(); else if (rc == LIBEVDEV_READ_STATUS_SYNC) do_something_else() No ABI changes, the enum values are the previously documented values, this is just a readability improvement. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Acked-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
* Revamp the API once againPeter Hutterer2013-09-101-3/+38
| | | | | | | | | | | | | | | | | 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>
* Log to stderr by defaultPeter Hutterer2013-09-101-3/+27
| | | | | | | | | The logging we do use atm inside the library is largely to spot application errors. Log that to stderr by default so it doesn't get lost. 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-9/+27
| | | | | Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
* Drop per-device logging function, use per-library one insteadPeter Hutterer2013-09-031-11/+45
| | | | | | | | | | | | | | | | There's no need to have separate logging function for each device created. More likely, libevdev will be hooked up once into the logging system and expected to deal with it. Plus, this allows us to log from the uinput code where we don't have the context anyway. Requires a rename to libevdev_set_log_function to avoid ABI breaks, and while we're breaking the ABI make the logging function more sophisticated to log line, number, etc. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
* Return -EBADF for functions that need the fd initializedPeter Hutterer2013-08-311-0/+9
| | | | | Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
* Return EBADF when trying to read from an uninitalized devicePeter Hutterer2013-08-311-1/+1
| | | | | | | | All other functions that check the fd for validity return EBADF, which also makes it easier to debug if the actual device goes away. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
* Use ENOMEM instead of ENOSPCPeter Hutterer2013-08-311-4/+4
| | | | | | | | | | | | From errno(3): ENOMEM Not enough space (POSIX.1) ENOSPC No space left on device (POSIX.1) when we run out memory the reason is a failed malloc, for which ENOMEM seems more appropriate. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
* memcpy instead of invidual bittogglePeter Hutterer2013-08-311-6/+9
| | | | | | | | | | | | | | | | The ioctls return the number of bytes copied into the destination, so just copy them into the device state instead of individually flipping bits. For easier review: rc is the return value of the EVIOCG* ioctl, which is the number of bytes copied. state variables must be initialized to 0 now, in case the kernel's FOO_MAX is smaller than libevdev's FOO_MAX. If not initialized to 0, the bytes between the two max values is undefined and we may end up generating bogus events. 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-5/+5
| | | | | | | 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>
* Fix two signed vs unsigned int warningsPeter Hutterer2013-08-291-1/+1
| | | | | | | | dev->num_slots is -1 if we don't have ABS_MT_SLOT. Set dev->grabbed to the right field type. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
* Mark all external symbols with LIBEVDEV_EXPORTPeter Hutterer2013-08-291-49/+53
| | | | | | | | | GCC_CFLAGS was set by configure, but never actually used. So we didn't build with hidden symbols, rather just weeded them out later through libtool. Do this properly now, mark the symbols as visibility default. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
* Fix some compiler warnings about maybe uninitialized valuesPeter Hutterer2013-08-291-3/+3
| | | | | | | These are just to shut the compiler up, in all three cases we only access the respective values if they're defined. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
* Simplify getter/setter macrosPeter Hutterer2013-08-291-14/+14
| | | | | | Now that we've dropped the deprecated API, we can simplify the macros a bit. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
* Drop deprecated APIPeter Hutterer2013-08-291-14/+0
| | | | | Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Acked-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
* Fix a few signed/unsigned int comparisonsPeter Hutterer2013-08-291-3/+4
| | | | | Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
* libevdev_is_event_type() needs to check for < EV_CNTPeter Hutterer2013-08-291-1/+1
| | | | | | | EV_MAX is a valid (though unused) value. Reported-by: Benjamin Tissoires <benjamin.tissoires@gmail.com> Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
* Rewrite libevdev_is_event_code to avoid signed/unsigned comparisonPeter Hutterer2013-08-291-4/+7
| | | | Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
* Use libevdev_get_event_type_max from libevdev_get_event_code_namePeter Hutterer2013-08-291-3/+2
| | | | | | | This will check for invalid types for us, and we can do a better check for signed/unsigned comparison. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
* Add support for EV_SWPeter Hutterer2013-08-291-0/+52
| | | | | Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
* Avoid under-allocation of array for syncing key/led statePeter Hutterer2013-08-281-2/+2
| | | | | | | | | No functional effect as the size would end up being the same anyway due to the values of KEY_MAX and LED_MAX. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: David Herrmann <dh.herrmann@gmail.com> Reviewed-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
* Remove unneeded include of linux/uinput.hPeter Hutterer2013-08-261-1/+0
| | | | Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
* Rename enums to match lower_case formatPeter Hutterer2013-08-261-4/+4
| | | | | | | This is technically an API, but not an ABI change. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: David Herrmann <dh.herrmann@gmail.com>
* Store the abs value after handling mt eventsPeter Hutterer2013-08-261-1/+8
| | | | | | | | | | | This way any ABS_MT_ event value that comes in will also be stored in abs_info. That always corresponds to "current slot", so if a user calls libevdev_set_event_value() or libevdev_get_event_value() they're actually modifying the current slot value. When the current slot changes, sync the state back into the absinfo values. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
* write EV_SYN input_event along with led events to devicepolyphemus2013-08-261-1/+5
| | | | | | | | | | Other clients of an evdev device need to have the events they receive be separated, in moment in time, from other events by an EV_SYN/ SYN_REPORT. This is the responsibility of the client who writes events into the stream. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
* Add functions to toggle LEDs on the devicePeter Hutterer2013-08-151-0/+59
| | | | | Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
* Keep the LED state and sync it after SYN_DROPPEDPeter Hutterer2013-08-151-0/+51
| | | | | | | | This enables libevdev_get_event_value(dev, EV_LED, LED_NUML); to check if a LED is on or off. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
* Add setters for an event or slot valuePeter Hutterer2013-08-151-0/+47
| | | | Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
* Rename libevdev_kernel_set_abs_value to libevdev_kernel_set_abs_infoPeter Hutterer2013-08-141-0/+7
| | | | | | | Keep it in line with the non-kernel setter Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
* Sync the key state on startupPeter Hutterer2013-08-141-0/+4
| | | | | Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>