platform/upstream/libevdev.git
9 years agolibevdev 1.3.2 libevdev-1.3.2
Peter Hutterer [Fri, 5 Dec 2014 04:27:19 +0000 (14:27 +1000)]
libevdev 1.3.2

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
9 years agotools: zero-pad PID/VID in the dpi tool
Peter Hutterer [Fri, 5 Dec 2014 04:17:27 +0000 (14:17 +1000)]
tools: zero-pad PID/VID in the dpi tool

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
9 years agotools: print the hwdb match line from the dpi tool
Peter Hutterer [Mon, 1 Dec 2014 04:51:13 +0000 (14:51 +1000)]
tools: print the hwdb match line from the dpi tool

Let's make this as easy as possible

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
9 years agotools: add a tool to estimate the resolution of a mouse
Peter Hutterer [Mon, 17 Nov 2014 05:52:24 +0000 (15:52 +1000)]
tools: add a tool to estimate the resolution of a mouse

Relative devices don't provide a physical resolution to the host. For things
like pointer acceleration, the physical amount of movement is better as
baseline than the movement in device units.

Alas, many devices don't come with any information at all, so the users have
to guess. Help that guesswork by providing a tool that does the calculations
for them.

This tool measures the device units covered, then prints the frequency and an
lookup table for various resolutions (in dpi) to match to the physical
movement of the device.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
9 years agodoc: add the prefixing * to all @code doxygen sections
Peter Hutterer [Mon, 17 Nov 2014 02:13:25 +0000 (12:13 +1000)]
doc: add the prefixing * to all @code doxygen sections

These were removed in (7da329b) because for some reason they got copied into
the output. That was either a buggy doxygen or just some other problem. Add
them again, makes it much easier to read the header file.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
9 years agotest: add test for clock id setting on an invalid device
Peter Hutterer [Mon, 17 Nov 2014 02:06:46 +0000 (12:06 +1000)]
test: add test for clock id setting on an invalid device

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
9 years agotest: add test for setting absinfo on invalid devices
Peter Hutterer [Mon, 17 Nov 2014 02:01:41 +0000 (12:01 +1000)]
test: add test for setting absinfo on invalid devices

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
9 years agotest: add test case for grab calls on invalid devices
Peter Hutterer [Mon, 17 Nov 2014 01:54:04 +0000 (11:54 +1000)]
test: add test case for grab calls on invalid devices

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
9 years agotest: add missing tests for invalid calls on next_event/has_event_pending
Peter Hutterer [Mon, 17 Nov 2014 01:37:43 +0000 (11:37 +1000)]
test: add missing tests for invalid calls on next_event/has_event_pending

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
9 years agoRemove superfluous linebreak in an error message
Peter Hutterer [Mon, 17 Nov 2014 01:51:04 +0000 (11:51 +1000)]
Remove superfluous linebreak in an error message

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
9 years agodoc: fix uinput example code
Peter Hutterer [Mon, 17 Nov 2014 22:03:27 +0000 (08:03 +1000)]
doc: fix uinput example code

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
9 years agoFix a confusing comment
Peter Hutterer [Mon, 17 Nov 2014 01:26:29 +0000 (11:26 +1000)]
Fix a confusing comment

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
9 years agolibevdev 1.3.1 libevdev-1.3.1
Peter Hutterer [Thu, 13 Nov 2014 01:05:22 +0000 (11:05 +1000)]
libevdev 1.3.1

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
9 years agodoc: update doxygen.in for current doxygen
Peter Hutterer [Thu, 13 Nov 2014 01:05:55 +0000 (11:05 +1000)]
doc: update doxygen.in for current doxygen

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
9 years agoinclude: update to 3.17 header
Peter Hutterer [Wed, 12 Nov 2014 23:40:42 +0000 (09:40 +1000)]
include: update to 3.17 header

Adds INPUT_PROP_POINTING_STICK

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
9 years agolibevdev 1.3 libevdev-1.3
Peter Hutterer [Tue, 9 Sep 2014 01:29:15 +0000 (11:29 +1000)]
libevdev 1.3

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
9 years agodoc: fix slightly confusing code/type comments
Ran Benita [Wed, 27 Aug 2014 18:53:39 +0000 (21:53 +0300)]
doc: fix slightly confusing code/type comments

