Commit graph

265 commits

Author SHA1 Message Date
Peter Hutterer
69d89ddcc2 test: path suspend tests 2014-01-15 12:03:25 +10:00
Peter Hutterer
caaf170f4d test: add tests for libinput_create_from_path
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>

squashme path test
2014-01-15 12:03:25 +10:00
Peter Hutterer
08d0c55e62 test: add a couple of tests for the udev-seat backend
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-01-15 12:03:25 +10:00
Peter Hutterer
3a344169bb Add a device test suite
A rather large commit, copied from a similar (almost identical) suite in
libtouchpad and ported for libinput.

The goal here is to make testing for various devices easy, so the litest
("libinput test") wrappers do that. The idea is that each device has some
features, and tests are likely to exercise some features or won't work with
other features.

Each test case takes a list of required features and a list of excluded
features. The test suite will create a new test case for each device in the
suite that matches that set.

For example, the set of required LITEST_TOUCHPAD, excluded LITEST_BUTTON would
run on clickpads only, not on touchpads with buttons.

check supports suites and test cases, both named. We wrap that so that each
named set of cases we add are a test suite, with the set of devices being the
test cases. i.e.

litest_add("foo:bar", some_test_function, LITEST_ANY, LITEST_ANY);

adds a suite named "foo:bar" and test cases for both devices given, with their
shortnames as test case name, resulting in:
   "foo:bar", "trackpoint"
   "foo:bar", "clickpad"
   ...

Multiple test functions can be added to a suite. For tests without a device
requirement there is litest_add_no_device_test(...).

The environment variables CK_RUN_SUITE and CK_RUN_CASE can be used to narrow
the set of test cases. The test suite detects when run inside a debugger and
disables fork mode (the default).

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-01-15 11:59:27 +10:00
Peter Hutterer
86a50bccea test: add test for minimal linker flags
The most basic program using libinput should only need to link against -linput
and get the rest resolved automatically.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-01-15 11:26:08 +10:00
Peter Hutterer
fab5cc3439 test: add a build-test for -pedantic
We don't build with -pedantic, but a caller may try to actually stick to the
c99 standard, so let's make sure our public header doesn't cause any
issues there.

Likewise, make sure that our header compiles with GNU C90.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-01-15 11:26:08 +10:00
Peter Hutterer
0049641116 Add the framework for a test suite
Just the scaffolding, no actual tests just yet

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-01-10 14:17:06 +10:00
Peter Hutterer
7d51d769a6 Make sure our public header compiles with -pedantic
We don't use -pedantic, but a user of libinput may so let's make sure we don't
fail.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-01-10 14:17:06 +10:00
Peter Hutterer
f9c96c6e8c gitignore: ignore .swp files
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-01-10 14:17:06 +10:00
Peter Hutterer
8eac85e3fb Add libinput_next_event_type()
Returns the event type of the next event pending in the queue. For systems
that have the device init state separate from the actual event procesing
(read: xorg drivers) we need to be able to peek at the next event type to
check for the end of any initialization events (seat/device added) and the
beginning of actual device input events.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-01-10 11:23:57 +10:00
Peter Hutterer
90fa77908b Add LIBEVENT_EVENT_NONE
This event type is needed to notify callers that there is currently no
event waiting (in a follow-up patch). Also, it it avoids true/false
inconsistencies on event types (LIBINPUT_EVENT_ADDED_SEAT would otherwise be
the only FALSE event). While that's not technically necessary, it may prevent
the odd bug further down the road.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-01-10 11:18:43 +10:00
Peter Hutterer
ab9260c5c7 Drop capability events
We don't really support devices changing capabilities at runtime. The kernel
has no ability to tell us when this happens on an already-opened device and
the few devices that can literally change physical capabilities (e.g. the
wiimote) open up extra kernel devices instead of modifying the existing one.

Thus, we don't need to notify about devices changing capabilities.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-01-10 11:08:40 +10:00
Peter Hutterer
069fc60b8b Add libinput_create_from_path
Hooking libinput up to udev isn't always possible, especially if libinput were
to be used in the X server which already has the udev handling built-in.
Add an option to create a context from a path.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-01-10 11:08:24 +10:00
Peter Hutterer
3cf9cd9c86 Suspend libinput before destroying it
libinput_suspend() already causes the fds to be closed, devices and seats to
be removed, etc. Call it before libinput_destroy() to reduce the
backend-specific code.

