summaryrefslogtreecommitdiff
path: root/libevdev
AgeCommit message (Collapse)AuthorFilesLines
2013-11-01Provide separate lookup functions for zero-terminated stringsHEADmasterPeter Hutterer2-12/+58
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: David Herrmann <dh.herrmann@gmail.com>
2013-10-31Add libevdev_event_type/code_from_name() resolversDavid Herrmann3-0/+177
Three new helpers are added: (1) libevdev_event_type_from_name() takes a string describing an EV_* event type and returns the given event-type constant. (2) libevdev_event_code_from_name() takes a string describing an event code and returns the given event-code constant. Signed-off-by: David Herrmann <dh.herrmann@gmail.com> Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net> Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-10-31Create event type/code lookup tablesDavid Herrmann1-4/+59
Additionally to type->string mapping tables we now also create string->type lookup tables. The lookup tables are sorted by their name so binary-search will work. We create one lookup table for EV_* types and one for all event-codes. More tables (like bus-names, input-properties, ..) can be added later. Signed-off-by: David Herrmann <dh.herrmann@gmail.com> Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net> Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-10-31Add startswith() helperDavid Herrmann1-0/+8
Simple helper that use strncmp() to test whether a given string starts with a given suffix. While it doesn't reduce code-size by much, it is a lot more readable than the strncmp() usage. Signed-off-by: David Herrmann <dh.herrmann@gmail.com> Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net> Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-10-24Check max to see if an event type is validPeter Hutterer1-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>
2013-10-24Make sure EV_SYN is always setPeter Hutterer1-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>
2013-10-24Disallow disabling EV_SYN event codesPeter Hutterer1-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>
2013-10-23Reset the struct on set_fdPeter Hutterer1-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>
2013-10-23Document backwards-compatibility behaviourPeter Hutterer1-0/+56
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-10-23Work around missing EVIOCGMTSLOTS ioctlPeter Hutterer1-2/+12
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-10-23Make uinput-code backwards-compatible to missing UI_SET_PROPBIT ioctlPeter Hutterer1-1/+18
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: David Herrmann <dh.herrmann@gmail.com>
2013-10-23When running against a kernel without properties, continue as usualPeter Hutterer1-1/+5
Missing out on properties is not fatal. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-10-23Pass linux/input.h as argument to make-event-names.pyPeter Hutterer2-7/+6
Rather than a hardcoded path inside the source. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-10-23Add a copy of linux/input.hPeter Hutterer1-2/+3
This avoids a number of otherwise required ifdefs when building on older kernels Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: David Herrmann <dh.herrmann@gmail.com>
2013-10-21configure: test for python and python-argparsePeter Hutterer1-1/+1
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: David Herrmann <dh.herrmann@gmail.com>
2013-10-14Don't allow a negative fd in libevdev_set_fdPeter Hutterer1-1/+2
Everything else responds with -EBADF, let's do so here as well. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-10-14Allow -1 as valid fd in libevdev_change_fdPeter Hutterer2-14/+25
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>
2013-10-08Uppercase #define LIBEVDEV_INT_HPeter Hutterer1-2/+2
over-eager search/replace Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-10-04Note that libevdev_change_fd requires a LIBEVDEV_FORCE_SYNCPeter Hutterer1-0/+4
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-10-04Mark three deprecated functions as suchPeter Hutterer1-3/+3
These are deprecated, but were missing the deprecated attribute. And fix up the tests that were still using those deprecated calls. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-09-19Add extern C guards to libevdev-uinput.hPeter Hutterer1-0/+7
Reported-by: Stanisław Halik <sthalik@misaki.pl> Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-09-19Capitalize uinput header guardsPeter Hutterer1-3/+3
victim of some overly vicious search/replace Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-09-18Print an error on an invalid log priorityPeter Hutterer1-0/+1
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-09-18Merge branch 'clockid'Peter Hutterer2-0/+27
2013-09-17Fix a typo in the uinput documentationPeter Hutterer1-2/+2
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-09-17Move libevdev_led_value documentation to the kernel groupPeter Hutterer1-0/+3
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-09-13wrap EVIOCSCLOCKID into an API callPeter Hutterer2-0/+27
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2013-09-12Fix a comment to reflect the new APIPeter Hutterer1-3/+3
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-09-11Remove warning comment from FORCE_SYNCPeter Hutterer1-3/+2
There is a legitimate reason for clients to force a sync on the device. X.Org drivers lose the fd when the device is disabled and re-enabled. When the device comes back, a simple libevdev_change_fd() doesn't update the status on the device. Button states, etc. may have changed, etc. So a driver may call FORCE_SYNC after re-connecting to the fd to make sure the library and the driver get the current state of the device. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Acked-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2013-09-11Name-space the read flags betterPeter Hutterer4-17/+29
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>
2013-09-11Enumerate libevdev_next_event() return codesPeter Hutterer2-17/+40
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>
2013-09-11Fix comment typoPeter Hutterer1-1/+1
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-09-11Add missing group assignment to a bunch of functions and enumerationsPeter Hutterer1-6/+26
Without these, they won't show up in the documentation. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-09-10Revamp the API once againPeter Hutterer5-12/+66
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>
2013-09-10Merge branch 'logging-fix'Peter Hutterer4-38/+187
2013-09-10Log to stderr by defaultPeter Hutterer2-5/+29
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>
2013-09-04Fix comment typoPeter Hutterer1-1/+1
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-09-04Match the kernel define for SYN_MAXPeter Hutterer1-1/+3
Will be defined as 0xf in 3.12, see http://git.kernel.org/cgit/linux/kernel/git/dtor/input.git/commit/?h=next&id=52764fed5049655926bcecaefd52f0a415ceb105 And add the required ifdef guards for kernels before that. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-09-04Check for GNU ld and use the flags depending on the outcomePeter Hutterer1-4/+1
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: David Herrmann <dh.herrmann@gmail.com>
2013-09-03Warn if there are multiple devices with the same syspathPeter Hutterer1-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>
2013-09-03Log a few errors, specifically application bugsPeter Hutterer2-10/+31
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2013-09-03Drop per-device logging function, use per-library one insteadPeter Hutterer3-17/+106
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>
2013-09-03Add some gcc/ld optimizations and magicDavid Herrmann1-1/+8
There are several gcc/ld flags that optimize size and performance without requiring explicit code changes. In no particular order, this adds: - gcc -pipe to avoid temporary files and use pipes during compilation - gcc -fno-common avoids putting uninitialized global variables not marked as "extern" into a common section. This catches compilation errors if we didn't mark global variables explicitly as "extern". - gcc -fno-strict-aliasing allows us to use unions for some binary magic. Otherwise, -O2 might assume that two different types never point at the same memory. We currently don't rely on this but it's common practice so avoid any non-obvious runtime errors later. - gcc -ffunction-sections and -fdata-sections put each function and variable into a separate section. This enables ld's --gc-sections to drop any unused sections (sections which aren't referenced from an exported section). This is very useful to avoid putting dead code into DSOs. We can now link any helper function into libevdev and the linker removes all of them if they're unused. - gcc -fstack-protector adds small stack-corruption protectors in functions which have big buffers on the stack (>8bytes). If the stack-protectors are corrupted, the process is aborted. This is highly useful to debug stack-corruption issues which often are nearly impossible to catch without this. - ld --as-needed drops all linked libraries that are not actually required by libevdev. So we can link to whatever we want and the linker will drop everything which is not actually used. - ld -z now, resolve symbols during linking, not during runtime. - ld -z relro, add relocation-read-only section. This allows to put read-only global variables and alike into a read-only section. This is useful for variables that need a relocation and thus cannot be explicitly put into a read-only section. This option tells the linker to mark them read-only after relocations are done. (that's why -z now makes sense in combination with this) All of these options are common in other open-source projects, including systemd and weston. Don't ask me why they are not marked as default.. Signed-off-by: David Herrmann <dh.herrmann@gmail.com> Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net> Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-08-31uinput: don't try to set the syspath twicePeter Hutterer1-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>
2013-08-31Return -EBADF for functions that need the fd initializedPeter Hutterer1-0/+9
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2013-08-31Return EBADF when trying to read from an uninitalized devicePeter Hutterer1-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>
2013-08-31Use ENOMEM instead of ENOSPCPeter Hutterer3-7/+7
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>
2013-08-31memcpy instead of invidual bittogglePeter Hutterer1-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>
2013-08-30Fix off-by-one errors when dealing with *_MAX values.Peter Hutterer2-8/+8
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>
2013-08-29Use AC_USE_SYSTEM_EXTENSIONSPeter Hutterer1-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>