Signed-off-by: Ran Benita <ran234@gmail.com>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
9 years agoconfigure.ac: print prefix and libdir
Peter Hutterer [Tue, 26 Aug 2014 23:42:56 +0000 (09:42 +1000)]
configure.ac: print prefix and libdir

When building for multiple prefixes from the same repo it's nice to see a
reminder for what the current prefix is.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
9 years agolibevdev 1.3RC2 libevdev-1.2.99.902
Peter Hutterer [Mon, 25 Aug 2014 00:28:55 +0000 (10:28 +1000)]
libevdev 1.3RC2

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
9 years agotest: fix EVIOCREVOKE test on non-supporting kernels
Peter Hutterer [Mon, 25 Aug 2014 00:28:09 +0000 (10:28 +1000)]
test: fix EVIOCREVOKE test on non-supporting kernels

The ioctl-returned errno is positive.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
9 years agoAdd some minimal documentation about static linking
Peter Hutterer [Tue, 19 Aug 2014 00:31:12 +0000 (10:31 +1000)]
Add some minimal documentation about static linking

I can't recommend it, but I can't stop people from doing it, so at least
document the ground rules.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
9 years agoHook up nm to check for leaking symbols in the static library
Peter Hutterer [Mon, 18 Aug 2014 23:16:39 +0000 (09:16 +1000)]
Hook up nm to check for leaking symbols in the static library

We ignore anything that starts with an underscore, anything that starts with
libevdev and main (since we test the test-static-link binary) and a couple of
gcov-related functions. This should catch any functions we accidentally
export.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
9 years agotest: handle the GCOV_LDFLAGS in all tests
Peter Hutterer [Mon, 18 Aug 2014 22:40:19 +0000 (08:40 +1000)]
test: handle the GCOV_LDFLAGS in all tests

We rebuild the libevdev object files with the gcov flags for the tests, so we
need to make sure those flags are present on all binaries.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
9 years agotest: override check-local instead of check
Peter Hutterer [Mon, 18 Aug 2014 22:16:37 +0000 (08:16 +1000)]
test: override check-local instead of check

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
9 years agotest: add basic static link test
Peter Hutterer [Mon, 18 Aug 2014 22:15:07 +0000 (08:15 +1000)]
test: add basic static link test

Same as the dynamic link test, just with the -static flag

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
9 years agouinput: explicitly ignore the UI_DEV_DESTROY return value
Peter Hutterer [Fri, 22 Aug 2014 01:47:38 +0000 (11:47 +1000)]
uinput: explicitly ignore the UI_DEV_DESTROY return value

This can't fail in the kernel anyway, so cast it to shut up Coverity.
Error message:
"Calling function "ioctl(int, unsigned long, ...)" without checking return
 value (as is done elsewhere 35 out of 36 times)."

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
9 years agotools: pass -rc to strerror, not rc
Peter Hutterer [Fri, 22 Aug 2014 01:45:01 +0000 (11:45 +1000)]
tools: pass -rc to strerror, not rc

rc is a negative errno

Found by Coverity.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
9 years agouinput: close the managed fd on error
Peter Hutterer [Fri, 22 Aug 2014 01:42:10 +0000 (11:42 +1000)]
uinput: close the managed fd on error

Using LIBEVDEV_UINPUT_OPEN_MANAGED can leak the fd if an error occurs after
opening it.

Found by Coverity.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
9 years agoRename symbols leaking from static library to avoid name clashes
Peter Hutterer [Mon, 18 Aug 2014 04:03:43 +0000 (14:03 +1000)]
Rename symbols leaking from static library to avoid name clashes

The static library currently leaks log_msg and log_priority. Both are too
generic, so rename them, with a leading underscore to hint they're supposed to
be private.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
9 years agoAdd libevdev_property_from_name()
Peter Hutterer [Mon, 18 Aug 2014 00:33:18 +0000 (10:33 +1000)]
Add libevdev_property_from_name()

