platform/upstream/libinput.git
10 years agotouchpad: Support finger-pinnnig during physical button presses
Peter Hutterer [Mon, 17 Feb 2014 04:24:20 +0000 (14:24 +1000)]
touchpad: Support finger-pinnnig during physical button presses

On a clickpad, one finger has be on the trackpad to trigger a physical button
press. For drag and drop, we still want motion events though when a second
finger is down.

This patch adds finger-pinning. If the touchpad is pressed, the pressing
finger is "pinned" and ignored for further motion events. A second finger may
then be used to drag.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
10 years agotouchpad: mark the first finger as pointer-controlling finger
Peter Hutterer [Fri, 14 Feb 2014 03:59:41 +0000 (13:59 +1000)]
touchpad: mark the first finger as pointer-controlling finger

Unused at the moment, but will be used later to determine if a finger should
trigger motion events.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
10 years agotouchpad: add support for clickfingers
Peter Hutterer [Mon, 17 Feb 2014 01:14:29 +0000 (11:14 +1000)]
touchpad: add support for clickfingers

On touchpads without physical buttons, the number of fingers on the touchpad
at the time the physical click happens decides the button type. 1/2/3 fingers
is handled left/right/middle.

We also swallow the motion event on the actual click event, this reduces
erroneous motion events by a bit. More processing is needed here though.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
10 years agotouchpad: add fake-touch support for BTN_TOOL_DOUBLETAP and friends
Peter Hutterer [Fri, 14 Feb 2014 05:12:22 +0000 (15:12 +1000)]
touchpad: add fake-touch support for BTN_TOOL_DOUBLETAP and friends

This enables two-finger scrolling and two- and three-finger tapping on a
single-touch touchpad if BTN_TOOL_DOUBLETAP and BTN_TOOL_TRIPLETAP is set.

These require a bit of special processing:
BTN_TOUCH is set with the first finger down, but somewhat randomly unset and
re-set when switching between the various BTN_TOOL_*TAP values.
BTN_TOOL_<N>TAP is only set for N fingers down, thus a double->triple move
will see a release for DOUBLETAP and a press for TRIPLETAP. This may happen in
the same event, or across two consecutive events.

This patch adds a fake_touches mask to the touchpad struct. The mask is set
for each matching BTN_* event and used to count the number of expected
fake touchpoints. From that we begin/end the number of actual touchpoints
required. Fake touchpoints take their x/y coordinates from the first
touchpoint, which reads ABS_X/ABS_Y.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
10 years agotouchpad: support single-touch touchpads
Peter Hutterer [Fri, 14 Feb 2014 04:18:27 +0000 (14:18 +1000)]
touchpad: support single-touch touchpads

Touchpads without ABS_MT_SLOT create 5 slots by default (for up to QUINTTAP)
and ABS_X/Y is mapped to the 0-slot touchpoint. This commit adds handling for
a single finger, no BTN_TOOL_DOUBLETAP or similar is being processed yet.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
10 years agotouchpad: Only move the pointer when there's a single finger down
Peter Hutterer [Fri, 14 Feb 2014 05:48:49 +0000 (15:48 +1000)]
touchpad: Only move the pointer when there's a single finger down

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
10 years agotouchpad: require minimum scroll distance and lock scroll direction
Peter Hutterer [Fri, 14 Feb 2014 02:31:26 +0000 (12:31 +1000)]
touchpad: require minimum scroll distance and lock scroll direction

This is a fairly rough approach, but can be handled more fine-grained later.
Require a minimum of 1 unit to start scrolling and lock the scrolling in the
initial direction, so further scroll events are limited to that direction
only.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
10 years agotouchpad: Filter motion in a certain number of tap states
Peter Hutterer [Sun, 9 Feb 2014 21:44:59 +0000 (07:44 +1000)]
touchpad: Filter motion in a certain number of tap states

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
10 years agotouchpad: add support for multi-finger tapping
Peter Hutterer [Fri, 7 Feb 2014 05:18:17 +0000 (15:18 +1000)]
touchpad: add support for multi-finger tapping

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
10 years agotouchpad: Make touchpad_get_delta() available from other files
Peter Hutterer [Fri, 7 Feb 2014 04:39:21 +0000 (14:39 +1000)]
touchpad: Make touchpad_get_delta() available from other files

