Commit graph

957 commits

Author SHA1 Message Date
Peter Hutterer
72cc601007 test: add protocol A touch screen tests
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2015-03-02 12:45:47 +10:00
Peter Hutterer
bb78357f04 evdev: force-assign 10 slots to mtdev devices
If the device doesn't have any slots, mtdev->caps.slot.maximum is 0. Since we
only use mtdev if we don't have slots, this caused protocol A devices to
always fail.

https://bugs.freedesktop.org/show_bug.cgi?id=89211

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2015-03-02 12:45:47 +10:00
Peter Hutterer
ae75a44e30 Clarify a comment, it's wheel clicks, not mouse clicks
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-02-24 15:49:04 +10:00
Hans de Goede
88d87e763c touchpad: Refactor tp_get_*_touches_delta
The two tp_get_*_touches_delta functions are almost identical, refactor
them into one function.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-02-23 10:06:37 +01:00
Hans de Goede
2e8403e762 touchpad: Do not use fake touches when getting the average touches delta
Only look at real touches when getting the average touches delta, otherwise
the touch used to populate the fake touches gets an unfair weighing factor.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-02-23 10:01:02 +01:00
Hans de Goede
ff02bd1b5b touchpad: Move gesture handling code to evdev-mt-touchpad-gestures.c
Just moving some code around, no functional changes.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-02-23 10:01:02 +01:00
Hans de Goede
18887f90ee touchpad: Gesture support preparation
Handle everything which is not handled by the tap, (soft)button or edge-scroll
code/statemachines in a unified way. Everything is treated as a X-finger
gesture now, and the action to take on finger movement is decided by
the gesture.finger_count setting. Pointer control now simply is seen as a
1 finger gesture, and 2fg scrolling as a 2fg gesture.

This removed the need for special-casing things like switching back to
pointer mode when lifting a finger in 2fg scrolling mode, and also lays the
groundwork for adding 3+ fg gesture support.

Note that 1 test-case needs to be updated to wait for the finger mode
switching when switching mode while a gesture has already been started.
This is actually an improvement as this stops sending spurious pointer
motion events at the end of 2fg scrolling when not lifting both fingers at
exactly the same time.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-02-23 10:01:02 +01:00
Hans de Goede
6d03202730 touchpad: Add tp_get_average_touches_delta helper function
Add a tp_get_average_touches_delta helper function, and rename
tp_get_active_touches_delta to tp_get_combined_touches_delta to better
differentiate the two.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-02-23 09:50:09 +01:00
Hans de Goede
0cd92aeacd touchpad: Also stop edge scrolling when the trackpoint becomes active
Not only stop 2fg scrolling, but also edge scrolling when the trackpoint
becomes active.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-02-23 09:50:04 +01:00
Hans de Goede
f7bef28a54 touchpad: Change how we deal with scroll methods
With the upcoming gesture support 2fg scrolling will be handled as part of
the main gesture state machine, whereas edge scrolling has its own state
machine, our current way of dispatching scroll "actions" does not play well
with this.

Change the scroll method handling to treat edge and 2fg scrolling as 2
separate state machines. The double scroll calls this introduces will mostly
be removed when the gesture handling code lands.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-02-23 09:49:57 +01:00
Peter Hutterer
2840733978 cosmetic: drop more double empty lines
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-02-23 13:49:10 +10:00
Peter Hutterer
6c5be5c77f configure.ac: libinput 0.11.0
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-02-23 10:28:23 +10:00
Peter Hutterer
79e64ce0b5 doc: document udev device tagging
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-02-23 10:28:23 +10:00
Peter Hutterer
02d8bc766b doc: add missing space
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-02-23 10:28:23 +10:00
Peter Hutterer
ca9da65cff cosmetic: fix a whitespace issue
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-02-23 09:01:25 +10:00
Peter Hutterer
ed0f0bf494 test: fix Coverity complaints
seat_button_count
seat_key_count ... uninitialized variable

