platform/upstream/libevdev.git
10 years agoAdd extern C guards to libevdev-uinput.h
Peter Hutterer [Wed, 18 Sep 2013 22:32:00 +0000 (08:32 +1000)]
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>
10 years agoCapitalize uinput header guards
Peter Hutterer [Wed, 18 Sep 2013 22:31:33 +0000 (08:31 +1000)]
Capitalize uinput header guards

victim of some overly vicious search/replace

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
10 years agolibevdev 0.4 libevdev-0.4
Peter Hutterer [Wed, 18 Sep 2013 04:38:26 +0000 (14:38 +1000)]
libevdev 0.4

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
10 years agoPrint an error on an invalid log priority
Peter Hutterer [Wed, 18 Sep 2013 04:37:35 +0000 (14:37 +1000)]
Print an error on an invalid log priority

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
10 years agoMerge branch 'clockid'
Peter Hutterer [Wed, 18 Sep 2013 01:44:06 +0000 (11:44 +1000)]
Merge branch 'clockid'

10 years agotools: make to function calls static
Peter Hutterer [Tue, 17 Sep 2013 10:10:18 +0000 (20:10 +1000)]
tools: make to function calls static

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
10 years agoFix a typo in the uinput documentation
Peter Hutterer [Tue, 17 Sep 2013 02:26:21 +0000 (12:26 +1000)]
Fix a typo in the uinput documentation

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
10 years agoMove libevdev_led_value documentation to the kernel group
Peter Hutterer [Tue, 17 Sep 2013 01:59:38 +0000 (11:59 +1000)]
Move libevdev_led_value documentation to the kernel group

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
10 years agotools: Honor GCC_CFLAGS
Colin Walters [Mon, 16 Sep 2013 12:27:40 +0000 (08:27 -0400)]
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>
10 years agoDrop duplicate compiler flag
Peter Hutterer [Mon, 16 Sep 2013 06:00:06 +0000 (16:00 +1000)]
Drop duplicate compiler flag

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
10 years agoRevert "Reintroduce -fstack-protector"
Peter Hutterer [Mon, 16 Sep 2013 05:55:10 +0000 (15:55 +1000)]
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 f5e65ea3ce2541fe8ccfafe9b0dd04325da75b34.

10 years agoReintroduce -fstack-protector
David Herrmann [Thu, 12 Sep 2013 16:07:54 +0000 (18:07 +0200)]
Reintroduce -fstack-protector

We removed this previously due to build failures in:

  commit 14ac764ec86452ca607403f314b0f8355d80290c
  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>
10 years agoTest for CFLAGS/LFLAGS availability
David Herrmann [Thu, 12 Sep 2013 16:07:53 +0000 (18:07 +0200)]
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>
10 years agowrap EVIOCSCLOCKID into an API call
Peter Hutterer [Thu, 12 Sep 2013 03:42:24 +0000 (13:42 +1000)]
wrap EVIOCSCLOCKID into an API call

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
10 years agotest: provide wrapper for fetching the devnode from a uinput test device
Peter Hutterer [Thu, 12 Sep 2013 04:03:55 +0000 (14:03 +1000)]
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>
10 years agotest: add a test for checking log data being passed around correctly
Peter Hutterer [Thu, 12 Sep 2013 04:27:28 +0000 (14:27 +1000)]
test: add a test for checking log data being passed around correctly

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
10 years agoFix a comment to reflect the new API
Peter Hutterer [Thu, 12 Sep 2013 03:39:40 +0000 (13:39 +1000)]
Fix a comment to reflect the new API

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
10 years agoRemove warning comment from FORCE_SYNC
Peter Hutterer [Wed, 11 Sep 2013 01:17:08 +0000 (11:17 +1000)]
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>
10 years agoName-space the read flags better
Peter Hutterer [Wed, 11 Sep 2013 01:04:54 +0000 (11:04 +1000)]
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>
10 years agoEnumerate libevdev_next_event() return codes
Peter Hutterer [Wed, 11 Sep 2013 00:32:36 +0000 (10:32 +1000)]
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>
10 years agoRequire check 0.9.9
Peter Hutterer [Tue, 10 Sep 2013 23:21:32 +0000 (09:21 +1000)]
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>
10 years agoFix comment typo
Peter Hutterer [Wed, 11 Sep 2013 02:01:05 +0000 (12:01 +1000)]
Fix comment typo

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
10 years agodoc: don't show enum values in doxygen
Peter Hutterer [Wed, 11 Sep 2013 01:57:30 +0000 (11:57 +1000)]
doc: don't show enum values in doxygen

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
10 years agoAdd missing group assignment to a bunch of functions and enumerations
Peter Hutterer [Wed, 11 Sep 2013 01:47:39 +0000 (11:47 +1000)]
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>
10 years agoRevamp the API once again
Peter Hutterer [Tue, 27 Aug 2013 03:33:37 +0000 (13:33 +1000)]
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>
10 years agobuild: remove -fstack-protector
David Herrmann [Mon, 9 Sep 2013 14:03:41 +0000 (16:03 +0200)]
build: remove -fstack-protector