12717d79 "Add libevdev_event_type/code_from_name() resolvers" added the
lookup functions for types and codes, this commit adds the missing ones for
input properties.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
9 years agoconfigure: move the python check down to re-unite the gcov check outputs
Peter Hutterer [Mon, 18 Aug 2014 22:20:49 +0000 (08:20 +1000)]
configure: move the python check down to re-unite the gcov check outputs

The python check was inserted between "checking whether to build with gcov"
and the answering "yes", causing a lonely "yes" or "no" to wander around the
config.log in vain, haunted by solitude and wondering about the binary
simplicity of its life.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
9 years agotest: drop include of libevdev-int.h
Peter Hutterer [Mon, 18 Aug 2014 00:32:16 +0000 (10:32 +1000)]
test: drop include of libevdev-int.h

Not needed, and shouldn't be used in a test anyway

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
9 years agotest: use ck_assert_int_eq() where comparing integers
Peter Hutterer [Mon, 18 Aug 2014 00:20:49 +0000 (10:20 +1000)]
test: use ck_assert_int_eq() where comparing integers

A simple ck_assert() just fails, a ck_assert_int_eq() also shows the two
values. Makes failures a bit easier to debug.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
9 years agouinput: preserve the errno before cleaning up
Peter Hutterer [Tue, 12 Aug 2014 05:41:45 +0000 (15:41 +1000)]
uinput: preserve the errno before cleaning up

libevdev_uinput_destroy() may/will botch the errno, make sure we save it
before use.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
9 years agouinput: check errno against the positive value
Peter Hutterer [Tue, 12 Aug 2014 05:38:47 +0000 (15:38 +1000)]
uinput: check errno against the positive value

We use the negative errno internally, but the proper errno is always positive.

Fixes device creation failures on kernels that don't support UI_SET_PROPBIT.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: David Herrmann <dh.herrmann@gmail.com>
9 years agolibevdev 1.3RC1 libevdev-1.2.99.901
Peter Hutterer [Fri, 8 Aug 2014 01:39:52 +0000 (11:39 +1000)]
libevdev 1.3RC1

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
9 years agoinclude: update to Linux 3.16 header
Peter Hutterer [Fri, 8 Aug 2014 01:12:24 +0000 (11:12 +1000)]
include: update to Linux 3.16 header

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
10 years agoinclude: add uinput.h header as well
Peter Hutterer [Mon, 23 Jun 2014 23:05:53 +0000 (09:05 +1000)]
include: add uinput.h header as well

Older kernels don't have UI_GET_SYSNAME, and upstream is adding a few more
ioctls to the uinput code. So ship the header we're using to avoid compilation
errors.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
10 years agouinput: change strcpy/strcat usage for snprintf
Peter Hutterer [Thu, 19 Jun 2014 04:20:58 +0000 (14:20 +1000)]
uinput: change strcpy/strcat usage for snprintf

Better protection against buffer overflow, though by the time someone
is manipulating your sysfs, libevdev is unlikely to be the biggest worry.

Slight change in functionality: before we checked the timestamp of
/sys/devices/virtual/input/inputXYZ before looking at /inputXYZ/name, now we
just check the name file for the timestamp.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
10 years agouinput: use the UI_GET_SYSNAME ioctl if available
Peter Hutterer [Thu, 19 Jun 2014 04:10:13 +0000 (14:10 +1000)]
uinput: use the UI_GET_SYSNAME ioctl if available

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
10 years agowhitespace fix
Peter Hutterer [Thu, 19 Jun 2014 03:52:02 +0000 (13:52 +1000)]
whitespace fix

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
10 years agotest: ignore any timer_create errors in valgrind
Peter Hutterer [Wed, 11 Jun 2014 23:47:32 +0000 (09:47 +1000)]
test: ignore any timer_create errors in valgrind

Drop the rest of the stack trace, we know whenever check calls this we get a
valgrind error if sevp in timer_create(2) is NULL.