t = zalloc
s = zalloc ... dereferencing potential NULL-pointer

d->ntouches_down... side-effect in assertion

Coverity run against the 0.10.0 tag, see
https://scan.coverity.com/projects/4298

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Christian Hartmann <cornogle@googlemail.com>
2015-02-20 10:03:09 +10:00
Peter Hutterer
002ef1635d cosmetic: drop double empty lines
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-02-20 09:57:39 +10:00
Peter Hutterer
413c29fef7 udev: fix a race condition if a device disappears before we get a handle
If the device disappears too quickly, the device is NULL, the sysname is NULL
and that causes a segfault in strcmp.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2015-02-19 06:56:23 +10:00
Peter Hutterer
a138069d5c Rename noaccel to unaccel for consistency
No functional changes, this affects the declaration only.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-02-18 15:05:56 +10:00
Peter Hutterer
65e077759b evdev: check the first parent of the event node for ID_INPUT tags
Bluetooth tablet devices' rules can't tag the event node directly, they can
only tag the first parent (the /sys/class/input/input1234 node). Check that
parent for tags too, lest we miss something important.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Tested-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2015-02-18 10:08:35 +10:00
Benjamin Tissoires
cbeacfed13 Use LIBINPUT_DEVICE_GROUP from udev as group identifier
Store it as identifier in the device group, any two devices that have a
the same non-NULL identifier share the group.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-02-18 10:08:35 +10:00
Peter Hutterer
2b2a1b0eb9 Add udev bits to assign LIBINPUT_DEVICE_GROUP
The easiest way to get a device group is by looking at the phys path of the
input device (which looks like usb-0000:00:14.0-1/input1) and dropping the
/inputX bit. The rest is the same for devices that belong together (except on
the Cintiq 22HD Touch).

Ideally we could just take ATTRS{phys} but we can't select substrings to drop
into ENV so we need to do it ourselves. This patch adds a callout that takes a
syspath and prints the mangled path, to be used in LIBINPUT_DEVICE_GROUP.

The rule triggers on any device that has a non-zero phys attribute, this
groups devices like tablets together but also devices like mice with multiple
interfaces.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Tested-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2015-02-18 10:08:29 +10:00
Peter Hutterer
f0d7eaf11e tools: print the device group in event-debug
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2015-02-18 09:47:41 +10:00
Peter Hutterer
761baeb6e6 Add libinput_device_pointer_has_button over the plain has_button
If a device has multiple capabilities, has_button is imprecise. A device with
tablet and pointer capability for example may have BTN_LEFT on the pointer
interface but not on the tablet interface.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-02-13 14:36:56 +10:00
Marek Chalupa
a9f216ab47 add simple symbols leak checker
This patch adds simple script that compares libinput.sym file to the
functions that are marked by LIBINPUT_EXPORT. This script is added
to make check target.

Signed-off-by: Marek Chalupa <mchqwerty@gmail.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-02-13 10:20:44 +10:00
Peter Hutterer
d6da0e18c2 Add two missing @ref tags
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-02-11 14:54:53 +10:00
Peter Hutterer
43a3a6ced0 evdev: add missing %s for accelerometer tagging
Oh gcc warning, where are thou?

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-02-11 12:38:18 +10:00
Peter Hutterer
911059b1e7 doc: add a dot graph for device groups and two missing @refs
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-02-09 09:50:31 +10:00
Peter Hutterer
b384f2a8ab evdev: switch to using udev's device tagging system
Use ID_INPUT_FOO to assume a device is a FOO, don't decide ourselves based on
whatever bits are available. This moves the categorization out to udev's
input_id builtin by default and other bits that tag the device. libwacom tags
all known devices as ID_INPUT_TABLET and (for touch-enabled ones)
ID_INPUT_TOUCH - we can re-use that knowledge then.

Ignore anything that doesn't have ID_INPUT set, this provides for an easy way
of making devices "invisible" to libinput.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2015-02-09 08:36:58 +10:00
Benjamin Tissoires
1edbac96fa evdev: retrieve udev tags
udev already tags the devices by opening each of them and analyzing their
features. We are basically re-doing this in libinput.