If gcc is built without libssp support, it loudly fails linking due to
missing __stack_chk_*() helpers. Unfortunately, gcc isn't smart enough to
disable it automatically.

systemd recently got a CC_CHECK_FLAG_APPEND helper to work around such
issues:
  http://cgit.freedesktop.org/systemd/systemd/tree/m4/attributes.m4

I didn't want to add it now, so let's just drop -fstack-protector. If we
want it, we can try adding it later again.

This partially reverts:
  commit 43752ec17d09b132621a86f5cbc546ca6ab9e977
  Author: David Herrmann <dh.herrmann@gmail.com>
  Date:   Sun Sep 1 17:45:04 2013 +0200

      Add some gcc/ld optimizations and magic

All other gcc/ld options are kept.

Reported-by: Giovanni Campagna <gcampagn@redhat.com>
Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
10 years agoconfigure: add missing comma
Giovanni Campagna [Mon, 9 Sep 2013 12:41:11 +0000 (14:41 +0200)]
configure: add missing comma

Without that, it becomes impossible to build without gcov.

Signed-off-by: Giovanni Campagna <scampa.giovanni@gmail.com>
Reviewed-by: David Herrmann <dh.herrmann@gmail.com>
Reviewed-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
10 years agoSupport GNOME Build API
Giovanni Campagna [Mon, 9 Sep 2013 12:41:10 +0000 (14:41 +0200)]
Support GNOME Build API

By adding an autogen.sh file with NOCONFIGURE support.

Signed-off-by: Giovanni Campagna <scampa.giovanni@gmail.com>
Reviewed-by: David Herrmann <dh.herrmann@gmail.com>
Reviewed-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
10 years agoMerge branch 'logging-fix'
Peter Hutterer [Mon, 9 Sep 2013 23:59:11 +0000 (09:59 +1000)]
Merge branch 'logging-fix'

10 years agotest: test for logging function
Peter Hutterer [Tue, 3 Sep 2013 06:54:44 +0000 (16:54 +1000)]
test: test for logging function

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
10 years agoLog to stderr by default
Peter Hutterer [Tue, 3 Sep 2013 06:58:29 +0000 (16:58 +1000)]
Log to stderr by default

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>
10 years agoFix comment typo
Peter Hutterer [Tue, 3 Sep 2013 04:37:49 +0000 (14:37 +1000)]
Fix comment typo

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
10 years agoMatch the kernel define for SYN_MAX
Peter Hutterer [Mon, 2 Sep 2013 21:52:31 +0000 (07:52 +1000)]
Match the kernel define for SYN_MAX

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>
10 years agoCheck for GNU ld and use the flags depending on the outcome
Peter Hutterer [Tue, 3 Sep 2013 00:32:00 +0000 (10:32 +1000)]
Check for GNU ld and use the flags depending on the outcome

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: David Herrmann <dh.herrmann@gmail.com>
10 years agoWarn if there are multiple devices with the same syspath
Peter Hutterer [Sat, 31 Aug 2013 03:03:47 +0000 (13:03 +1000)]
Warn if there are multiple devices with the same syspath

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>
10 years agoLog a few errors, specifically application bugs
Peter Hutterer [Sat, 31 Aug 2013 02:53:36 +0000 (12:53 +1000)]
Log a few errors, specifically application bugs

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
10 years agoDrop per-device logging function, use per-library one instead
Peter Hutterer [Mon, 26 Aug 2013 03:24:26 +0000 (13:24 +1000)]
Drop per-device logging function, use per-library one instead

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>
10 years agoRemove -g from default GCC_CFLAGS
David Herrmann [Sun, 1 Sep 2013 15:45:05 +0000 (17:45 +0200)]
Remove -g from default GCC_CFLAGS