https://bugs.freedesktop.org/show_bug.cgi?id=79921

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
10 years agoinclude: update to Linux 3.15 header
Peter Hutterer [Mon, 9 Jun 2014 21:51:09 +0000 (07:51 +1000)]
include: update to Linux 3.15 header

Adds INPUT_PROP_TOPBUTTONPAD

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
10 years agoAdd per-device log handlers
Peter Hutterer [Wed, 14 May 2014 06:36:49 +0000 (16:36 +1000)]
Add per-device log handlers

The global log handler isn't a good choice for a low-level library. In the
caser of the X server, both evdev and synaptics are now using the libevdev but
are loaded from the same server process. Thus, there's only one log handler,
but evdev and synaptics don't talk to each other (a bit childish, I know).

Add a per-device log handler that overrides the global log handler, and fall
back to the global log handler if no device log handler is set. The log
macros take care of that automatically, especially as we can't do per-device
log handlers for the uinput code.

Note that we use the same struct for the global and device logging, so in each
instance one of the two function pointers is NULL. Suicide triggers are in
place in case we mess that up.

This also makes libevdev_new_from_fd() a bit less useful since we can't set
the log handler beforehand.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: David Herrmann <dh.herrmann@gmail.com>
10 years agom4: fix CC_CHECK_WERROR and CC_FLAG_VISIBILITY macros
Peter Hutterer [Wed, 14 May 2014 23:52:14 +0000 (09:52 +1000)]
m4: fix CC_CHECK_WERROR and CC_FLAG_VISIBILITY macros

These macros come from systemd, but CC_CHECK_CFLAGS_SILENT was removed in
systemd commit eb2e280f9c59b66965c9316eadc4c113a13ca744, breaking some of
them.

CC_FLAG_VISIBILITY doesn't need to require CC_CHECK_WERROR because
CC_CHECK_FLAG_APPEND always append -Werror anyway. Which kinda brings into
question why we have CC_CHECK_WERROR in the first place, but whavever.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
10 years agolibevdev 1.2.99.1
Peter Hutterer [Wed, 14 May 2014 22:23:25 +0000 (08:23 +1000)]
libevdev 1.2.99.1

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
10 years agolibevdev 1.2.2 libevdev-1.2.2
Peter Hutterer [Thu, 5 Jun 2014 05:15:30 +0000 (15:15 +1000)]
libevdev 1.2.2

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
10 years agoMark the log functions with the printf format attribute
Peter Hutterer [Wed, 14 May 2014 23:54:10 +0000 (09:54 +1000)]
Mark the log functions with the printf format attribute

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: David Herrmann <dh.herrmann@gmail.com>
10 years agoDocument that we need uinput in the kernel for the test suite
Peter Hutterer [Thu, 22 May 2014 05:07:59 +0000 (15:07 +1000)]
Document that we need uinput in the kernel for the test suite

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
10 years agolibevdev 1.2.1 libevdev-1.2.1
Peter Hutterer [Wed, 14 May 2014 05:11:23 +0000 (15:11 +1000)]
libevdev 1.2.1

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
10 years agotest: unconditionally distribute the valgrind suppressions
Peter Hutterer [Wed, 7 May 2014 08:55:02 +0000 (18:55 +1000)]
test: unconditionally distribute the valgrind suppressions

Reported-by: David Herrmann <dh.herrmann@gmail.com>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
10 years agoIgnore NULL as argument in libevdev_uinput_destroy()
Peter Hutterer [Thu, 1 May 2014 21:53:24 +0000 (07:53 +1000)]
Ignore NULL as argument in libevdev_uinput_destroy()

Triggered by the tests when run as non-root. Simply ignore any attempt to
destroy a NULL device, which also matches the behaviour of libevdev_free().

Reported-by: Andreas Radke <a.radke@arcor.de>
Reviewed-by: Daniel Martin <consume.noise@gmail.com>
Tested-by: Daniel Martin <consume.noise@gmail.com>
Reviewed-by: David Herrmann <dh.herrmann@gmail.com>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
10 years agolibevdev 1.2 libevdev-1.2
Peter Hutterer [Wed, 30 Apr 2014 05:08:25 +0000 (15:08 +1000)]
libevdev 1.2

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
10 years agotest: run all tests through valgrind
Peter Hutterer [Thu, 24 Apr 2014 01:27:14 +0000 (11:27 +1000)]
test: run all tests through valgrind

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
10 years agotest: disable parallel testing
Peter Hutterer [Thu, 24 Apr 2014 01:14:34 +0000 (11:14 +1000)]
test: disable parallel testing