The advantage of udev tags over the plain heuristic from libinput is that
users (or driver writers) can force some tags that are not detected by
common rules. For instance, the pad part of the Wacom tablets is difficult
to discriminate from a joystick or a pointer.

For now we tread INPUT_ID_KEY and INPUT_ID_KEYBOARD as equivalent. It may
become necessary to separate them later.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2015-02-09 08:36:52 +10:00
Peter Hutterer
cbee7ce783 README: Add the libinput component to the bugzilla URL
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-02-09 08:12:45 +10:00
Peter Hutterer
eeac661d93 doc: document that we're ignoring position-less clicks
This can happen a lot easier on the new Lenovo series, so document that this
is intentional behavior.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-02-06 14:35:37 +10:00
Peter Hutterer
e3a43902f9 Introduce device groups to group logical devices together
Devices like Wacom tablets have multiple event nodes (touch, pad and stylus).
This requires some logical grouping, e.g. setting an Intuos 5 tablet
left-handed effectively turns it upside down. That then applies to both the
stylus and the touch device.

Merging the devices into one struct libinput_device is not feasable, it
complicates the API for little benefit. A caller would still need access to
all subdevices to get udev handles, etc. Some configuration options apply to
the whole device (left-handed) but some (may) only apply to a single subdevice
(calibration, natural scrolling).

Addressing this would make the libinput API unwieldly and hard to use.

Instead, add a device group concept. Each device is a member of a device
group - a singleton for most devices. Wacom tablets will have a single group
across multiple devices, allowing the caller to associate the devices together
if needed.

The API is intentionally very simple and requires the caller to keep track of
groups and which/how many devices are in it. The caller has more powerful
libraries available to do that than we have.

This patch does not address the actual merging of devices into the same
device group, it simply creates a new group for each new device.

[rebased on top of 0.10]
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Jonas Ådahl <jadahl@gmail.com>
2015-02-06 11:08:43 +10:00
Peter Hutterer
ca4e03fb11 configure.ac: libinput 0.10.0
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-02-06 10:33:02 +10:00
Olivier Fourdan
f420c54a99 Fix an abort if the device speed is NaN
When using libinput with xf86-input-libinput, the device speed is
represented as a float passed via X properties.

If a buggy client gives a broken value, the conversions that occur
can cause the value of speed to be NaN (not a number), aka infinity.

In C, any comparison with NaN always gives false, whatever the value.

So that test in libinput_device_config_accel_set_speed():

   (speed < 1.0 || speed > 1.0)

will necessarily return FALSE, defeating the test of range.

However, since since any comparison with NaN is false, the
opposite assert() in accelerator_set_speed():

   (speed >= 1.0 && speed <= 1.0)

will be false as well, thus triggering the abort() and the crash of
the entire X server along with it.

The solution is to use the same construct in both routines, so that
it fails gracefully in libinput_device_config_accel_set_speed().

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-02-06 10:26:04 +10:00
Peter Hutterer
65b5647076 cosmetic: fix grammar in doxygen
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-02-06 10:08:33 +10:00
Peter Hutterer
0968c067f6 touchpad: mark two switch fallthroughs with comments
Coverity pointed these out, they're false positives but mark them with
comments to make it obvious to the reader.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-02-04 09:11:46 +10:00
Peter Hutterer
bcb6f22d89 path: make sure udev devices are initialized before usage
When creating uinput devices, we get the devnode from the kernel directly
rather than through udev. When we add this to the path backend too quickly the
udev_device we get may not be fully initialized and properties may be missing.
This causes false test results.

Avoid this by making sure the handle we have is initialized. This should never
trigger on a real device anyway, even creating a device through litest is slow
enough to avoid this issue. Only affected are the tests in misc.c where we
create the uinput device directly.