No functional changes.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
10 years agotouchpad: add a struct for handling physical button event state changes
Peter Hutterer [Fri, 7 Feb 2014 03:59:38 +0000 (13:59 +1000)]
touchpad: add a struct for handling physical button event state changes

On ClickPads (touchpads without phys. middle/right buttons) it is important to
know whether a physical click is queued up. The finger position or number of
fingers decide which button event to send.

This isn't currently used, we still just send the button number at the moment.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
10 years agotouchpad: mark which events are currently pending processing
Peter Hutterer [Fri, 7 Feb 2014 03:48:06 +0000 (13:48 +1000)]
touchpad: mark which events are currently pending processing

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
10 years agotouchpad: move structs into a header file
Peter Hutterer [Fri, 7 Feb 2014 03:39:27 +0000 (13:39 +1000)]
touchpad: move structs into a header file

The tapping state implementation will be in a separate file, so let's make
sure we can access the structs we need.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
10 years agotouchpad: add two-finger average scrolling
Peter Hutterer [Thu, 6 Feb 2014 09:17:22 +0000 (19:17 +1000)]
touchpad: add two-finger average scrolling

If two fingers are down and moving, take the average movement of both fingers
and use that for scrolling.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
10 years agotouchpad: hook up the pointer acceleration
Peter Hutterer [Thu, 6 Feb 2014 09:43:48 +0000 (19:43 +1000)]
touchpad: hook up the pointer acceleration

Same algorithm as in evdev-touchpad.c

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
10 years agotouchpad: add hysteresis smoothing for input coordinates
Peter Hutterer [Thu, 6 Feb 2014 08:57:10 +0000 (18:57 +1000)]
touchpad: add hysteresis smoothing for input coordinates

Same algorithm as in evdev-touchpad.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
10 years agotouchpad: add a touchpad driver based on per-finger tracking
Peter Hutterer [Thu, 6 Feb 2014 05:32:32 +0000 (15:32 +1000)]
touchpad: add a touchpad driver based on per-finger tracking

This patch is a mixture of an experimental project (libtouchpad) and
evdev-touchpad.c. It adds a new touchpad driver for multi-touch touchpads that
tracks each touchpoint separately. This makes it a lot easier to handle
multi-finger tapping, software button areas, etc.

libtouchpad used a slightly different coding style, this is the attempt to get
closer to the one used in libinput.

Currently sends motion events for single-finger motion, button events only for
physical buttons.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
10 years agoAdd the shell for a multitouch-compatible touchpad implementation
Peter Hutterer [Thu, 6 Feb 2014 05:05:36 +0000 (15:05 +1000)]
Add the shell for a multitouch-compatible touchpad implementation

Doesn't do anything but initialize and destroy. This is not a permanent
separate implementation, it's just easier to start this way and then switch
over than to add to the current one.

Temporary measure: LIBINPUT_NEW_TOUCHPAD_DRIVER environment variable can be
used to enable the new driver

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
10 years agotools: drop CLOCK_MONOTONIC call, no longer necessary
Peter Hutterer [Thu, 6 Mar 2014 05:27:47 +0000 (15:27 +1000)]
tools: drop CLOCK_MONOTONIC call, no longer necessary

Obsolete as of 84c4f40f25e91ff6ecd35b47398d13ac3996f101.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
10 years agolibinput: Fix the close_restricted interface callback
Jasper St. Pierre [Sat, 1 Mar 2014 19:19:03 +0000 (14:19 -0500)]
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>
10 years agoconfigure.ac: Bump to 0.1.0 0.1.0
Jonas Ådahl [Wed, 26 Feb 2014 18:54:51 +0000 (19:54 +0100)]
configure.ac: Bump to 0.1.0

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
10 years agoconfigure.ac: Update URLs
Jonas Ådahl [Wed, 26 Feb 2014 18:54:27 +0000 (19:54 +0100)]
configure.ac: Update URLs

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
10 years agoUpdate README
Jonas Ådahl [Wed, 26 Feb 2014 18:36:38 +0000 (19:36 +0100)]
Update README