-g should be set by debugging-options or in the default CFLAGS="", we
shouldn't force it in GCC_CFLAGS.

Reported-by: Peter Hutterer <peter.hutterer@who-t.net>
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>
10 years agoAdd some gcc/ld optimizations and magic
David Herrmann [Sun, 1 Sep 2013 15:45:04 +0000 (17:45 +0200)]
Add some gcc/ld optimizations and magic

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>
10 years agouinput: don't try to set the syspath twice
Peter Hutterer [Sat, 31 Aug 2013 02:59:27 +0000 (12:59 +1000)]
uinput: don't try to set the syspath twice

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>
10 years agoReturn -EBADF for functions that need the fd initialized
Peter Hutterer [Sat, 31 Aug 2013 02:37:14 +0000 (12:37 +1000)]
Return -EBADF for functions that need the fd initialized

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
10 years agoReturn EBADF when trying to read from an uninitalized device
Peter Hutterer [Sat, 31 Aug 2013 02:33:33 +0000 (12:33 +1000)]
Return EBADF when trying to read from an uninitalized device

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>
10 years agoUse ENOMEM instead of ENOSPC
Peter Hutterer [Sat, 31 Aug 2013 02:23:44 +0000 (12:23 +1000)]
Use ENOMEM instead of ENOSPC

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>
10 years agotest: update to test for the various _MAX values
Peter Hutterer [Fri, 30 Aug 2013 00:21:01 +0000 (10:21 +1000)]
test: update to test for the various _MAX values

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
10 years agomemcpy instead of invidual bittoggle
Peter Hutterer [Thu, 29 Aug 2013 05:52:54 +0000 (15:52 +1000)]
memcpy instead of invidual bittoggle

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>
10 years agotest: add a test for uinput device properties
Peter Hutterer [Fri, 30 Aug 2013 00:12:30 +0000 (10:12 +1000)]
test: add a test for uinput device properties

Specifically, test for INPUT_PROP_MAX, which is a valid property value

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
10 years agoFix off-by-one errors when dealing with *_MAX values.
Peter Hutterer [Thu, 29 Aug 2013 05:38:53 +0000 (15:38 +1000)]
Fix off-by-one errors when dealing with *_MAX values.

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>
10 years agoUse AC_USE_SYSTEM_EXTENSIONS
Peter Hutterer [Mon, 26 Aug 2013 03:08:12 +0000 (13:08 +1000)]
Use AC_USE_SYSTEM_EXTENSIONS

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>
10 years agotest: fix ev_rep test for new uinput implementation
Peter Hutterer [Mon, 29 Jul 2013 02:15:07 +0000 (12:15 +1000)]
test: fix ev_rep test for new uinput implementation

