Commit graph

295 commits

Author SHA1 Message Date
David Herrmann
d64ee00eeb Create event type/code lookup tables
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-31 11:23:13 +10:00
David Herrmann
5183bf3763 Add startswith() helper
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-31 11:23:13 +10:00
David Herrmann
639a5a9b56 Fix wrong libevdev clock test
We can rely on CLOCK_MONOTONIC and CLOCK_REALTIME to be different at any
time. However, this does not apply to the ms/us/ns parts of the current
time. Both may be in sync regarding the current micro-seconds state. So
remove the wrong clock us-comparison.

I was able to trigger this on my machine. Chances that both are in sync
are very low so I assume my RTC only provides low granularity and thus
both clocks are sync during boot for higher granularity.

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-31 11:23:13 +10:00
Peter Hutterer
34d52e143d Require autoconf 2.62
According to Gaetan, that's what we really require. And as a bonus point, this makes libevdev build
on RHEL6 out-of-the-box.

CC: Gaetan Nadon <memsize@videotron.ca>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-10-31 11:23:13 +10:00
Peter Hutterer
c4111f717a Check max to see if an event type is valid
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-24 15:13:41 +10:00
Peter Hutterer
521ba2300e Make sure EV_SYN is always set
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-24 15:13:41 +10:00
Peter Hutterer
03c3e4f975 Disallow disabling EV_SYN event codes
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-24 15:13:41 +10:00
Peter Hutterer
b15e5987b3 Reset the struct on set_fd
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-23 09:04:41 +10:00
Peter Hutterer
e1cabf4f67 Revert "Check for linux/input.h during configure"
We now ship our own linux/input.h, so no need to have the header around locally.

This reverts commit fcf80ba371.
2013-10-23 09:04:41 +10:00
Peter Hutterer
346e3eed6a Document backwards-compatibility behaviour
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-10-23 09:04:41 +10:00
Peter Hutterer
306f856f67 Work around missing EVIOCGMTSLOTS ioctl
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-10-23 09:04:41 +10:00
Peter Hutterer
ae738d29ea Make uinput-code backwards-compatible to missing UI_SET_PROPBIT ioctl
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: David Herrmann <dh.herrmann@gmail.com>
2013-10-23 09:04:41 +10:00
Peter Hutterer
f9bdb66ab4 When running against a kernel without properties, continue as usual
Missing out on properties is not fatal.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-10-23 09:04:41 +10:00
Peter Hutterer
caa9267290 Pass linux/input.h as argument to make-event-names.py
Rather than a hardcoded path inside the source.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-10-23 09:04:41 +10:00
Peter Hutterer
2a3219f55d Add a copy of linux/input.h
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-23 09:04:34 +10:00
Peter Hutterer
db3ecc334b configure: test for python and python-argparse
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: David Herrmann <dh.herrmann@gmail.com>
2013-10-21 20:17:22 +10:00
Peter Hutterer
0dbf1ea4f8 Don't allow a negative fd in libevdev_set_fd
Everything else responds with -EBADF, let's do so here as well.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-10-14 14:20:55 +10:00
Peter Hutterer
e8920d2fd4 Allow -1 as valid fd in libevdev_change_fd
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-14 14:20:55 +10:00
Peter Hutterer
fcf80ba371 Check for linux/input.h during configure
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-10-08 14:53:01 +10:00
Peter Hutterer
2660b58336 Uppercase #define LIBEVDEV_INT_H
over-eager search/replace

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-10-08 14:22:27 +10:00
Peter Hutterer
49203b040e Note that libevdev_change_fd requires a LIBEVDEV_FORCE_SYNC
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-10-04 16:15:43 +10:00
Peter Hutterer
d9fcbd563a Mark three deprecated functions as such
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-10-04 16:02:22 +10:00
Peter Hutterer
3a4706796e Use AC_MSG_RESULT to print the few configuration options
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2013-10-02 09:55:08 +10:00
Peter Hutterer
c8b5f6a08f Disable gcov by default
Having libevdev build with profiling enabled by default
leaves profiling files around. Profiling is something that only
libevdev developers should need, so let them enable it
case-by-case.

https://bugzilla.redhat.com/show_bug.cgi?id=1012180

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2013-10-02 09:40:43 +10:00
Stephen Kitt
92b03c9da1 Avoid shipping generated documentation twice
Only add files to EXTRA_DIST, to avoid having a full copy of doc/html as
doc/html/html in the distributed tarball.