The tests create devices on the host system, avoid running them in parallel to
avoid interference between the test devices.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Acked-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
10 years agotest: silence some valgrind warnings
Peter Hutterer [Thu, 24 Apr 2014 01:08:18 +0000 (11:08 +1000)]
test: silence some valgrind warnings

ioctl points to uninitialized bytes - correct but we didn't use those anyway.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
10 years agolibevdev 1.2RC1 libevdev-1.1.99.1
Peter Hutterer [Wed, 23 Apr 2014 22:24:06 +0000 (08:24 +1000)]
libevdev 1.2RC1

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
10 years agoDrain all events before synchronizing after SYN_DROPPED
Peter Hutterer [Mon, 7 Apr 2014 05:16:28 +0000 (15:16 +1000)]
Drain all events before synchronizing after SYN_DROPPED

The kernel ring buffer drops all events on SYN_DROPPED, but then continues to
fill up again. So by the time we read the events, the kernel's client buffer is
essentially like this:
  SYN_DROPPED, ev1, ev2, ev3, ...., evN

The kernel's device state represents the device after evN, and that is what
the ioctls return. For EV_KEY, EV_SND, EV_LED and EV_SW the kernel removes
potential duplicates from the client buffer [1], it doesn't do so for EV_ABS.

So we can't actually sync while there are events on the wire because the
events represent an earlier state. So simply discard all events in the kernel
buffer, synchronize, and then start processing again. We lose some granularity
but at least the events are correct.

[1] http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/drivers/input/evdev.c?id=483180281f0ac60d1138710eb21f4b9961901294

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
10 years agoMove read_more_events() up in the file
Peter Hutterer [Mon, 7 Apr 2014 05:01:44 +0000 (15:01 +1000)]
Move read_more_events() up in the file

No functional change

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
10 years agoActually make the min queue size a minimum
Peter Hutterer [Mon, 7 Apr 2014 05:00:24 +0000 (15:00 +1000)]
Actually make the min queue size a minimum

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
10 years agoClarify what signal-safe means
Peter Hutterer [Thu, 10 Apr 2014 01:00:24 +0000 (11:00 +1000)]
Clarify what signal-safe means

Just in case...

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
10 years agoCalling libevdev_enable_event_code() overwrites EV_ABS/EV_REP values
Peter Hutterer [Fri, 4 Apr 2014 04:11:47 +0000 (14:11 +1000)]
Calling libevdev_enable_event_code() overwrites EV_ABS/EV_REP values

Document this behaviour

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
10 years agotest: restore default log priority after tests
Peter Hutterer [Fri, 4 Apr 2014 00:04:56 +0000 (10:04 +1000)]
test: restore default log priority after tests

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
10 years agoSplit the SYN_DROPPED page into a few sections
Peter Hutterer [Mon, 7 Apr 2014 04:26:31 +0000 (14:26 +1000)]
Split the SYN_DROPPED page into a few sections

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
10 years agoFix a typo, add a @ref in the documentation
Peter Hutterer [Mon, 7 Apr 2014 04:21:27 +0000 (14:21 +1000)]
Fix a typo, add a @ref in the documentation

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
10 years agoDrop invalid ABS_MT_TRACKING_ID changes
Peter Hutterer [Tue, 1 Apr 2014 07:01:39 +0000 (17:01 +1000)]
Drop invalid ABS_MT_TRACKING_ID changes

Follow-up to
commit 41334b5b40cd5456f5f584b55d8888aaafa1f26e
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date:   Thu Mar 6 11:54:00 2014 +1000

    If the tracking ID changes during SYN_DROPPED, terminate the touch first