Nonetheless, handle this for the generic case so we don't run into heisenbugs
later.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2015-02-04 08:14:50 +10:00
Peter Hutterer
26140aba23 test: switch event conversion tests to use litest devices
Makes the code use more commonly used paths, no real functional changes at
this point. This was using hand-crafted devices as it predates the
litest_add_for_device() helper.

For an upcoming patch to use the udev ID_INPUT_. tags the
event_conversion_key test requires this change: without it the device will be
tagged with ID_INPUT_KEY but not ID_INPUT_KEYBOARD. This could be fixed by
adding all normal keyboard keys to the uinput device but it's easier to just
re-use litest.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2015-02-04 08:14:08 +10:00
Peter Hutterer
536dd6a40f zalloc the libinput_source, don't malloc it
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Jonas Ådahl <jadahl@gmail.com>
2015-02-03 10:56:38 +10:00
Peter Hutterer
154b3cf749 Don't init pointer acceleration on absolute devices
Note: touchpads have a different backend, we never get here in that case. This
only applies to true absolute pointer devices.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Jonas Ådahl <jadahl@gmail.com>
2015-02-03 10:56:38 +10:00
Peter Hutterer
2a95a8586d test: add pointer acceleration defaults test
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Jonas Ådahl <jadahl@gmail.com>
2015-02-03 10:43:48 +10:00
Peter Hutterer
199cd87b07 evdev: set the default speed after initializing ptraccel
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Jonas Ådahl <jadahl@gmail.com>
2015-02-03 10:40:49 +10:00
Peter Hutterer
b21fbfd947 filter: zalloc the struct to make sure the speed is initialized
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Jonas Ådahl <jadahl@gmail.com>
2015-02-03 10:37:51 +10:00
Peter Hutterer
ecec6721d1 cosmetic: remove double empty-line
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-02-03 10:34:53 +10:00
Peter Hutterer
4ec2947cc9 test: add per-device udev rule support
Don't rely on a magic version tag, instead let a device define a udev rule and
drop that into the udev runtime directory before the device is created.

There are a couple of caveats with this approach: first, since this changes
system-wide state it may cause issues on the device the test suite is run on.
This can be avoided if the udev rules have filter patterns that ensure only
test devices are affected.

Second, the check test suite aborts but it doesn't run the teardown() function
if a test fails. So far this wasn't a problem since uinput devices disappear
whenever we exit. The rules files will hang around though, so an unchecked
fixture was added to delete all litest-foo.rules files before and after a test
case starts. Unchecked fixtures are run regardless of the exit status of the
test but run in the same address space - i.e. no ck_assert() usage.

Also unchecked fixtures are only run once per test-case, not once per test
function. For us, that means they're only run once per device (we use the
devices as test case), i.e. if a test fails and the udev rule isn't tidied up,
the next test may be unpredictable. This shouldn't matter too much though.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2015-02-03 10:34:26 +10:00
Peter Hutterer
7d7ea4ec2e Add missing doxygen ingroup tag for libinput_device_get_udev_device
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-01-30 15:39:41 +10:00
Peter Hutterer
fd8a29fb69 configure.ac: libinput 0.9.0
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-01-30 14:05:01 +10:00
Peter Hutterer
149f711fcc test: add tests for new lenovo touchpads
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2015-01-29 14:44:35 +10:00
Peter Hutterer
428614bb24 touchpad: re-route trackpoint buttons on the *50 Lenovo series
The laptops on this series have the physical trackpoint buttons back but
wired them up to the touchpad instead of the trackpoint device and they appear
as BTN_0, BTN_1 and BTN_2 for left, right, middle.

The udev hwdb marks these for us with the TOUCHPAD_HAS_TRACKPOINT_BUTTONS tag
[1]. Use that tag to identify them and re-route the events through the
trackstick device after mangling the event codes to represent the actual
buttons.

[1] http://cgit.freedesktop.org/systemd/systemd/tree/hwdb/70-touchpad.hwdb

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2015-01-29 14:43:57 +10:00