Commit graph

440 commits

Author SHA1 Message Date
Peter Hutterer
4e7863eee1 libevdev 1.2.99.1
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-06-05 15:16:05 +10:00
Peter Hutterer
576ceeea59 libevdev 1.2.2
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-06-05 15:15:30 +10:00
Peter Hutterer
f5c4de024d 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>
2014-06-05 15:15:12 +10:00
Peter Hutterer
25507127bd Document that we need uinput in the kernel for the test suite
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-05-22 15:07:59 +10:00
Peter Hutterer
ee6d8b6f6e libevdev 1.2.1
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-05-14 15:12:31 +10:00
Peter Hutterer
067426385e test: unconditionally distribute the valgrind suppressions
Reported-by: David Herrmann <dh.herrmann@gmail.com>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-05-07 18:55:02 +10:00
Peter Hutterer
d0af7f2851 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>
2014-05-07 18:52:17 +10:00
Peter Hutterer
b5a39e9e05 libevdev 1.2
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-04-30 15:08:25 +10:00
Peter Hutterer
a93baace89 test: run all tests through valgrind
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2014-04-29 10:49:10 +10:00
Peter Hutterer
974e330ac2 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>
2014-04-29 10:48:36 +10:00
Peter Hutterer
9d22a52383 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>
2014-04-28 08:27:06 +10:00
Peter Hutterer
5dacba1ef8 libevdev 1.2RC1
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-04-24 08:24:09 +10:00
Peter Hutterer
050bca91a1 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>
2014-04-24 08:17:01 +10:00
Peter Hutterer
8b01184404 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>
2014-04-24 08:17:01 +10:00
Peter Hutterer
1c425e9837 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>
2014-04-10 11:00:56 +10:00
Peter Hutterer
779654839a Clarify what signal-safe means
Just in case...

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-04-10 11:00:56 +10:00
Peter Hutterer
d55056c468 Calling libevdev_enable_event_code() overwrites EV_ABS/EV_REP values
Document this behaviour

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-04-08 09:01:56 +10:00
Peter Hutterer
6721131eaf test: restore default log priority after tests
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-04-08 09:01:50 +10:00
Peter Hutterer
c44e510acd Split the SYN_DROPPED page into a few sections
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-04-07 14:26:31 +10:00
Peter Hutterer
be87068a9b Fix a typo, add a @ref in the documentation
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-04-07 14:23:21 +10:00
Peter Hutterer
6cbf971b39 Drop invalid ABS_MT_TRACKING_ID changes
Follow-up to
commit 41334b5b40
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
66fee1bec4.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2014-04-03 13:31:40 +10:00
Peter Hutterer
27df93737e 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>
2014-04-03 13:31:39 +10:00
Peter Hutterer
f8fba5b588 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 41334b5b40
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>
2014-04-03 13:30:49 +10:00
Peter Hutterer
ca082d5fcb 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>
2014-04-03 12:08:54 +10:00
Peter Hutterer
7164e1d412 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>
2014-04-03 12:08:28 +10:00
Peter Hutterer
fda0b3bf23 Use libevdev_reset from libevdev_free
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2014-04-02 12:04:46 +10:00
Peter Hutterer
79041dd602 Add quote around device name during error message
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-04-02 11:35:58 +10:00
Peter Hutterer
c97839a81e 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>
2014-04-02 11:35:56 +10:00
Peter Hutterer
befe33620b 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>
2014-04-02 11:35:12 +10:00
Peter Hutterer
f90c038a2d 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>
2014-04-02 11:35:12 +10:00
Peter Hutterer
9fa89aabba 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>
2014-04-01 17:05:53 +10:00
Peter Hutterer
e8505f57a4 Fix indentation
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-04-01 14:02:41 +10:00
Peter Hutterer
b23649e1ba libevdev 1.1
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-03-25 16:20:24 +10:00
Peter Hutterer
a75e1c3533 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>
2014-03-21 11:27:27 +10:00
Peter Hutterer
66a78e3391 libevdev 1.1RC2
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-03-19 10:30:02 +10:00
Peter Hutterer
019953ebea Bump library revision
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-03-19 10:29:51 +10:00
Peter Hutterer
f29008b758 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>
2014-03-19 09:36:41 +10:00
Peter Hutterer
2ad8980c5a 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>
2014-03-19 09:36:41 +10:00
Peter Hutterer
982866824c 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>
2014-03-19 09:36:41 +10:00
Peter Hutterer
ab4fdcc0d5 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>
2014-03-19 09:36:41 +10:00
Peter Hutterer
b7bc345b40 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>
2014-03-19 09:36:41 +10:00
Peter Hutterer
aa4726c7e2 add a linebreak for correct rendering of the documentation
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-03-18 15:12:35 +10:00
Peter Hutterer
29a5a5e5fc 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>
2014-03-14 09:38:18 +10:00
Peter Hutterer
4d975f9317 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>
2014-03-14 09:38:18 +10:00
Peter Hutterer
fb480e7d8f 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>
2014-03-14 09:38:18 +10:00
Peter Hutterer
2b0fda32ed 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>
2014-03-11 09:19:18 +10:00
Peter Hutterer
dff2502254 libevdev 1.1RC1
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-03-11 08:31:12 +10:00
Peter Hutterer
9b0d1f708a test: fix distcheck
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-03-11 08:31:12 +10:00
Peter Hutterer
6ba45a0006 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>
2014-03-07 10:16:16 +10:00
Peter Hutterer
41334b5b40 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>
2014-03-07 10:16:16 +10:00