We can actually set EV_REP values now, though with limitations

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
10 years agotest: switch udev backend over to new libevdev-uinput bits
Peter Hutterer [Mon, 29 Jul 2013 03:50:41 +0000 (13:50 +1000)]
test: switch udev backend over to new libevdev-uinput bits

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
10 years agotest: add uinput creation tests
Peter Hutterer [Fri, 26 Jul 2013 04:35:54 +0000 (14:35 +1000)]
test: add uinput creation tests

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
10 years agoAdd support for uinput device creation
Peter Hutterer [Thu, 25 Jul 2013 05:56:11 +0000 (15:56 +1000)]
Add support for uinput device creation

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>
10 years agoFix two signed vs unsigned int warnings
Peter Hutterer [Thu, 29 Aug 2013 01:53:59 +0000 (11:53 +1000)]
Fix two signed vs unsigned int warnings

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>
10 years agoActually use the gcc CFLAGS set in configure
Peter Hutterer [Fri, 23 Aug 2013 00:42:10 +0000 (10:42 +1000)]
Actually use the gcc CFLAGS set in configure

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
10 years agoMark all external symbols with LIBEVDEV_EXPORT
Peter Hutterer [Thu, 29 Aug 2013 01:50:09 +0000 (11:50 +1000)]
Mark all external symbols with LIBEVDEV_EXPORT

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>
10 years agoFix some compiler warnings about maybe uninitialized values
Peter Hutterer [Sun, 25 Aug 2013 22:39:55 +0000 (08:39 +1000)]
Fix some compiler warnings about maybe uninitialized values

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>
10 years agoconfigure.ac: Drop a superfluous variable
Peter Hutterer [Fri, 23 Aug 2013 04:01:34 +0000 (14:01 +1000)]
configure.ac: Drop a superfluous variable

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
10 years agoAdd C++ header guards
Peter Hutterer [Fri, 23 Aug 2013 01:08:26 +0000 (11:08 +1000)]
Add C++ header guards

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
10 years agotest: add test for libevdev_is_event_code(EV_SYN...)
Peter Hutterer [Fri, 23 Aug 2013 00:57:50 +0000 (10:57 +1000)]
test: add test for libevdev_is_event_code(EV_SYN...)

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
10 years agoSimplify getter/setter macros
Peter Hutterer [Fri, 23 Aug 2013 00:49:56 +0000 (10:49 +1000)]
Simplify getter/setter macros

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>
10 years agoDrop deprecated API
Peter Hutterer [Fri, 23 Aug 2013 00:48:46 +0000 (10:48 +1000)]
Drop deprecated API

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Acked-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
10 years agoFix a few signed/unsigned int comparisons
Peter Hutterer [Fri, 23 Aug 2013 00:28:57 +0000 (10:28 +1000)]
Fix a few signed/unsigned int comparisons

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
10 years agoAdd a note that libevdev_is_event_type/code have compile-time ranges
Peter Hutterer [Fri, 23 Aug 2013 00:26:36 +0000 (10:26 +1000)]
Add a note that libevdev_is_event_type/code have compile-time ranges

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Acked-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
10 years agolibevdev_is_event_type() needs to check for < EV_CNT
Peter Hutterer [Thu, 29 Aug 2013 01:17:08 +0000 (11:17 +1000)]
libevdev_is_event_type() needs to check for < EV_CNT

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>
10 years agoRewrite libevdev_is_event_code to avoid signed/unsigned comparison
Peter Hutterer [Fri, 23 Aug 2013 00:25:08 +0000 (10:25 +1000)]
Rewrite libevdev_is_event_code to avoid signed/unsigned comparison

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
10 years agoUse libevdev_get_event_type_max from libevdev_get_event_code_name
Peter Hutterer [Fri, 23 Aug 2013 00:20:50 +0000 (10:20 +1000)]
Use libevdev_get_event_type_max from libevdev_get_event_code_name

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>
10 years agoAxis values must be int, not unsigned int
Peter Hutterer [Fri, 23 Aug 2013 00:15:50 +0000 (10:15 +1000)]
Axis values must be int, not unsigned int

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
10 years agoIgnore -Woverride-init in event-names.h
Peter Hutterer [Thu, 22 Aug 2013 06:04:40 +0000 (16:04 +1000)]
Ignore -Woverride-init in event-names.h

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>
10 years agoChange event name generate script to be python 2/3 compatible
Peter Hutterer [Sun, 25 Aug 2013 22:53:46 +0000 (08:53 +1000)]
Change event name generate script to be python 2/3 compatible

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>
10 years agodoc: actually package generated documentation
Peter Hutterer [Tue, 27 Aug 2013 01:42:48 +0000 (11:42 +1000)]
doc: actually package generated documentation

Previous find command wouldn't actually list the generated documentation
files, so they'd be missing in the tarball.

...and add a dist-hook to make sure this won't happen during release.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
10 years agoAdd support for EV_SW
Peter Hutterer [Wed, 14 Aug 2013 09:52:25 +0000 (19:52 +1000)]
Add support for EV_SW

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
10 years agoAvoid under-allocation of array for syncing key/led state
Peter Hutterer [Mon, 26 Aug 2013 22:03:17 +0000 (08:03 +1000)]
Avoid under-allocation of array for syncing key/led state

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>
10 years agoRemove unneeded include of linux/uinput.h
Peter Hutterer [Mon, 26 Aug 2013 03:10:05 +0000 (13:10 +1000)]
Remove unneeded include of linux/uinput.h

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
10 years agoMerge branch 'led-handling'
Peter Hutterer [Sun, 25 Aug 2013 23:53:10 +0000 (09:53 +1000)]
Merge branch 'led-handling'