Added links and updated the description.

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
10 years agoMakefile.am: Add private header to sources list
Jonas Ådahl [Fri, 21 Feb 2014 21:18:37 +0000 (22:18 +0100)]
Makefile.am: Add private header to sources list

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
10 years agopath: Silence -Wmaybe-uninitialized compiler warning
Jonas Ådahl [Fri, 21 Feb 2014 21:17:17 +0000 (22:17 +0100)]
path: Silence -Wmaybe-uninitialized compiler warning

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
10 years agoSplit up the touch event into the different touch types
Jonas Ådahl [Wed, 19 Feb 2014 20:39:26 +0000 (21:39 +0100)]
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>
10 years agoAdd seat wide slot to touch events
Jonas Ådahl [Thu, 30 Jan 2014 21:44:49 +0000 (22:44 +0100)]
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>
10 years agoMerge branch 'libevdev'
Peter Hutterer [Tue, 25 Feb 2014 04:31:35 +0000 (14:31 +1000)]
Merge branch 'libevdev'

10 years agoevdev: set CLOCK_MONOTONIC as the time source
Peter Hutterer [Tue, 18 Feb 2014 22:45:57 +0000 (08:45 +1000)]
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>
10 years agoHook up event processing to libevdev
Peter Hutterer [Fri, 6 Dec 2013 03:09:18 +0000 (13:09 +1000)]
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>
10 years agoHook up libevdev as backend
Peter Hutterer [Fri, 6 Dec 2013 02:01:47 +0000 (12:01 +1000)]
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>
10 years agoevdev: reset the device fd after closing it
Peter Hutterer [Fri, 21 Feb 2014 06:13:02 +0000 (16:13 +1000)]
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>
10 years agoevdev: fix device_transform_ functions
Benjamin Tissoires [Mon, 17 Feb 2014 18:42:52 +0000 (13:42 -0500)]
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>
10 years agotest: Add scale li_fixed overflow test
Jonas Ådahl [Tue, 18 Feb 2014 19:13:58 +0000 (20:13 +0100)]
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>
10 years agotest: Fix touch_down in wacom touch test device
Jonas Ådahl [Tue, 18 Feb 2014 19:13:57 +0000 (20:13 +0100)]
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>
10 years agoevent-debug: Display touch event seats as signed integer
Jonas Ådahl [Wed, 19 Feb 2014 20:43:35 +0000 (21:43 +0100)]
event-debug: Display touch event seats as signed integer

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
10 years agoAdd a customizable log handler
Peter Hutterer [Wed, 12 Feb 2014 04:20:18 +0000 (14:20 +1000)]
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>
10 years agoevdev: Use -1 to represent touch events slots from single touch devices
Jonas Ådahl [Wed, 12 Feb 2014 19:56:06 +0000 (20:56 +0100)]
evdev: Use -1 to represent touch events slots from single touch devices

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
10 years agoChange touch event slots from being unsigned to signed
Jonas Ådahl [Wed, 12 Feb 2014 19:52:14 +0000 (20:52 +0100)]
Change touch event slots from being unsigned to signed

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
10 years agodoc: Rephrase touch event slot description to be more event centric
Jonas Ådahl [Tue, 11 Feb 2014 22:30:28 +0000 (23:30 +0100)]
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>
10 years agoFix coding style issues
Jonas Ådahl [Tue, 11 Feb 2014 22:29:34 +0000 (23:29 +0100)]
Fix coding style issues

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
10 years agoevdev-touchpad: don't post motion events for 0/0 deltas
Peter Hutterer [Fri, 7 Feb 2014 01:09:08 +0000 (11:09 +1000)]
evdev-touchpad: don't post motion events for 0/0 deltas

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
10 years agoevdev-touchpad: replace some numbers with a #define
Peter Hutterer [Fri, 7 Feb 2014 00:32:03 +0000 (10:32 +1000)]
evdev-touchpad: replace some numbers with a #define

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
10 years agoutil: add min/max macros
Peter Hutterer [Thu, 6 Feb 2014 05:26:02 +0000 (15:26 +1000)]
util: add min/max macros

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
10 years agoMake it possible to have persistent libinput_seat instances
Jonas Ådahl [Mon, 10 Feb 2014 01:40:55 +0000 (11:40 +1000)]
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>
10 years agoevdev: restore EVDEV_UNHANDLED_DEVICE error code
Peter Hutterer [Mon, 10 Feb 2014 05:40:49 +0000 (15:40 +1000)]
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>
10 years agotest: Add tests for adding/removing devices
Peter Hutterer [Thu, 6 Feb 2014 00:05:29 +0000 (10:05 +1000)]
test: Add tests for adding/removing devices

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
10 years agoudev: rename create_from_udev to udev_create_for_seat
Peter Hutterer [Wed, 29 Jan 2014 05:35:20 +0000 (15:35 +1000)]
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>
10 years agopath: add libinput_path_create_context instead of libinput_create_from_path
Peter Hutterer [Wed, 29 Jan 2014 05:38:48 +0000 (15:38 +1000)]
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>
10 years agopath: add libinput_path_add_device() and libinput_path_remove_device()
Peter Hutterer [Wed, 29 Jan 2014 06:37:45 +0000 (16:37 +1000)]
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>
10 years agopath: modify backend to allow for more than one device
Peter Hutterer [Wed, 29 Jan 2014 05:57:53 +0000 (15:57 +1000)]
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>
10 years agoRevert "evdev: restore EVDEV_UNHANDLED_DEVICE error code"
Peter Hutterer [Mon, 10 Feb 2014 01:22:39 +0000 (11:22 +1000)]
Revert "evdev: restore EVDEV_UNHANDLED_DEVICE error code"

