Commit graph

38 commits

Author SHA1 Message Date
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
9b0d1f708a test: fix distcheck
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-03-11 08:31:12 +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
Benjamin Tissoires
d3ae3da90f 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>
2014-03-07 10:16:11 +10:00
Peter Hutterer
12ff51b871 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>
2014-03-06 14:30:03 +10:00
Peter Hutterer
66fee1bec4 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>
2014-03-06 14:30:03 +10:00
Peter Hutterer
4ba56ac309 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>
2014-03-06 09:21:02 +10:00
Peter Hutterer
f3f31b47fc Increase MAX_SLOTS to 60
As seen on 3M devices, which seems to be the maximum seen so far. Some Stantum
devices report 255 touches but are only capable of 10, so the are not affected
by our limits.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Acked-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2014-03-06 09:21:02 +10:00
Peter Hutterer
d596bd7a32 test: add a test for > MAX_SLOTS mt values
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2014-03-06 09:21:02 +10:00
Peter Hutterer
b08ed615d3 test: whitespace fixes (newlines)
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-03-05 19:16:08 +10:00
Peter Hutterer
05c061c2bc test: plug more memory leaks
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-02-27 13:19:12 +10:00
Peter Hutterer
642c91fc6a Warn about a SYN_DROPPED right after finishing a sync
If the first event after a completed device sync is a SYN_DROPPED, warn the
user that they're not fast enough handling this device.

The test for this is rather complicated since we can't write SYN_DROPPED
through uinput so we have to juggle the device fd and a pipe and switch
between the two at the right time (taking into account that libevdev will read
events from the fd whenever it can).

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-01-22 09:15:14 +10:00
Peter Hutterer
4eeda3bc47 test: fix typo
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-01-17 10:54:58 +10:00
Peter Hutterer
650f372c90 test: rename a test to match what it's testing better
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-01-17 10:54:58 +10:00
Peter Hutterer
714c2ffa9e Merge branch 'ev-rep-handling' 2013-12-09 09:49:43 +10:00
Peter Hutterer
f66bf57baa State that the event is defined for a SYN_DROPPED
All clients that want to handle SYN_DROPPED correctly need to pass an EV_SYN
through their own handlers before starting with the syn events. Rather than
letting them synthesize that, guarantee that the event is defined the first
time LIBEVDEV_READ_STATUS_SYNC is returned.

This does not change existing behavior, it merely documents it so we can rely
on it.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-12-09 09:49:28 +10:00
Peter Hutterer
a2f842bb8a Support EV_REP values through libevdev_get_event_value
We shouldn't have a separate API for that, the whole point of libevdev is to
abstract the quirkyness of the ioctls into a common interface. So let's
export the two EV_REP values through libevdev_get_event_value.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: David Herrmann <dh.herrmann@gmail.com>
2013-12-09 09:49:15 +10:00
Peter Hutterer
661602fe3b Name-space the read flags better
Rename from LIBEVDEV_READ_foo to LIBEVDEV_READ_FLAG_foo to differentiate
better from LIBEVDEV_READ_STATUS_foo.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Acked-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2013-09-11 12:10:15 +10:00
Peter Hutterer
5d2fc78138 Enumerate libevdev_next_event() return codes
Improved readability in callers, changing magic numbers 0 and 1 to

rc = libevdev_next_event();
if (rc == LIBEVDEV_READ_STATUS_SUCCESS)
    do_something();
else if (rc == LIBEVDEV_READ_STATUS_SYNC)
    do_something_else()

No ABI changes, the enum values are the previously documented values,
this is just a readability improvement.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Acked-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2013-09-11 12:10:12 +10:00
Peter Hutterer
69f89c8877 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>
2013-08-31 09:40:41 +10:00
Peter Hutterer
a8871e7aea 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>
2013-08-29 13:54:50 +10:00
Peter Hutterer
b20becc942 Add support for EV_SW
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2013-08-29 11:13:47 +10:00
Peter Hutterer
edc31cf12e 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>
2013-08-26 09:52:33 +10:00
Peter Hutterer
bfb6c1c6c5 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>
2013-08-15 10:32:40 +10:00
Peter Hutterer
74d9b4c72d Add setters for an event or slot value
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-08-15 10:32:37 +10:00
Peter Hutterer
a28473cb62 Add libevdev_has_event_pending()
Returns non-zero if there are events avialable to be read.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
Reviewed-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2013-08-01 13:53:04 +10:00
Peter Hutterer
33d0fff566 test: add a few sync test cases for incomplete syncs
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-07-02 14:02:58 +10:00
Peter Hutterer
d347e7d4e4 test: add test for abs and mt syncing
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-07-01 14:40:22 +10:00
Peter Hutterer
592d5167e4 test: add tests for mt event values
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-07-01 13:36:23 +10:00
Peter Hutterer
f7c580976c test: add tests for checking event values
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-07-01 13:36:20 +10:00
Peter Hutterer
3ad61372c8 test: add test for filtered event delivery
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-07-01 10:10:25 +10:00
Peter Hutterer
f456a9dce4 test: use new convenience function for uinput device creation
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-06-29 18:19:50 +10:00
Peter Hutterer
a30f4cfa8a test: prepare a common header file for all tests
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-06-29 18:00:42 +10:00
Peter Hutterer
20fb3fc875 test: close the right pipe fds
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-06-28 13:15:27 +10:00
Peter Hutterer
e8f059f235 test: fix a bunch of memory leaks
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-06-28 13:13:55 +10:00
Peter Hutterer
9ddd477f62 test: add test case for button deltas after SYN_DROPPED
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-06-28 11:25:51 +10:00
Peter Hutterer
627b33cfe7 Require a flag for normal mode too
Makes the whole thing more explicit.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-06-27 14:20:03 +10:00
Peter Hutterer
671a1e2feb test: add test for event polling and SYN_DROPPED handling
Rudimentary only, but it's a start

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-06-27 13:32:38 +10:00