No real functional change, the udev backend already did this anyway.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-01-10 11:08:24 +10:00
Peter Hutterer
93fbb5e05f udev: notify about a removed seat when the last device is removed
When the last device is removed from a seat, destroy the seat.
This guarantees seat removal events on libinput_suspend() as well.

Note that the seat must be manually unlinked, we can't rely on the unlinking
in libinput_seat_destroy. After the event, the seat's refcount is always > 1,
so the seat will live on until the event is destroyed. We need to make sure
it's not in the list anymore though.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-01-10 11:08:24 +10:00
Peter Hutterer
6fcaf7699c udev: Refcount the seat for each device
Use the seat's internal refcounting to up the reference each time we have a
device using it. This fixes the issue with seats being created but never
actually removed by anything.

udev_seat_get_named() will now return a seat with refcount 1 for a newly
created seat, or just up the refcount for the seat if it already exists.

This requires that the ADDED_SEAT and REMOVED_SEAT events up the refcount of
the seat as well: a device may be removed before the event is processed,
without the refcount the seat would be destroyed (if it's the last device on
the seat).

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-01-10 11:08:21 +10:00
Peter Hutterer
1ee5b28c6e Abstract the backend interface away
Remove the fixed calls into the udev backend and provide a basic interface
instead that allows other backends to hook into device/seat creation. This
enables multiple backends, specifically a path-based backend that is needed
for X.Org drivers.

This patch should have no visible functional changes.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-01-09 11:13:53 +10:00
Peter Hutterer
cd6a65bf37 Drop the destroyed sources list on libinput_destroy()
==2772== 40 bytes in 1 blocks are definitely lost in loss record 3 of 4
==2772==    at 0x4A0645D: malloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==2772==    by 0x405EC7: libinput_add_fd (libinput.c:335)
==2772==    by 0x40B346: udev_input_enable (udev-seat.c:268)
==2772==    by 0x40B5E7: libinput_create_from_udev (udev-seat.c:369)

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-01-08 20:45:58 +01:00
Peter Hutterer
4e67b6da39 Allow libinput_destroy() on a NULL pointer
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-01-08 20:45:58 +01:00
Peter Hutterer
c789a0fdd7 udev: plug leak when double-resuming
Leak when calling
  libinput_suspend();
  libinput_resume();
  libinput_resume();

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-01-08 20:45:58 +01:00
Peter Hutterer
ded615c64f Add two asserts to avoid underrunning the seat/device refcount
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-01-08 20:45:58 +01:00
Peter Hutterer
c0ac1ef9f2 Always allocate an event queue
On the typical setup we have at least 3 events pending as soon as we hook it
up (seat added, device added, capability). In the udev case we get up to > 64
events without even having input events on my laptop with only two extra
devices connected. So always allocate an event buffer to avoid spurious
resizing.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-01-07 21:28:08 +01:00
Peter Hutterer
faee8fe1a7 Don't access event buffer after realloc
realloc() may free the original event buffer, don't access it.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-01-07 21:27:30 +01:00
Peter Hutterer
4c41c6b2da gitignore: ignore ctags files
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-01-07 21:23:36 +01:00
Peter Hutterer
bc7b784b59 gitignore: generalise .libs/ and .deps/
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-01-07 21:23:09 +01:00
Peter Hutterer
1a829b7399 Remove duplicate gitignore entries
Already covered by a global rule

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-01-07 21:22:51 +01:00
Jonas Ådahl
68619ec714 Destroy associated reference counted objects when destroying context
This avoids issues with device and seat objects depending on a valid
context.

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
2014-01-03 22:38:42 +01:00
Jonas Ådahl
e637b9b0f5 udev-seat: Don't notify about removal when destroying context
As events will just be destroyed before leaving the libinput scope
during destruction, don't waste time on queueing them.

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
2014-01-03 22:33:16 +01:00
Jonas Ådahl
e92b996cff Destroy unprocessed events properly when destroying context
Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
2014-01-03 22:32:59 +01:00
Jonas Ådahl
847ce34597 Don't return error when dispatching didn't queue any event
As reading from timers or evdev does not necessarily mean an input
event is queued and ready to be retrieved with libinput_get_event(),
don't report such behaviour as an error.

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
2014-01-03 22:31:04 +01:00
Kristian Høgsberg
fef5004c46 evdev: Drop joystick rejection heurstics
We now no longer add joysticks at all.  They show up as absolute motion
devices without has_button, so we don't add them as a pointer.  We may add
a keyboard for the keyboard-style keys, but that's fine.  With the previous
commit, we no longer generate spurious absolute pointer motion for the abs
axes.