This reverts commit e8c20c7241d29aa3b725e6a03d52656cafacf0e0.

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>
10 years agoevdev: restore EVDEV_UNHANDLED_DEVICE error code
Peter Hutterer [Wed, 5 Feb 2014 23:33:26 +0000 (09:33 +1000)]
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>
10 years agoevdev: if mtdev failed to open, fail to init the device
Peter Hutterer [Wed, 5 Feb 2014 23:26:00 +0000 (09:26 +1000)]
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>
10 years agopath: add error handling for failing to create a seat
Peter Hutterer [Wed, 29 Jan 2014 06:08:54 +0000 (16:08 +1000)]
path: add error handling for failing to create a seat

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
10 years agoMove opening and closing the device fd into evdev.c
Peter Hutterer [Thu, 30 Jan 2014 04:54:31 +0000 (14:54 +1000)]
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>
10 years agotest: plug a memory leak, all events need to be destroyed
Peter Hutterer [Mon, 3 Feb 2014 04:23:38 +0000 (14:23 +1000)]
test: plug a memory leak, all events need to be destroyed

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
10 years agoevdev: Fix absolute coordinate transform formula
Jonas Ådahl [Mon, 3 Feb 2014 22:35:24 +0000 (23:35 +0100)]
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>
10 years agoRemove mention of delta coordinates having device specific direction
Jonas Ådahl [Tue, 28 Jan 2014 21:50:26 +0000 (22:50 +0100)]
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>
10 years agoReplace output screen size callback with transform helpers
Jonas Ådahl [Sat, 25 Jan 2014 10:53:53 +0000 (11:53 +0100)]
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>
10 years agopath: fix inconsistent use of devnode vs input->path
Peter Hutterer [Thu, 16 Jan 2014 01:25:26 +0000 (11:25 +1000)]
path: fix inconsistent use of devnode vs input->path

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
10 years agotest: don't leak open/closed counts into the next test
Peter Hutterer [Thu, 16 Jan 2014 00:56:01 +0000 (10:56 +1000)]
test: don't leak open/closed counts into the next test

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
10 years agotools: add a tool for basic event debugging
Peter Hutterer [Tue, 28 Jan 2014 01:25:40 +0000 (11:25 +1000)]
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>
10 years agotest: Make sure the sysname of a device is correct
Peter Hutterer [Tue, 28 Jan 2014 05:54:34 +0000 (15:54 +1000)]
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>
10 years agopath: print error when failing to open a device
Peter Hutterer [Wed, 29 Jan 2014 01:37:47 +0000 (11:37 +1000)]
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>
10 years agopath: store the sysname, not the syspath, in the device
Peter Hutterer [Tue, 28 Jan 2014 05:46:37 +0000 (15:46 +1000)]
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>
10 years agoAdd COPYING file
Peter Hutterer [Tue, 28 Jan 2014 21:28:03 +0000 (07:28 +1000)]
Add COPYING file

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Jonas Ådahl <jadahl@gmail.com>
10 years agoevdev: Don't queue touch events when no touch capability is reported
Jonas Ådahl [Mon, 27 Jan 2014 22:33:46 +0000 (23:33 +0100)]
evdev: Don't queue touch events when no touch capability is reported

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
10 years agoevdev: Don't report touch devices with buttons as actual touch devices
Jonas Ådahl [Mon, 27 Jan 2014 22:27:16 +0000 (23:27 +0100)]
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>
10 years agoDocument the LIBINPUT_EVENT_NONE event type
Jonas Ådahl [Sat, 25 Jan 2014 10:52:33 +0000 (11:52 +0100)]
Document the LIBINPUT_EVENT_NONE event type

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
10 years agoAllow initial device configuration after receiving DEVICE_ADDED event
Jonas Ådahl [Sat, 25 Jan 2014 10:46:55 +0000 (11:46 +0100)]
Allow initial device configuration after receiving DEVICE_ADDED event

