Peter Hutterer [Thu, 19 Dec 2013 01:42:55 +0000 (11:42 +1000)]
Drop libinput_event_get_target()
Replaced by specific accessor functions for context, seat and device. This
obsoletes the internal target as well, we just direcly ref the element we need
to instead of temporarily storing it in the target.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Peter Hutterer [Fri, 17 Jan 2014 07:59:30 +0000 (17:59 +1000)]
Add a generic libinput_event_get_device() function
After dropping seat evens, all events are now are associated with a device, so
provide a generic accessor function and drop the custom ones.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Peter Hutterer [Wed, 15 Jan 2014 07:04:00 +0000 (17:04 +1000)]
Split seats into having a physical and a logical name
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Peter Hutterer [Wed, 15 Jan 2014 06:31:29 +0000 (16:31 +1000)]
Drop seat events
seats are more a compositor concept than a concept of the input library. All
devices in a libinput context are associated with the seat given on creation
of the seat (maps to ID_SEAT in udev for the udev backend).
A logical seat may be assigned to a device (e.g. WL_SEAT) but this does not
necessarily map to the creation of the seat in the compositor.
Drop the seat events but keep seat objects around so that the caller can still
identify which seat a device belongs to.
If the libinput_seat_unref() in the udev backend destroys the seat, the device
list of that seat is invalid and we'd be accessing already freed bytes. To
avoid this, ref the seat before the device removal loop, then unref it once
we're done - that unref then may trigger the actual removal of the seat.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Peter Hutterer [Thu, 19 Dec 2013 01:22:53 +0000 (11:22 +1000)]
Add libinput_event_get_context()
Add a function to retrieve the libinput context from any event.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Peter Hutterer [Wed, 15 Jan 2014 06:57:30 +0000 (16:57 +1000)]
udev: Drop unused seat_name in struct udev_seat
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Jonas Ådahl [Wed, 15 Jan 2014 22:24:21 +0000 (23:24 +0100)]
test: Remove short option and fail on invalid options
Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
Jonas Ådahl [Wed, 15 Jan 2014 20:33:00 +0000 (21:33 +0100)]
test: Add udev suspend->resume test
Tests that suspend removes devices and that resume rediscovers them.
Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
Jonas Ådahl [Wed, 15 Jan 2014 20:11:51 +0000 (21:11 +0100)]
test: Fix optstring in getopt_long call
Was missing the "l".
Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
Peter Hutterer [Wed, 8 Jan 2014 07:39:27 +0000 (17:39 +1000)]
test: udev suspend tests
Peter Hutterer [Wed, 8 Jan 2014 07:39:16 +0000 (17:39 +1000)]
test: path suspend tests
Peter Hutterer [Tue, 10 Dec 2013 03:30:52 +0000 (13:30 +1000)]
test: add tests for libinput_create_from_path
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
squashme path test
Peter Hutterer [Mon, 9 Dec 2013 06:36:11 +0000 (16:36 +1000)]
test: add a couple of tests for the udev-seat backend
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Peter Hutterer [Fri, 6 Dec 2013 05:02:11 +0000 (15:02 +1000)]
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>
Peter Hutterer [Tue, 10 Dec 2013 22:20:59 +0000 (08:20 +1000)]
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>
Peter Hutterer [Fri, 6 Dec 2013 04:18:39 +0000 (14:18 +1000)]
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>
Peter Hutterer [Fri, 6 Dec 2013 04:17:35 +0000 (14:17 +1000)]
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>
Peter Hutterer [Fri, 6 Dec 2013 04:29:01 +0000 (14:29 +1000)]
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>
Peter Hutterer [Fri, 10 Jan 2014 03:33:02 +0000 (13:33 +1000)]
gitignore: ignore .swp files
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Peter Hutterer [Fri, 13 Dec 2013 07:58:50 +0000 (17:58 +1000)]
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>
Peter Hutterer [Fri, 13 Dec 2013 07:49:38 +0000 (17:49 +1000)]
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>
Peter Hutterer [Thu, 9 Jan 2014 03:12:23 +0000 (13:12 +1000)]
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>
Peter Hutterer [Tue, 10 Dec 2013 03:20:36 +0000 (13:20 +1000)]
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>
Peter Hutterer [Tue, 7 Jan 2014 04:54:55 +0000 (14:54 +1000)]
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>
Peter Hutterer [Mon, 23 Dec 2013 04:16:03 +0000 (14:16 +1000)]
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>
Peter Hutterer [Mon, 23 Dec 2013 04:10:56 +0000 (14:10 +1000)]
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>
Peter Hutterer [Fri, 13 Dec 2013 01:37:31 +0000 (11:37 +1000)]
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>
Peter Hutterer [Tue, 7 Jan 2014 05:45:55 +0000 (15:45 +1000)]
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>
Peter Hutterer [Tue, 24 Dec 2013 01:00:37 +0000 (11:00 +1000)]
Allow libinput_destroy() on a NULL pointer
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Peter Hutterer [Wed, 8 Jan 2014 02:53:46 +0000 (12:53 +1000)]
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>
Peter Hutterer [Wed, 8 Jan 2014 06:40:14 +0000 (16:40 +1000)]
Add two asserts to avoid underrunning the seat/device refcount
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Peter Hutterer [Tue, 24 Dec 2013 03:50:10 +0000 (13:50 +1000)]
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>
Peter Hutterer [Tue, 24 Dec 2013 03:46:20 +0000 (13:46 +1000)]
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>
Peter Hutterer [Tue, 24 Dec 2013 00:52:28 +0000 (10:52 +1000)]
gitignore: ignore ctags files
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Peter Hutterer [Tue, 24 Dec 2013 00:51:41 +0000 (10:51 +1000)]
gitignore: generalise .libs/ and .deps/
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Peter Hutterer [Tue, 24 Dec 2013 00:51:17 +0000 (10:51 +1000)]
Remove duplicate gitignore entries
Already covered by a global rule
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Jonas Ådahl [Tue, 31 Dec 2013 15:11:03 +0000 (16:11 +0100)]
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>
Jonas Ådahl [Tue, 31 Dec 2013 13:45:50 +0000 (14:45 +0100)]
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>
Jonas Ådahl [Mon, 30 Dec 2013 21:11:33 +0000 (22:11 +0100)]
Destroy unprocessed events properly when destroying context
Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
Jonas Ådahl [Mon, 30 Dec 2013 21:08:35 +0000 (22:08 +0100)]
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>
Kristian Høgsberg [Mon, 16 Dec 2013 23:57:53 +0000 (15:57 -0800)]
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
Kristian Høgsberg [Mon, 16 Dec 2013 23:51:22 +0000 (15:51 -0800)]
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.
Kristian Høgsberg [Mon, 16 Dec 2013 23:37:16 +0000 (15:37 -0800)]
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.
Kristian Høgsberg [Mon, 16 Dec 2013 23:19:30 +0000 (15:19 -0800)]
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.
Kristian Høgsberg [Mon, 16 Dec 2013 23:07:59 +0000 (15:07 -0800)]
evdev: Use a has_keyboard flag instead of EVDEV_KEYBOARD bit
Kristian Høgsberg [Mon, 16 Dec 2013 22:43:29 +0000 (14:43 -0800)]
evdev: Replace EVDEV_BUTTON with local has_button flag
Kristian Høgsberg [Mon, 16 Dec 2013 21:55:48 +0000 (13:55 -0800)]
evdev: Replace EVDEV_MOTION_ABS with local has_abs flag
Kristian Høgsberg [Mon, 16 Dec 2013 21:42:40 +0000 (13:42 -0800)]
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.
Kristian Høgsberg [Mon, 16 Dec 2013 19:25:19 +0000 (11:25 -0800)]
evdev: Drop EVDEV_MOTION_REL flag
This is only used inside evdev_configure_device() and we now use a local
has_rel flag instead.
Kristian Høgsberg [Mon, 16 Dec 2013 19:01:56 +0000 (11:01 -0800)]
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.
Peter Hutterer [Thu, 19 Dec 2013 01:06:40 +0000 (11:06 +1000)]
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>
Peter Hutterer [Fri, 13 Dec 2013 07:50:49 +0000 (17:50 +1000)]
Documentation typo fix
Peter Hutterer [Fri, 13 Dec 2013 04:40:33 +0000 (14:40 +1000)]
Fix typo in comment
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Peter Hutterer [Fri, 13 Dec 2013 01:04:01 +0000 (11:04 +1000)]
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>
Peter Hutterer [Tue, 10 Dec 2013 21:27:02 +0000 (07:27 +1000)]
Add libudev and -lm to Requires.private
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Peter Hutterer [Tue, 10 Dec 2013 22:03:33 +0000 (08:03 +1000)]
Add -lm to library
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Peter Hutterer [Fri, 13 Dec 2013 01:05:07 +0000 (11:05 +1000)]
udev: print errno if we can't open a device
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Peter Hutterer [Fri, 6 Dec 2013 04:35:22 +0000 (14:35 +1000)]
util: add ARRAY_FOR_EACH helper
Requires c99, but that's the future.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Peter Hutterer [Thu, 19 Dec 2013 01:05:29 +0000 (11:05 +1000)]
doc: group li_fixed_t into the fixed point functions
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Peter Hutterer [Fri, 6 Dec 2013 04:47:09 +0000 (14:47 +1000)]
Move zalloc() up to libinput-util.h
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Jonas Ådahl [Mon, 16 Dec 2013 21:52:05 +0000 (22:52 +0100)]
Unref seats and devices in libinput_destroy()
Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
Jonas Ådahl [Sun, 15 Dec 2013 20:25:10 +0000 (21:25 +0100)]
udev-seat: Remove unused declaration
Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
Peter Hutterer [Tue, 10 Dec 2013 01:39:29 +0000 (11:39 +1000)]
udev: include libinput-private.h for struct libinput
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Peter Hutterer [Tue, 10 Dec 2013 01:33:29 +0000 (11:33 +1000)]
fix typo in documentation
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Peter Hutterer [Fri, 6 Dec 2013 04:52:38 +0000 (14:52 +1000)]
configure: require c99
This enables a few nice things that gcc would otherwise not allow.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Peter Hutterer [Mon, 9 Dec 2013 06:34:49 +0000 (16:34 +1000)]
udev: fail libinput_create_from_udev for NULL values
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Peter Hutterer [Mon, 9 Dec 2013 06:21:06 +0000 (16:21 +1000)]
configure: add libudev dependency
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Peter Hutterer [Mon, 9 Dec 2013 11:27:31 +0000 (21:27 +1000)]
Allow for NULL in libinput_destroy
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Peter Hutterer [Mon, 9 Dec 2013 11:26:54 +0000 (21:26 +1000)]
Allow for NULL in libevdev_event_destroy
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Jonas Ådahl [Sun, 15 Dec 2013 16:50:04 +0000 (17:50 +0100)]
Introduce libinput_device_get_sysname() API
Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
Jonas Ådahl [Sun, 15 Dec 2013 16:47:45 +0000 (17:47 +0100)]
Export li_fixed_to_(int|double) converters
Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
Jonas Ådahl [Sun, 15 Dec 2013 16:45:02 +0000 (17:45 +0100)]
Introduce libinput_device_has_capability() API
Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
Jonas Ådahl [Sun, 8 Dec 2013 15:35:04 +0000 (16:35 +0100)]
doc: Document basic event accessor functions
Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
Jonas Ådahl [Sun, 8 Dec 2013 15:30:13 +0000 (16:30 +0100)]
Put libinput_event_destroy() together with other event functions
Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
Jonas Ådahl [Sun, 8 Dec 2013 11:36:27 +0000 (12:36 +0100)]
Make even structs private
To ease the possibility to extend messages with more information, make
every event struct private, while providing functions used for accessing
the parameters previously found directly in the public structs.
Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
Jonas Ådahl [Sun, 8 Dec 2013 11:35:40 +0000 (12:35 +0100)]
Put libinput_interface struct below base doxygen group
Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
Jonas Ådahl [Sat, 7 Dec 2013 15:41:43 +0000 (16:41 +0100)]
Reference count event target struct when applicable
If the target of an event is a reference counted object, such as
libinput_seat and libinput_device, make events own its own reference to
the object, releasing it when destroyed.
In order to do this, a new API requirement and function are introduced;
libinput_event_destroy(). The user is required to use
libinput_event_destroy() instead of free() after having retrieved an
event using libinput_get_event().
This fixes a race that would be triggered if a device or seat would be
added and removed before the user calling libinput_get_event().
Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
Jonas Ådahl [Sat, 7 Dec 2013 15:01:17 +0000 (16:01 +0100)]
Remove unused disabled code
Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
Jonas Ådahl [Sat, 7 Dec 2013 13:06:55 +0000 (14:06 +0100)]
doc: Clarify that the caller need to free retrieved event
Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
Peter Hutterer [Thu, 5 Dec 2013 23:58:00 +0000 (09:58 +1000)]
doc: hook up doxygen to generate the public API documentation
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Peter Hutterer [Thu, 5 Dec 2013 08:35:32 +0000 (18:35 +1000)]
Rename libinput_create_udev to libinput_create_from_udev
A lot more obvious what it does, it creates a libinput context from a udev
handler (rather than creating the udev handler).
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Peter Hutterer [Thu, 5 Dec 2013 08:37:26 +0000 (18:37 +1000)]
udev-seat: fix leak when failing to add devices
udev-monitor and the udev_monitor_source would leak.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Peter Hutterer [Fri, 6 Dec 2013 01:51:09 +0000 (11:51 +1000)]
Drop include of evdev.h from evdev.h
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Peter Hutterer [Fri, 6 Dec 2013 01:24:09 +0000 (11:24 +1000)]
Drop unused libinput_fd_handle and libinput_fd_callback
Obsolete with
ce787552bce26ccac433c7fcf9868d2a5561a0cc
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Peter Hutterer [Thu, 5 Dec 2013 08:32:36 +0000 (18:32 +1000)]
evdev: fix memcopy for calibration
Function arguments with fixed length are still just pointers, so
sizeof(calibration) here is sizeof(float*), not sizeof(float) * 6.
evdev.c: In function 'evdev_device_calibrate':
evdev.c:693:54: warning: argument to 'sizeof' in 'memcpy' call is the same
pointer type 'float *' as the destination; expected 'float' or an explicit
length [-Wsizeof-pointer-memaccess]
memcpy(device->abs.calibration, calibration, sizeof calibration);
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Peter Hutterer [Thu, 5 Dec 2013 07:50:47 +0000 (17:50 +1000)]
Move libinput, libinput_seat and libinput_device to the top
Declare all three before they are used.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Peter Hutterer [Thu, 5 Dec 2013 07:50:09 +0000 (17:50 +1000)]
Declare libinput_seat explicitly
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Peter Hutterer [Thu, 5 Dec 2013 07:33:47 +0000 (17:33 +1000)]
libinput_dispatch: return -EAGAIN if no events are ready
Notify the caller that no events are currently ready to be processed.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Peter Hutterer [Thu, 5 Dec 2013 07:26:40 +0000 (17:26 +1000)]
libinput_dispatch: return negative error number on failure
Might as well tell the caller what went wrong without having to worry about
errno.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Peter Hutterer [Thu, 5 Dec 2013 07:04:42 +0000 (17:04 +1000)]
Make the slots unsigned, the kernel guarantees a base of 0
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Peter Hutterer [Thu, 5 Dec 2013 07:04:09 +0000 (17:04 +1000)]
Make buttons unsigned, there are no negative button numbers
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Jonas Ådahl [Sat, 23 Nov 2013 12:04:32 +0000 (13:04 +0100)]
Port udev-seat to be used in libinput
This patch ports udev-seat from weston to libinput, including adapting
libinput internals and API to provide seat and device discovery.
The public API is extended with device discovery, object reference, a
seat object. As libinput takes care of creating and destroying its
objects user data getter/setter is added in order to make it possible
for the client to directly associate an object application side with an
object library side.
Device discovery API is made up of the 'seat added', 'seat removed',
'device added' and 'device removed' events. The seat added/removed
events contains a pointer to a libinput_seat struct, while the device
added/removed events contains a pointer to a libinput_device event.
The objects are reference counted with libinput holding one reference by
default. The application can increase the reference count with
libinput_seat_ref() and libinput_device_ref() and decrease the reference
count with libinput_seat_unref() and libinput_device_unref().
The basic event struct is changed to have a 'target' union parameter
that can be either a libinput, libinput_seat or libinput_device struct
pointer.
There is one known problem with the current API that is the potentially
racy initialization.
The problem is when a device is both discovered and lost during initial
dispatchig, causing libinput to first queue a 'added' message, creating
the device with default reference count 1, then before going back to the
application queuing a 'removed' message, while at same time decreasing
reference count of the device to 0, causing it o be destroyed. The queue
will at this state contain two messages with pointers to free:ed memory.
Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
Jonas Ådahl [Sat, 23 Nov 2013 11:55:44 +0000 (12:55 +0100)]
util: Add logging utilities
Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
Jonas Ådahl [Tue, 19 Nov 2013 21:29:38 +0000 (22:29 +0100)]
Merge branch 'master' into udev
Jonas Ådahl [Sun, 17 Nov 2013 18:31:34 +0000 (19:31 +0100)]
Add interface to libinput object and move screen dimension callback to it
Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
Jonas Ådahl [Sun, 17 Nov 2013 15:59:09 +0000 (16:59 +0100)]
Use events instead of callbacks for capability registration
This commit also introduces a new requirement to
libinput_device_destroy() - libinput_device_terminate() must be called
before libinput_device_destroy() in order to allow the user to dispatch
the events related to a terminating input devices while the device is
still valid.
Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
Jonas Ådahl [Sun, 17 Nov 2013 10:19:50 +0000 (11:19 +0100)]
Introduce libinput object managing all input data
Instead of having the user manage added and removed fd's as well as the
fd used for creating evdev devices, introduce a libinput object that
itself has an epoll fd.
The user no longer manages multiple fd's per libinput instance, but
instead handles one fd, dispatches libinput when data is available, then
reading events using libinput_get_event().
libinput_event's are now per libinstance, but divided into categories.
So far the only category is device events. Device events are categorized
by the presence of a non-NULL device pointer in the event.
The current API usage should look like:
struct libinput libinput = ...;
struct libinput_event *event;
if (libinput_dispatch(libinput) != 0)
return -1;
while ((event = libinput_get_event(libinput))) {
if (event->device)
process_device_event(event);
free(event);
}
Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
Jonas Ådahl [Sun, 17 Nov 2013 01:38:58 +0000 (02:38 +0100)]
src/Makefile.a: Fix whitespace
Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
Jonas Ådahl [Sat, 16 Nov 2013 18:32:46 +0000 (19:32 +0100)]
Change API from using listeners to using an event queue
Instead of having the input drivers invoke user set callbacks during
libinput_device_dispatch() and add_fd callback, let the driver queue
events that the user then reads from using libinput_device_get_event().
A typical use case would be:
struct libinput_device *device = ...;
struct libinput_event *event;
libinput_device_dispatch(device);
while ((event = libinput_device_get_event(device))) {
process_event(device, event);
free(event);
}
Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
David Herrmann [Mon, 21 Oct 2013 22:28:08 +0000 (00:28 +0200)]
launcher: add weston_launcher_close() dummy
If you request a device via weston_launcher_open(), you should now release
it via weston_launcher_close() instead of close(). This is currently not
needed but will be required for logind devices.