summaryrefslogtreecommitdiff
path: root/libevdev
Commit message (Collapse)AuthorAgeFilesLines
* Print an error on an invalid log priorityPeter Hutterer2013-09-181-0/+1
| | | | Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
* Merge branch 'clockid'Peter Hutterer2013-09-182-0/+27
|\
| * wrap EVIOCSCLOCKID into an API callPeter Hutterer2013-09-132-0/+27
| | | | | | | | | | Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
* | Fix a typo in the uinput documentationPeter Hutterer2013-09-171-2/+2
| | | | | | | | Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
* | Move libevdev_led_value documentation to the kernel groupPeter Hutterer2013-09-171-0/+3
|/ | | | Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
* Fix a comment to reflect the new APIPeter Hutterer2013-09-121-3/+3
| | | | Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
* Remove warning comment from FORCE_SYNCPeter Hutterer2013-09-111-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>
* Name-space the read flags betterPeter Hutterer2013-09-114-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>
* Enumerate libevdev_next_event() return codesPeter Hutterer2013-09-112-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>
* Fix comment typoPeter Hutterer2013-09-111-1/+1
| | | | Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
* Add missing group assignment to a bunch of functions and enumerationsPeter Hutterer2013-09-111-6/+26
| | | | | | Without these, they won't show up in the documentation. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
* Revamp the API once againPeter Hutterer2013-09-105-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>
* Merge branch 'logging-fix'Peter Hutterer2013-09-104-38/+187
|\
| * Log to stderr by defaultPeter Hutterer2013-09-102-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>
| * 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-032-10/+31
| | | | | | | | | | 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-033-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>
| * 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>
| * 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-313-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>
* | Fix comment typoPeter Hutterer2013-09-041-1/+1
| | | | | | | | Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
* | Match the kernel define for SYN_MAXPeter Hutterer2013-09-041-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>
* | Check for GNU ld and use the flags depending on the outcomePeter Hutterer2013-09-041-4/+1
| | | | | | | | | | Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: David Herrmann <dh.herrmann@gmail.com>
* | Add some gcc/ld optimizations and magicDavid Herrmann2013-09-031-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>
* 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-302-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>
* 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-294-2/+627
| | | | | | | | | | | | | | | | | | | | 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>
* Fix two signed vs unsigned int warningsPeter Hutterer2013-08-292-2/+2
| | | | | | | | 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>
* Actually use the gcc CFLAGS set in configurePeter Hutterer2013-08-291-1/+1
| | | | Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
* Mark all external symbols with LIBEVDEV_EXPORTPeter Hutterer2013-08-292-49/+54
| | | | | | | | | 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>
* Add C++ header guardsPeter Hutterer2013-08-291-0/+9
| | | | 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-292-28/+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>
* Add a note that libevdev_is_event_type/code have compile-time rangesPeter Hutterer2013-08-291-0/+6
| | | | | Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Acked-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>
* Axis values must be int, not unsigned intPeter Hutterer2013-08-291-1/+1
| | | | Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
* Ignore -Woverride-init in event-names.hPeter Hutterer2013-08-291-2/+3
| | | | | | | | | | | | Having the declarations in the form of [0...EV_MAX] = NULL together with the actual definitions causes warnings for every true definition if -Woverride-init is enabled. We can drop them for most as they're zero, but still need them for ev_max (which defaults to -1), not zero. So use the GCC pragma to disable the warnings for this file. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
* Change event name generate script to be python 2/3 compatiblePeter Hutterer2013-08-291-47/+48
| | | | | | | | | | | | | | | | | | Python 3 doesn't have a print statement, only a print function. Fixed with: 2to3 make-event-names.py | git apply Print as function requires Python 2.6 which is reasonable enough given that even RHEL6 ships that. Even though it's not needed for 2.6, use from __future__ import print_function to avoid accidentally introducing a print statement in the future. With this line, print "blah" is now a syntax error in python 2. This line was added manually, after the 2to3 conversion. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
* Add support for EV_SWPeter Hutterer2013-08-292-0/+53
| | | | | 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-262-10/+10
| | | | | | | 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-262-1/+16
| | | | | | | | | | | 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>