10 years agoRename enums to match lower_case format
Peter Hutterer [Wed, 14 Aug 2013 00:17:59 +0000 (10:17 +1000)]
Rename enums to match lower_case format

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>
10 years agoStore the abs value after handling mt events
Peter Hutterer [Thu, 15 Aug 2013 01:10:17 +0000 (11:10 +1000)]
Store the abs value after handling mt events

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>
10 years agowrite EV_SYN input_event along with led events to device
polyphemus [Fri, 9 Aug 2013 15:38:51 +0000 (17:38 +0200)]
write EV_SYN input_event along with led events to device

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>
10 years agoFix build without MSC_TIMESTAMP
Martin Minarik [Fri, 23 Aug 2013 17:47:55 +0000 (19:47 +0200)]
Fix build without MSC_TIMESTAMP

To build with older input.h

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
10 years agoPass --no-print-directory to make
David Herrmann [Sat, 17 Aug 2013 11:58:18 +0000 (13:58 +0200)]
Pass --no-print-directory to make

The "Entering/Leaving directroy /xyz" messages only add noise to
make-output. Even without we still get short hints which directory is
currently processed. Compare the two outputs below:

With --no-print-directory added:
  make --no-print-directory all-recursive
  Making all in doc
  doxygen libevdev.doxygen
  Making all in libevdev
  python2 ./make-event-names.py --output=c > event-names.h
  make  all-am
    CC       libevdev.lo
    CCLD     libevdev.la
  Making all in tools
    CC       libevdev-events.o
    CCLD     libevdev-events
  Making all in test
    CC       test-main.o
    CC       test-event-names.o
    CC       test-libevdev-init.o
    CC       test-libevdev-has-event.o
    CC       test-int-queue.o
    CC       test-libevdev-events.o
    CC       libevdev.o
    CC       test-common-uinput.o
    CC       test-common.o
    CCLD     test-libevdev

Without it:
  make  all-recursive
  make[1]: Entering directory `/home/david/dev/libevdev'
  Making all in doc
  make[2]: Entering directory `/home/david/dev/libevdev/doc'
  doxygen libevdev.doxygen
  make[2]: Leaving directory `/home/david/dev/libevdev/doc'
  Making all in libevdev
  make[2]: Entering directory `/home/david/dev/libevdev/libevdev'
  python2 ./make-event-names.py --output=c > event-names.h
  make  all-am
  make[3]: Entering directory `/home/david/dev/libevdev/libevdev'
    CC       libevdev.lo
    CCLD     libevdev.la
  make[3]: Leaving directory `/home/david/dev/libevdev/libevdev'
  make[2]: Leaving directory `/home/david/dev/libevdev/libevdev'
  Making all in tools
  make[2]: Entering directory `/home/david/dev/libevdev/tools'
    CC       libevdev-events.o
    CCLD     libevdev-events
  make[2]: Leaving directory `/home/david/dev/libevdev/tools'
  Making all in test
  make[2]: Entering directory `/home/david/dev/libevdev/test'
    CC       test-main.o
    CC       test-event-names.o
    CC       test-libevdev-init.o
    CC       test-libevdev-has-event.o
    CC       test-int-queue.o
    CC       test-libevdev-events.o
    CC       libevdev.o
    CC       test-common-uinput.o
    CC       test-common.o
    CCLD     test-libevdev
  make[2]: Leaving directory `/home/david/dev/libevdev/test'
  make[2]: Entering directory `/home/david/dev/libevdev'
  make[2]: Leaving directory `/home/david/dev/libevdev'
  make[1]: Leaving directory `/home/david/dev/libevdev'

We don't really win any useful information from these messages.

Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
10 years agoRemove deprecated SYMBOL_CACHE_SIZE from doxygen.in
David Herrmann [Sat, 17 Aug 2013 11:58:17 +0000 (13:58 +0200)]
Remove deprecated SYMBOL_CACHE_SIZE from doxygen.in

SYMBOL_CACHE_SIZE was removed in newer doxygen releases. We use the
default value, so simply drop it.

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>
10 years agoAdd -I m4 to ACLOCAL_AMFLAGS
David Herrmann [Sat, 17 Aug 2013 11:58:14 +0000 (13:58 +0200)]
Add -I m4 to ACLOCAL_AMFLAGS