https://bugs.freedesktop.org/show_bug.cgi?id=71687
2013-12-21 12:54:27 +01:00
Kristian Høgsberg
4004080f27 evdev: Reject absolute motion if we're not a pointer or a touch device
Some joysticks have certain buttons that acts keyboard keys.  As such,
we'll reconize them as keyboards but not pointers.  In that case, don't
send pointer motion events when we get absolute joystick events.
2013-12-21 12:53:29 +01:00
Kristian Høgsberg
83f3319f18 evdev: Drop obsolete accelerometer reject rule
This rule triggers for devices with an ABS_X/Y evaluators and no
keyboard or multitouch events.  There is no way we would ever add such
a device as a pointer, keyboard or touch device anyway.  A pointer
device requires has_button (in which case the !has_key condtion would
fail); a keyboard device would also mean !has_key is false and a touch
screen device implies that !device->is_mt is false.
2013-12-21 12:51:52 +01:00
Kristian Høgsberg
6eebf35653 evdev: Remove EVDEV_TOUCH and with it evdev_device->caps
We now keep all the configuration intermediate results inside
evdev_configure_device() and the result is device->seat_caps.
2013-12-21 12:49:17 +01:00
Kristian Høgsberg
f6caf57b00 evdev: Use a has_keyboard flag instead of EVDEV_KEYBOARD bit 2013-12-21 12:44:03 +01:00
Kristian Høgsberg
4124ca1433 evdev: Replace EVDEV_BUTTON with local has_button flag 2013-12-21 12:35:43 +01:00
Kristian Høgsberg
a847278c4a evdev: Replace EVDEV_MOTION_ABS with local has_abs flag 2013-12-21 12:34:26 +01:00
Kristian Høgsberg
7226e8c368 evdev: Use has_abs only for ABS_X and ABS_Y, introduce has_mt for MT events
We split up has_abs into plain ABS_X/Y and MT events, but this shouldn't
introduce any logic changes.
2013-12-21 12:32:31 +01:00
Kristian Høgsberg
606706f87f evdev: Drop EVDEV_MOTION_REL flag
This is only used inside evdev_configure_device() and we now use a local
has_rel flag instead.
2013-12-21 12:32:06 +01:00
Kristian Høgsberg
a5db876938 evdev: Combine evdev_handle_device() and evdev_configure_device()
We split the device probing and idenfication somewhat arbitrarily between
these two functions.  This commit combines them into one.  Return of -1
indicates error, 0 success, but succesful probing can return a device
with device->caps == 0, which means we don't handle the device.
2013-12-21 12:25:17 +01:00
Peter Hutterer
e13d0c8248 doc: extract static members as well
We only run doxygen over the public headers, so if we have a static function
in those make sure they show up.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-12-21 12:11:03 +01:00
Peter Hutterer
ea246471d3 Documentation typo fix 2013-12-21 12:10:45 +01:00
Peter Hutterer
727b21f366 Fix typo in comment
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-12-21 12:10:38 +01:00
Peter Hutterer
ecc8d6c42d Document the open/close_restricted interface
Specifically, document that it needs to return a negative errno on failure.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-12-21 12:10:32 +01:00
Peter Hutterer
ed87c6dbb0 Add libudev and -lm to Requires.private
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-12-21 12:10:19 +01:00
Peter Hutterer
c7af6193b6 Add -lm to library
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-12-21 12:10:09 +01:00
Peter Hutterer
ac1f1acb41 udev: print errno if we can't open a device
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-12-21 12:10:03 +01:00
Peter Hutterer
b59d9c537b util: add ARRAY_FOR_EACH helper
Requires c99, but that's the future.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-12-21 12:09:55 +01:00
Peter Hutterer
95c6ac638f doc: group li_fixed_t into the fixed point functions
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-12-21 12:09:39 +01:00
Peter Hutterer
e4f4389341 Move zalloc() up to libinput-util.h
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-12-21 12:09:27 +01:00