In normal mode, we may get double tracking ID events in the same slot, but
only if we either have a user-generated event sequence (uinput) or a malicious
device that tries to send data on a slot > dev->num_slots.
Since the client is unlikely to be able to handle these events, discard the
ABS_MT_TRACKING_ID completely. This is a bug somewhere in the stack, so
complain and hobble on along.

Note: the kernel doesn't allow that, but we cap to num_slots anyway, see
66fee1bec4c4b021e1b54adcd775cf6e2aa84869.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
10 years agoMove slot-related initialization down
Peter Hutterer [Tue, 1 Apr 2014 05:40:09 +0000 (15:40 +1000)]
Move slot-related initialization down

No real effects, but improves readability

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
10 years agoDrop hardcoded MAX_SLOTS in favour of pre-allocated memory
Peter Hutterer [Tue, 1 Apr 2014 05:32:46 +0000 (15:32 +1000)]
Drop hardcoded MAX_SLOTS in favour of pre-allocated memory

We can't allocate in sync_mt_state since it may be called in the signal
handler. So pre-allocate based on the device's number of slots, store that in
the libevdev struct and use it for the sync process.

This fixes a remaining bug with the handling of ABS_MT_TRACKING_ID. If a
device had > MAX_SLOTS and a slot above that limit would start or stop during
a SYN_DROPPED event, the slot would not be synced, and a subsequent touch in
that slot may double-terminate or double-open a touchpoint in the client.
For the effects of that see

commit 41334b5b40cd5456f5f584b55d8888aaafa1f26e
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date:   Thu Mar 6 11:54:00 2014 +1000

    If the tracking ID changes during SYN_DROPPED, terminate the touch first

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
10 years agoOnly sync the initial MT state for Protocol B devices
Peter Hutterer [Tue, 1 Apr 2014 05:12:56 +0000 (15:12 +1000)]
Only sync the initial MT state for Protocol B devices

For protocol A devices we won't get the information from the kernel anyway and
we expect all axes to be updated in the next event.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
10 years agoDrop unnecessary memset
Peter Hutterer [Wed, 2 Apr 2014 01:57:41 +0000 (11:57 +1000)]
Drop unnecessary memset

The EVICOCGMTSLOTS ioctl returns all slot values for the requested code or an
error code, it doesn't return the number of bytes successfully transferred.
Thus all values in the input array are always defined (on success), we don't
need to memset it.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
10 years agoUse libevdev_reset from libevdev_free
Peter Hutterer [Wed, 2 Apr 2014 01:48:14 +0000 (11:48 +1000)]
Use libevdev_reset from libevdev_free

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
10 years agoAdd quote around device name during error message
Peter Hutterer [Tue, 1 Apr 2014 06:59:46 +0000 (16:59 +1000)]
Add quote around device name during error message

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
10 years agotest: remove checks for test device creation failure
Peter Hutterer [Wed, 2 Apr 2014 01:12:42 +0000 (11:12 +1000)]
test: remove checks for test device creation failure

test_create_... fails on a non-zero return code anyway

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
10 years agotest: the kernel test build doesn't need to link to libevdev
Peter Hutterer [Wed, 2 Apr 2014 01:24:27 +0000 (11:24 +1000)]
test: the kernel test build doesn't need to link to libevdev

We statically compile libevdev in anyway through $(common_sources)

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
10 years agotest: fix kernel test for revoke after
Peter Hutterer [Wed, 2 Apr 2014 01:31:59 +0000 (11:31 +1000)]
test: fix kernel test for revoke after

dev2 by definition doesn't initialize, we expect it to fail. Freeing it after
is a bad idea. Also initialize it to NULL so this is a bit more obvious now.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
10 years agotest: fix the tracking_id sync test
Peter Hutterer [Tue, 1 Apr 2014 06:31:41 +0000 (16:31 +1000)]
test: fix the tracking_id sync test