We put m4 files into a separate directory. If we ever put our own files in
there, we need to include it. Furthermore, this suppresses annoying
autotools warnings.

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>
10 years agoAdd functions to toggle LEDs on the device
Peter Hutterer [Fri, 9 Aug 2013 03:21:28 +0000 (13:21 +1000)]
Add functions to toggle LEDs on the device

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
10 years agoKeep the LED state and sync it after SYN_DROPPED
Peter Hutterer [Tue, 13 Aug 2013 23:29:41 +0000 (09:29 +1000)]
Keep the LED state and sync it after SYN_DROPPED

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>
10 years agoAdd setters for an event or slot value
Peter Hutterer [Fri, 9 Aug 2013 04:46:24 +0000 (14:46 +1000)]
Add setters for an event or slot value

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
10 years agoRename libevdev_kernel_set_abs_value to libevdev_kernel_set_abs_info
Peter Hutterer [Fri, 9 Aug 2013 03:47:00 +0000 (13:47 +1000)]
Rename libevdev_kernel_set_abs_value to libevdev_kernel_set_abs_info

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>
10 years agoSync the key state on startup
Peter Hutterer [Tue, 13 Aug 2013 23:44:21 +0000 (09:44 +1000)]
Sync the key state on startup

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
10 years agoSimplify a bit state setter
Peter Hutterer [Tue, 13 Aug 2013 23:15:51 +0000 (09:15 +1000)]
Simplify a bit state setter

set_bit_state does exactly what the previous if/else did.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
10 years agoMinor documentation improvement
Peter Hutterer [Wed, 14 Aug 2013 00:22:24 +0000 (10:22 +1000)]
Minor documentation improvement

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
10 years agotest: devices with abs axes need to be created properly
Peter Hutterer [Mon, 29 Jul 2013 03:38:28 +0000 (13:38 +1000)]
test: devices with abs axes need to be created properly

Simply enabling the bits is not enough, we need to provide axis
information too if we want to enable this properly.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
10 years agoMake the tests optional to drop unneeded dependencies
Peter Hutterer [Mon, 29 Jul 2013 04:27:41 +0000 (14:27 +1000)]
Make the tests optional to drop unneeded dependencies

libevdev has no external dependencies and both check and libudev are
only required for running the unit-tests. Make them optional.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
10 years agotest: change device for enabling/disabling bits to use REL_*
Peter Hutterer [Mon, 29 Jul 2013 03:34:48 +0000 (13:34 +1000)]
test: change device for enabling/disabling bits to use REL_*

No real effect on the test, this check is just so that a follow-up patch to
fix the tests for the new uinput backend is a bit easier to review.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
10 years agoFix stray * in documentation
Peter Hutterer [Fri, 9 Aug 2013 04:35:45 +0000 (14:35 +1000)]
Fix stray * in documentation

10 years agolibevdev 0.3 libevdev-0.3
Peter Hutterer [Thu, 8 Aug 2013 03:21:04 +0000 (13:21 +1000)]
libevdev 0.3

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
10 years agoFix header guard, lowercased in some previous search/replace
Peter Hutterer [Thu, 8 Aug 2013 03:04:11 +0000 (13:04 +1000)]
Fix header guard, lowercased in some previous search/replace

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
10 years agoAdd setters for product/vendor/bustype/version
Peter Hutterer [Thu, 25 Jul 2013 06:21:32 +0000 (16:21 +1000)]
Add setters for product/vendor/bustype/version

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
10 years agoRename ID getters to have a consistent naming scheme
Peter Hutterer [Thu, 1 Aug 2013 03:22:07 +0000 (13:22 +1000)]
Rename ID getters to have a consistent naming scheme

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
10 years agoReplace ID getter implementation with a define
Peter Hutterer [Tue, 30 Jul 2013 03:48:55 +0000 (13:48 +1000)]
Replace ID getter implementation with a define

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
10 years agoProvide setters for name, phys, uniq
Peter Hutterer [Thu, 25 Jul 2013 06:11:04 +0000 (16:11 +1000)]
Provide setters for name, phys, uniq

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
10 years agoAdd abs setters for changing a single value on an abs axis
Peter Hutterer [Wed, 24 Jul 2013 05:52:02 +0000 (15:52 +1000)]
Add abs setters for changing a single value on an abs axis

Changing a single value on an abs axis is slightly more common than
having to enable that axis outright. Provide a set of accessors for
doing so.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
10 years agoRename a few getters for consistency
Peter Hutterer [Tue, 30 Jul 2013 01:25:00 +0000 (11:25 +1000)]
Rename a few getters for consistency

Deprecated:
* libevdev_get_abs_min, libevdev_get_abs_max
* libevdev_get_input_prop_name

Will be removed in one or two versions.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>