Commit graph

399 commits

Author SHA1 Message Date
Jasper St. Pierre
385bfdb762 libinput: Fix the close_restricted interface callback
libinput is supposed to take a close callback in its interface
to allow you to call out to a privileged API to close FDs. But
the FD that libinput passes you is bogus, because
libinput_remove_source closes the FD on which it's passed. This
is really bad, as the libinput_source really doesn't own the FD
which it's passed, so it shouldn't be trying to close() it.

Only one out of the four users of libinput_remove_source actually
wants their FD closed, so move the close() call there.

Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-03-04 15:21:38 +10:00
Jonas Ådahl
6ae636fe18 configure.ac: Bump to 0.1.0
Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
2014-02-26 19:54:51 +01:00
Jonas Ådahl
edd792ab6e configure.ac: Update URLs
Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
2014-02-26 19:54:27 +01:00
Jonas Ådahl
2b08f19b7e Update README
Added links and updated the description.

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
2014-02-26 19:50:37 +01:00
Jonas Ådahl
9e48569ae8 Makefile.am: Add private header to sources list
Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
2014-02-26 19:32:33 +01:00
Jonas Ådahl
b98e9b1ccc path: Silence -Wmaybe-uninitialized compiler warning
Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
2014-02-26 19:32:33 +01:00
Jonas Ådahl
6f0ca1a386 Split up the touch event into the different touch types
Instead of having one touch events representing different types of touch
events by providing a touch type, have one separate event type per touch
type. This means the LIBINPUT_EVENT_TYPE_TOUCH is replaced with
LIBINPUT_EVENT_TYPE_TOUCH_DOWN, LIBINPUT_EVENT_TYPE_TOUCH_MOTION,
LIBINPUT_EVENT_TYPE_TOUCH_UP and LIBINPUT_EVENT_TYPE_TOUCH_CANCEL.

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
2014-02-26 19:32:33 +01:00
Jonas Ådahl
e80cff7b0e Add seat wide slot to touch events
Since a Wayland compositor have to represent all touch devices of a seat
as one virtual device, lets make that easier by also providing seat wide
slots with touch events.

Seat wide slots may be accessed using
libinput_event_touch_get_seat_slot().

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
2014-02-26 19:32:33 +01:00
Peter Hutterer
bc06973c2e Merge branch 'libevdev' 2014-02-25 14:31:35 +10:00
Peter Hutterer
84c4f40f25 evdev: set CLOCK_MONOTONIC as the time source
Avoids erroneous timestamps when the system time is reset. This used to a be a
problem with the X.Org synaptics driver where taps, scrolling and a couple of
other things would potentially lock up.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-02-25 14:31:22 +10:00
Peter Hutterer
0fea6226f1 Hook up event processing to libevdev
This gives us the ability to handle SYN_DROPPED transparently to the caller.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Jonas Ådahl <jadahl@gmail.com>
2014-02-25 14:31:17 +10:00
Peter Hutterer
f925cee8df Hook up libevdev as backend
libevdev wraps the various peculiarities of the evdev kernel API into a
type-safe API. It also buffers the device so checking for specific features at
a later time is easier than re-issuing the ioctls. Plus, it gives us almost
free support for SYN_DROPPED events (in the following patch).

This patch switches all the bit checks over to libevdev and leaves the event
processing as-is. Makes it easier to review.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Jonas Ådahl <jadahl@gmail.com>
2014-02-24 09:29:09 +10:00
Peter Hutterer
d31b1b7b70 evdev: reset the device fd after closing it
A caller may have a reference to the device after closing it, make sure that
ref doesn't have a dangling fd so future attempts of reading from/writing to
the device fail.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-02-21 16:13:02 +10:00
Benjamin Tissoires
128f98c43b evdev: fix device_transform_ functions
X and Y are li_fixed_t, which is 24.8 fixed point real number.
li_fixed_t max is thus ~8388607.

On a touchscreen with a range of 32767 values (like a 3M sensor), and
mapped on monitor with a resolution of 1920x1080, we currently have:
(x - li_fixed_from_int(device->abs.min_x)) * width == 62912640

which is 7 times bigger than li_fixed_t max.

Force a cast to uint64_t to keep the precision of the sensor.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-02-20 11:30:08 +10:00
Jonas Ådahl
ad24bc07f8 test: Add scale li_fixed overflow test
Add a test case and test device that checks if the scale transform can
handle high resolution devices and output monitor resolutions.