A max of num_slots -1 caused the first MT_SLOT event to be skipped, leading to
wrong tracking IDs in the slots.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
10 years agoFix indentation
Peter Hutterer [Tue, 1 Apr 2014 04:02:41 +0000 (14:02 +1000)]
Fix indentation

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
10 years agolibevdev 1.1 libevdev-1.1
Peter Hutterer [Tue, 25 Mar 2014 06:20:24 +0000 (16:20 +1000)]
libevdev 1.1

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
10 years agoAdd documentation for axis updates without a tracking ID
Peter Hutterer [Wed, 19 Mar 2014 04:04:59 +0000 (14:04 +1000)]
Add documentation for axis updates without a tracking ID

If a touch starts and terminates while in SYN_DROPPED, the tracking ID appears
to stay at -1, but the other axes may update. We need to pass these on to the
client since the kernel may buffer the next event with the same value
otherwise. Note this in the documentation so that client's don't create touch
points based on out-of-touchpoint updates.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
10 years agolibevdev 1.1RC2 libevdev-1.0.99.2
Peter Hutterer [Wed, 19 Mar 2014 00:30:02 +0000 (10:30 +1000)]
libevdev 1.1RC2

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
10 years agoBump library revision
Peter Hutterer [Wed, 19 Mar 2014 00:29:51 +0000 (10:29 +1000)]
Bump library revision

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
10 years agouinput: check for asprintf failure
Peter Hutterer [Tue, 18 Mar 2014 03:55:21 +0000 (13:55 +1000)]
uinput: check for asprintf failure

This doesn't really do much here, but strictly speaking: if asprintf returns
-1, devnode is undefined. So reset it to NULL to avoid weird pointers. And
also free the rest of the names if we ever have more than one device - which
also shouldn't happen.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
10 years agotest: shut up compiler warning
Peter Hutterer [Tue, 18 Mar 2014 03:58:18 +0000 (13:58 +1000)]
test: shut up compiler warning

test-libevdev-events.c: In function ‘test_double_syn_dropped_event’:
test-libevdev-events.c:187:2: warning: ignoring return value of ‘read’,
declared with attribute warn_unused_result [-Wunused-result]

This read was there to drain events even when there shouldn't be any on the
pipe anyway. So let's add an assert.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
10 years agoShut up another warning
Peter Hutterer [Tue, 18 Mar 2014 04:00:07 +0000 (14:00 +1000)]
Shut up another warning

Triggered with -O3

../libevdev/libevdev.c: In function ‘libevdev_get_event_value’:
../libevdev/libevdev.c:1112:6: warning: ‘value’ may be used uninitialized in
this function [-Wmaybe-uninitialized]

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
10 years agoShut up compiler warning
Peter Hutterer [Tue, 18 Mar 2014 03:44:39 +0000 (13:44 +1000)]
Shut up compiler warning

Triggered with -O

../libevdev/libevdev.c: In function ‘libevdev_has_event_code’:
../libevdev/libevdev-util.h:58:20: warning: ‘mask’ may be used uninitialized
in this function [-Wmaybe-uninitialized]

Optimisation clearly shuffles things around here: in the code, if no max is
found, we return -1 and bail out before we access mask.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
10 years agoSanitize events when we're skipping sync as well
Peter Hutterer [Mon, 17 Mar 2014 06:08:36 +0000 (16:08 +1000)]
Sanitize events when we're skipping sync as well

If a client doesn't sync expliciltly, make sure we sanitize the events when we
update the internal library state.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
10 years agoadd a linebreak for correct rendering of the documentation
Peter Hutterer [Tue, 18 Mar 2014 05:11:39 +0000 (15:11 +1000)]
add a linebreak for correct rendering of the documentation

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
10 years agodoc: move the section for the internal test suite down
Peter Hutterer [Tue, 11 Mar 2014 00:57:15 +0000 (10:57 +1000)]
doc: move the section for the internal test suite down

"Related Pages" in doxygen are ordered in the order they appear in the source
file. The internal test suite is least likely to be of interest to the
reader, so move it to the bottom.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
10 years agodoc: include linux/input.h verbatim in the documentation
Peter Hutterer [Tue, 11 Mar 2014 00:56:10 +0000 (10:56 +1000)]
doc: include linux/input.h verbatim in the documentation