By specifying that a device will not be read until the next time the
user calls libinput_dispatch(), if data is available, it will allow for
setting up initial configuration, such as tap button, output screen
size, acceleration parameters, etc.

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
10 years agoFix some coding style inconsistencies
Jonas Ådahl [Sat, 25 Jan 2014 10:33:09 +0000 (11:33 +0100)]
Fix some coding style inconsistencies

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
10 years agoevdev: Make evdev manage its seat reference
Jonas Ådahl [Wed, 22 Jan 2014 22:48:39 +0000 (23:48 +0100)]
evdev: Make evdev manage its seat reference

Before the seat reference would be decreased when a device was removed.
This could cause libinput_device_get_seat() to potentially return an
invalid pointer when a device was removed, its seat unreferenced and
destryoed.

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
10 years agoRemove redundant device pointer from device notify event
Jonas Ådahl [Wed, 22 Jan 2014 22:59:05 +0000 (23:59 +0100)]
Remove redundant device pointer from device notify event

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
10 years agoSimplify device reference counting of events
Jonas Ådahl [Wed, 22 Jan 2014 22:45:44 +0000 (23:45 +0100)]
Simplify device reference counting of events

This also makes DEVICE_ADDED/REMOVED events own a reference, which is
necessary to not have libinput_event_get_device() potentially returning
an invalid pointer.

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
10 years agoevdev: Make error handling more consistent
Jonas Ådahl [Wed, 22 Jan 2014 22:43:45 +0000 (23:43 +0100)]
evdev: Make error handling more consistent

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
10 years agotest: add a simple touch test
Peter Hutterer [Wed, 22 Jan 2014 00:34:11 +0000 (10:34 +1000)]
test: add a simple touch test

Currently testing for touch frame events only

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
10 years agotest: add basic pointer motion and button test
Peter Hutterer [Tue, 21 Jan 2014 04:17:01 +0000 (14:17 +1000)]
test: add basic pointer motion and button test

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
10 years agotest: add a wacom touch devices (absolute touchscreen)
Peter Hutterer [Tue, 21 Jan 2014 23:58:43 +0000 (09:58 +1000)]
test: add a wacom touch devices (absolute touchscreen)