The test case is created in a way that it will fail if the coordinate
transform expression will overflow if only 32 bit integer data
containers are used.

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-02-20 11:30:08 +10:00
Jonas Ådahl
295578bc2d test: Fix touch_down in wacom touch test device
Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-02-20 11:30:08 +10:00
Jonas Ådahl
63f192c466 event-debug: Display touch event seats as signed integer
Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
2014-02-19 22:16:39 +01:00
Peter Hutterer
3a07b03df5 Add a customizable log handler
The previous log handler wasn't actually hooked up to anything. Add a public
API for the log handler with priority filtering, defaulting to priority
'error' and stderr as output stream.

And to keep the diff down and convenience up, provide a few simple wrappers
for logging. The generic is log_msg(), but let's use log_info, log_error, etc.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Jonas Ådahl <jadahl@gmail.com>
2014-02-19 08:35:25 +10:00
Jonas Ådahl
803f254343 evdev: Use -1 to represent touch events slots from single touch devices
Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
2014-02-17 20:12:19 +01:00
Jonas Ådahl
e108e8ddba Change touch event slots from being unsigned to signed
Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
2014-02-17 20:12:19 +01:00
Jonas Ådahl
1bed4eadd2 doc: Rephrase touch event slot description to be more event centric
It is unclear what "current" means as events are asynchronous, and
since a slot is associated with a touch event rather than a device,
change the description to reflect this.

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
2014-02-17 20:12:19 +01:00
Jonas Ådahl
8dd059061b Fix coding style issues
Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
2014-02-17 20:12:19 +01:00
Peter Hutterer
993a3b8ebd evdev-touchpad: don't post motion events for 0/0 deltas
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-02-17 14:35:10 +10:00
Peter Hutterer
c81e1235c6 evdev-touchpad: replace some numbers with a #define
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-02-17 14:35:08 +10:00
Peter Hutterer
01ee0f7ef9 util: add min/max macros
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-02-17 14:35:06 +10:00
Jonas Ådahl
b34139c9e7 Make it possible to have persistent libinput_seat instances
With this patch, a user can keep a reference to a libinput_seat
instance, which will cause the seat to never be unlinked from the
libinput context nor destroyed.

Previously, a when the last device of a seat was removed, the seat was
unlinked and if a new device was discovered with a previously empty seat
a new seat instance would always be created, meaning two potential seat
instances with identical physical and logical seat name pairs.

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-02-10 22:28:46 +01:00
Peter Hutterer
26a1fff787 evdev: restore EVDEV_UNHANDLED_DEVICE error code
If we don't have capabilities we can deal with, return a different
error so the backends can handle it separately (they already do).

Signe-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-02-10 15:40:49 +10:00
Peter Hutterer
b069228937 test: Add tests for adding/removing devices
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-02-10 11:23:36 +10:00
Peter Hutterer
75427b0788 udev: rename create_from_udev to udev_create_for_seat
Maintain proper namespacing rename the backend-specific calls to
	libinput_<backend>_<foo>

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-02-10 11:23:36 +10:00
Peter Hutterer
606249f91c path: add libinput_path_create_context instead of libinput_create_from_path
Creates an empty context that is not hooked up to a device. Callers can then
add and remove devices to this context using libinput_path_add_device() and
libinput_path_remove_device().

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-02-10 11:23:36 +10:00
Peter Hutterer
69dcea11b9 path: add libinput_path_add_device() and libinput_path_remove_device()
This allows multiple devices to share a single libinput context. The new
function returns the newly added device immediately. Unlike the udev seat
where devices may or may not be added - over the lifetime of the seat - a
path-based backend knows immediately if device exists or doesn't exist.

Returning the device is required by callers that have the event processing
separate from adding devices - by the time we have the DEVICE_ADDED event in
the queue we may have other events to process first. And the DEVICE_ADDED
event won't easily link to the path we gave it anyway, so it's hard to figure
out which DEVICE_ADDED event corresponds to the new device.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-02-10 11:23:36 +10:00
Peter Hutterer
6764e7e19a path: modify backend to allow for more than one device
The previous path backend created a libinput context attached to a single
device. This is insufficient when we need to use cross-device functionality.
One example of this cross-device functionality include disabling a touchpad
while the trackstick is in use (Lenovo T440 and related models).

This patch merely adds the infrastructure to support multiple devices for a
path backend. Follow-up patches add the function calls to add and remove
devices. This is needed by Xorg input drivers that still make use of the
server's device hotplug mechanisms but want to otherwise use libinput.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-02-10 11:23:35 +10:00
Peter Hutterer
f6e8160ce1 Revert "evdev: restore EVDEV_UNHANDLED_DEVICE error code"
This reverts commit e8c20c7241.