This makes it easier to look up what specific version libevdev was compiled
against.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
10 years agodoc: Add documentation on how SYN_DROPPED is handled
Peter Hutterer [Tue, 11 Mar 2014 00:44:10 +0000 (10:44 +1000)]
doc: Add documentation on how SYN_DROPPED is handled

This is getting a bit complex, so add some high-level documentation that we at
least know what we're trying to do.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
10 years agoconfigure: add link to our wiki page
Peter Hutterer [Mon, 10 Mar 2014 23:19:18 +0000 (09:19 +1000)]
configure: add link to our wiki page

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
10 years agolibevdev 1.1RC1 libevdev-1.0.99.1
Peter Hutterer [Mon, 10 Mar 2014 22:21:49 +0000 (08:21 +1000)]
libevdev 1.1RC1

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
10 years agotest: fix distcheck
Peter Hutterer [Mon, 10 Mar 2014 22:30:29 +0000 (08:30 +1000)]
test: fix distcheck

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
10 years agoAdd a documentation note to update the slot after syncing
Peter Hutterer [Thu, 6 Mar 2014 02:38:47 +0000 (12:38 +1000)]
Add a documentation note to update the slot after syncing

Clients may not care about the events generated during SYN_DROPPED, but the
current slot must be updated to avoid a client being out-of-date.
Same with tracking IDs, if they changed, the caller will likely have to update
some internal states.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
10 years agoIf the tracking ID changes during SYN_DROPPED, terminate the touch first
Peter Hutterer [Thu, 6 Mar 2014 01:54:00 +0000 (11:54 +1000)]
If the tracking ID changes during SYN_DROPPED, terminate the touch first

Most clients can't deal with tracking ID changes unless a -1 is sent first. So
if we notice that the tracking ID has changed during the sync process, send a
set of ABS_MT_TRACKING_ID -1 events for each of those, then send the rest of
the events.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
10 years agoSend an extra ABS_MT_SLOT event to sync the client up with the current slot
Benjamin Tissoires [Wed, 5 Mar 2014 02:03:57 +0000 (12:03 +1000)]
Send an extra ABS_MT_SLOT event to sync the client up with the current slot

If multiple slots have changed during the sync handling, the client must be
re-set to the current slot before continuing with normal events.

Signed-off-by: Benjamin Tissoires <btissoir@redhat.com>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
10 years agoDon't sync the MT state for fake MT devices
Peter Hutterer [Wed, 5 Mar 2014 03:15:20 +0000 (13:15 +1000)]
Don't sync the MT state for fake MT devices

Devices with ABS_MT_SLOT-1 are fake MT devices, they merely overlap the
axis range but don't actually provide slots. The EVIOCGABS ioctl won't work to
retrieve the current value - the kernel does not store values for those axes
and the return value is always 0.

Thus, simply ignore those axes for fake MT devices and instead rely on the
next event to update the caller with the correct state for each axis.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
10 years agoMove some functions/macros between libevdev-int.h and libevdev-util.h
Peter Hutterer [Thu, 6 Mar 2014 00:22:20 +0000 (10:22 +1000)]
Move some functions/macros between libevdev-int.h and libevdev-util.h

This allows libevdev-util.h to be used by tests, it no longer relies on
libevdev internal structs.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
10 years agoCap slot values to the announced maximum
Peter Hutterer [Wed, 5 Mar 2014 00:57:01 +0000 (10:57 +1000)]
Cap slot values to the announced maximum

A malicious device may announce N slots but then send a slot index >= N. The
slot state is almost always allocated (definitely the case in libevdev and
true for most callers), so providing a slot number higher than the announced
maximum is likely to lead to invalid dereferences. Don't allow that.
Likewise, don't allow negative slot numbers.

Note that the kernel filters these events anyway, the only way to trigger this
is to change the device fd to something outside the kernel's control.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
10 years agotest: add two more checks for the current slot
Peter Hutterer [Thu, 27 Feb 2014 06:52:51 +0000 (16:52 +1000)]
test: add two more checks for the current slot

When syncing, we expect the slot to stay the same until the client has
processed the events. This already worked, just add a check to make sure.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>