This means we do have to provide the get_current_screen_dimensions() call in
litest now, just hardcode it to 1024x768.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
10 years agotest: Add a basic mouse test device
Peter Hutterer [Tue, 21 Jan 2014 05:18:09 +0000 (15:18 +1000)]
test: Add a basic mouse test device

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
10 years agotest: Add a common helper function to drain all current events
Peter Hutterer [Wed, 22 Jan 2014 01:20:50 +0000 (11:20 +1000)]
test: Add a common helper function to drain all current events

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
10 years agoevdev: don't ignore scroll events with a value greater than 1/-1
Peter Hutterer [Tue, 21 Jan 2014 05:48:06 +0000 (15:48 +1000)]
evdev: don't ignore scroll events with a value greater than 1/-1

Higher values than 1 or -1 are legitimate on some devices, though not all mice
send wheel events other than 1/-1.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
10 years agopath: get ID_SEAT and WL_SEAT from udev for the device node
Peter Hutterer [Tue, 21 Jan 2014 02:03:47 +0000 (12:03 +1000)]
path: get ID_SEAT and WL_SEAT from udev for the device node

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
10 years agoDrop event classes
Peter Hutterer [Tue, 21 Jan 2014 03:56:12 +0000 (13:56 +1000)]
Drop event classes

There are now only two event classes and only two users of the event class.
It's easier to use the event type directly to see which event has references
and which one doesn't.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
10 years agoPromote touch frames to top-level events
Peter Hutterer [Fri, 20 Dec 2013 00:15:00 +0000 (10:15 +1000)]
Promote touch frames to top-level events

These events are not a state of a single touchpoints but rather a notification
that all touchpoints finished processing. As such, they should have their own
type.

And make sure we actually send them when needed.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
10 years agoProvide accessors to retrieve the right event type
Peter Hutterer [Thu, 19 Dec 2013 23:22:32 +0000 (09:22 +1000)]
Provide accessors to retrieve the right event type

Slightly enhances the type-safety. A caller may now do something along the
lines of

struct libinput_event_pointer *ptrev;
ptrev = libinput_event_get_pointer_event(event);

if (!ptrev)
   oops, that wasn't a pointer event

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
10 years agoAdd documentation for the various events
Peter Hutterer [Thu, 19 Dec 2013 07:50:49 +0000 (17:50 +1000)]
Add documentation for the various events

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
10 years agozalloc all events to make sure we have defined defaults
Peter Hutterer [Wed, 22 Jan 2014 01:01:24 +0000 (11:01 +1000)]
zalloc all events to make sure we have defined defaults

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
10 years agoReduce touch events to a single event type
Peter Hutterer [Thu, 19 Dec 2013 07:16:19 +0000 (17:16 +1000)]
Reduce touch events to a single event type

No real effect since we're hiding the actual touch events through the touch
type.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
10 years agoReduce pointer events to one single type
Peter Hutterer [Thu, 19 Dec 2013 03:15:28 +0000 (13:15 +1000)]
Reduce pointer events to one single type

The event type itself says enough about the actual event type, we don't need
to have separate structs for every type.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
10 years agoReduce keyboard events to one single type
Peter Hutterer [Thu, 19 Dec 2013 06:40:48 +0000 (16:40 +1000)]
Reduce keyboard events to one single type

Provide one top-level event for keyboard events: libinput_event_keyboard. The
event type specifies which subtype the event is anyway.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
10 years agoImprove namespacing of event types
Peter Hutterer [Thu, 19 Dec 2013 02:04:24 +0000 (12:04 +1000)]
Improve namespacing of event types

Now that the target of an event isn't exposed to the caller anymore, the
namespacing can be associated with a more intuitive one.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
10 years agoMerge the device added/removed events into a single device notify event
Peter Hutterer [Wed, 15 Jan 2014 07:10:30 +0000 (17:10 +1000)]
Merge the device added/removed events into a single device notify event

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
10 years agoDrop libinput_event_get_target()
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>
10 years agoAdd a generic libinput_event_get_device() function
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>
10 years agoSplit seats into having a physical and a logical name
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>
10 years agoDrop seat events
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>
10 years agoAdd libinput_event_get_context()
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>
10 years agoudev: Drop unused seat_name in struct udev_seat
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>
10 years agotest: Remove short option and fail on invalid options
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>