Signed-off-by: Stephen Kitt <skitt@debian.org>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-09-24 04:21:17 +10:00
Peter Hutterer
c365d22b70 Add extern C guards to libevdev-uinput.h
Reported-by: Stanisław Halik <sthalik@misaki.pl>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-09-19 08:32:00 +10:00
Peter Hutterer
c5c7c914af Capitalize uinput header guards
victim of some overly vicious search/replace

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-09-19 08:31:33 +10:00
Peter Hutterer
f6fc441c73 libevdev 0.4
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-09-18 14:38:26 +10:00
Peter Hutterer
90fa52f4f6 Print an error on an invalid log priority
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-09-18 14:37:35 +10:00
Peter Hutterer
bf32246957 Merge branch 'clockid' 2013-09-18 11:44:06 +10:00
Peter Hutterer
ab2ab19ca3 tools: make to function calls static
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-09-17 20:11:38 +10:00
Peter Hutterer
64efc0b5bf Fix a typo in the uinput documentation
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-09-17 20:11:38 +10:00
Peter Hutterer
001d194c19 Move libevdev_led_value documentation to the kernel group
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-09-17 20:11:38 +10:00
Colin Walters
34fc7ee425 tools: Honor GCC_CFLAGS
So we get compiler warnings from tools/ too.

Signed-off-by: Colin Walters <walters@verbum.org>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-09-17 20:11:32 +10:00
Peter Hutterer
e156f9a11c Drop duplicate compiler flag
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-09-16 16:00:06 +10:00
Peter Hutterer
3dc41b29b7 Revert "Reintroduce -fstack-protector"
http://lists.freedesktop.org/archives/input-tools/2013-September/000332.html
See above a detailed reasoning, but Colin Walters put it this way:

"At a high level, I think components (git repositories) should feel free
to set up default warning flags and possibly use a targeted subset of
-Werror=foo.  But please don't inject non-warning flags like this unless
there is a very good reason.

The right way to do -fstack-protector is to have something like
redhat-rpm-config or other global CFLAGS system controlling *all*
components."

Thus, reverting the -fstack-protector flag. This doesn't completely address
Colin's comments, we still use a few other flags. But this one is the one
that causes real headaches, so drop it.

This reverts commit f5e65ea3ce.
2013-09-16 15:55:10 +10:00
David Herrmann
f5e65ea3ce Reintroduce -fstack-protector
We removed this previously due to build failures in:

  commit 14ac764ec8
  Author: David Herrmann <dh.herrmann@gmail.com>
  Date:   Mon Sep 9 16:03:41 2013 +0200

      build: remove -fstack-protector

Reintroduce it but this time disable it if it's not supported. We use the
CC-flags testing to prevent build-failures on gcc without libssp support.

Cc: Giovanni Campagna <gcampagn@redhat.com>
Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-09-13 15:51:23 +10:00
David Herrmann
92b2b1ccd5 Test for CFLAGS/LFLAGS availability
Use the CC_CHECK_FLAGS_APPEND() m4 macro to test for availability of
CFLAGS and LFLAGS. It automatically drops the unavailable flags.

This is also used by systemd, so it ought to work with ostree and other
non-standard build-environments.

Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-09-13 15:49:50 +10:00
Peter Hutterer
1e81ac1e28 wrap EVIOCSCLOCKID into an API call
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2013-09-13 09:28:00 +10:00
Peter Hutterer
c299ab3c5e test: provide wrapper for fetching the devnode from a uinput test device
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2013-09-13 08:59:06 +10:00
Peter Hutterer
b539cfd808 test: add a test for checking log data being passed around correctly
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-09-12 14:28:05 +10:00
Peter Hutterer
a263d7f71b Fix a comment to reflect the new API
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-09-12 14:15:56 +10:00
Peter Hutterer
64e1ed2cef Remove warning comment from FORCE_SYNC
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-11 12:10:15 +10:00
Peter Hutterer
661602fe3b Name-space the read flags better
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-11 12:10:15 +10:00
Peter Hutterer
5d2fc78138 Enumerate libevdev_next_event() return codes
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-11 12:10:12 +10:00
Peter Hutterer
7421760eae Require check 0.9.9
0.9.9 is the first released version with fixed ck_assert_* macros that don't do
multiple expansion.

http://sourceforge.net/p/check/code/596/

Reported-by: Martin Minarik <minarik11@student.fiit.stuba.sk>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-09-11 12:07:51 +10:00
Peter Hutterer
37a69d5675 Fix comment typo
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-09-11 12:06:08 +10:00
Peter Hutterer
dab889781b doc: don't show enum values in doxygen
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-09-11 12:06:08 +10:00
Peter Hutterer
4eb87a113a Add missing group assignment to a bunch of functions and enumerations
Without these, they won't show up in the documentation.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-09-11 12:05:54 +10:00
Peter Hutterer
ab2f20bfd6 Revamp the API once again
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-10 11:25:09 +10:00