Ooops, bad rebase. This accesses the device after it was already destroyed
which is not the intent of the patch.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-02-10 11:23:35 +10:00
Peter Hutterer
e8c20c7241 evdev: restore EVDEV_UNHANDLED_DEVICE error code
If we don't have capabilities we can deal with, return a different error so
the backends can handle it separately (they already do).

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-02-06 09:46:34 +10:00
Peter Hutterer
e13f736cff evdev: if mtdev failed to open, fail to init the device
We can't handle protocol A devices properly without mtdev, so skip the device
altogether.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-02-06 09:46:34 +10:00
Peter Hutterer
9d3fbabb5e path: add error handling for failing to create a seat
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-02-06 09:46:34 +10:00
Peter Hutterer
1901449871 Move opening and closing the device fd into evdev.c
evdev_device_remove() already calls close(device->fd). Move the
close_restricted call there to avoid one privileged call in the backend and
one in the device. And move the open_restricted() into the evdev device too to
reduce the duplicated code in the two backends.

Update to one of the tests: since we'd now fail getting the device node from
the invalid /tmp path, the open_func_count is 0.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-02-06 09:16:43 +10:00
Peter Hutterer
0d879fd239 test: plug a memory leak, all events need to be destroyed
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-02-06 08:09:34 +10:00
Jonas Ådahl
512e964661 evdev: Fix absolute coordinate transform formula
Since the device min/max x/y coordinates are inclusive, to get the
width/height one need to add one to (min x/y - max x/y).

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
2014-02-03 23:39:58 +01:00
Jonas Ådahl
bb52822ece Remove mention of delta coordinates having device specific direction
The event represent pointer motions on a screen, so this information is
unnecessary. It could also be confused for meaning the provided
coordinate's direction being device specific.

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
2014-02-03 23:39:58 +01:00
Jonas Ådahl
1f1304041c Replace output screen size callback with transform helpers
Instead of automatically transforming absolute coordinates of touch and
pointer events to screen coordinates, the user now uses the corresponding
transform helper function. This means the coordinates returned by
libinput_event_pointer_get_absolute_x(),
libinput_event_pointer_get_absolute_y(), libinput_touch_get_x() and
libinput_touch_get_y() has changed from being in output screen coordinate
space to being in device specific coordinate space.

For example, where one before would call libinput_event_touch_get_x(event),
one now calls libinput_event_touch_get_x_transformed(event, output_width).

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
2014-02-03 23:39:58 +01:00
Peter Hutterer
b5f06f8329 path: fix inconsistent use of devnode vs input->path
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-01-31 15:00:17 +10:00
Peter Hutterer
db2274eaad test: don't leak open/closed counts into the next test
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-01-31 15:00:17 +10:00
Peter Hutterer
3444b29ceb tools: add a tool for basic event debugging
Simply prints the various events to make it easier to check what's coming out
of libinput. Works for --udev (the default) or for --device /dev/input/event0.
Example output:

event7 	DEVICE_ADDED	seat0	default
event8 	DEVICE_ADDED	seat0	default
event4 	POINTER_BUTTON	 +1.35s	272 pressed
event5 	POINTER_MOTION	 +2.31s	 -3.00/  2.00

Time is displayed relative to the starting time.

Note: statically linked for easier debugging, but we don't distribute it
(yet) anyway.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Jonas Ådahl <jadahl@gmail.com>
2014-01-31 14:57:19 +10:00
Peter Hutterer
20416ae4b7 test: Make sure the sysname of a device is correct
Currently this means start with "event" and don't contain /.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Jonas Ådahl <jadahl@gmail.com>
2014-01-31 14:57:18 +10:00
Peter Hutterer
184c95c147 path: print error when failing to open a device
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Jonas Ådahl <jadahl@gmail.com>
2014-01-31 14:57:18 +10:00
Peter Hutterer
5d7e0fbfec path: store the sysname, not the syspath, in the device
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Jonas Ådahl <jadahl@gmail.com>
2014-01-31 14:57:18 +10:00
Peter Hutterer
05fc927168 Add COPYING file
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Jonas Ådahl <jadahl@gmail.com>
2014-01-31 14:57:18 +10:00
Jonas Ådahl
b57656aa9a evdev: Don't queue touch events when no touch capability is reported
Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
2014-01-27 23:35:14 +01:00
Jonas Ådahl
3290b78bd6 evdev: Don't report touch devices with buttons as actual touch devices
This was a detail of the original version of the commit "evdev: Remove
EVDEV_TOUCH and with it evdev_device->caps" that got lost during porting.

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
2014-01-27 23:35:11 +01:00