Commit graph

253 commits

Author SHA1 Message Date
Davide Depau
5feaa5f00c evdev: don't suspend keyboard on ThinkPad X1 Yoga 1st in tablet mode
When the X1 Yoga is in tablet mode, one capacitative touch button (windows
key, sends KEY_LEFTMETA) and two side volume buttons are accessible on the
front. The key event comes through the internal keyboard that we disabled in
tablet mode so it stops working.

Luckily the Yoga physically disables the "main" keyboard when in tablet mode,
so all we have to do is skip our code to disable the keyboard and the keys are
working again.

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

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-04-18 14:36:31 +10:00
Peter Hutterer
23614f7551 debounce: disable debouncing on the Logitech K400
This is an external keyboard+touchpad but not recognised as touchpad by the
kernel so it's in mouse emulation mode. Double-taps are sent with impossibly
close timestamps and filtered out by the debouncing code. Since this isn't a
real button that can wear out anyway, let's just disable debouncing on this
device.

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

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-04-13 09:29:36 +10:00
Tim Richardson
dd6059aefc evdev: fix duplicated flag value
edit: Luckily there's no overlap between the users of those two flags so this
didn't trigger any bugs.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-04-12 08:48:22 +10:00
Peter Hutterer
8eb41b432e doc: axis overrides need to go to systemd, not libinput
And remove the double-slash in the error message pointing here.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-04-10 08:00:35 +10:00
Peter Hutterer
49a8bd3ca7 Merge branch 'wip/hysteresis-wobbles' 2018-03-09 10:17:43 +10:00
Peter Hutterer
1523d8bb2e Extract and reset the abs fuzz value for the x/y axes
The kernel fuzz handling is buggy, especially when we want to rely on the fuzz
value for our hysteresis. But since this is a hw property and (at least
sometimes) set by the driver, we can't make this a pure libinput hwdb set
either.

So our workaround is:
* extract the (non-zero) fuzz into a udev property so we don't lose it
* set the fuzz to 0 to disable the in-kernel hysteresis
* overwrite our internal absinfo with the property fuzz

This way we get to use the hw-specified fuzz without having the kernel muck
around with it. We also get to use the EVDEV_ABS_ values in 60-evdev.hwdb to
override a driver-set fuzz.

Two drawbacks:
- we're resetting the kernel fuzz to 0, this affects any other users of the
  device node. That's probably a minor impact only.
- we can only save this in a udev property there's a risk of this information
  getting lost when playing around with udev rules. That too should be a minor
  issue.

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

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-03-09 09:49:54 +10:00
Peter Hutterer
a437d9374b touchpad: enable palm detection on tablets' touchpads
https://bugs.freedesktop.org/show_bug.cgi?id=104986

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-03-05 15:51:17 +10:00
Daniel van Vugt
6936a15558 Introduce omnidirectional (elliptical) hysteresis
This changes the hysteresis region to an ellipse (usually a circle), where
previously it was a rectangle (usually square).

Using an ellipse means the algorithm is no longer more sensitive in some
directions than others. It is now omnidirectional, which solves a few
problems:
  * Moving a finger in small circles now creates circles, not squares.
  * Moving a finger in a curve no longer snaps the cursor to vertical
    or horizontal lines. The cursor now follows a similar curve to the
    finger.

https://bugs.freedesktop.org/page.cgi?id=splinter.html&bug=105306

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-03-05 10:40:48 +10:00
Peter Hutterer
56fd071412 evdev: pass the time down to toggle_touch
Currently unused, will be used in later patches

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-02-21 15:13:08 +10:00
Peter Hutterer
582e3c00b7 Add a test device for aiptek tablets
This tablet advertises tilt but doesn't actually have it. Let's rule out tilt
for all aiptek devices until someone complains.

Recording from: https://bugzilla.redhat.com/show_bug.cgi?id=1535755
Related to: https://bugs.freedesktop.org/show_bug.cgi?id=104911

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-02-13 16:04:58 +10:00
Peter Hutterer
3a3fd645c4 evdev: add a quirk to disable debouncing on the MS Nano Transcievers
A set of wireless devices that can scramble the timestamps, so we get
press/release within 8ms even though I doubt the user is capable of doing
this. Since they're generally good quality anyway, let's just disable
debouncing on those until someone complains and we need something more
sophisticated.

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

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-02-13 15:58:48 +10:00
Peter Hutterer
d4b76be18b evdev: log all evdev_msg_* on one line
So we don't have to have newline handling in the callers. This effectively
reverts 6ab2999be9 "test: detect linebreaks in log messages".

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

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2018-02-06 19:29:26 +10:00
Greg V
8adfac3975 Include stdarg.h where variadic functions are used
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-12-01 09:31:42 +10:00
Peter Hutterer
db3b6fe5f7 fallback: change to handle the state at EV_SYN time
The previous approach was to remember the last event and flush it at the right
time. The new approach is to update the device state during the frame and send
out the events at EV_SYN time.

This gives us two advantages: we are not dependent on the kernel order of how
events come in and we can process events depending on other events in the same
frame. This will come in handy later for button debouncing.

This is also the approach we have in the touchpad and tablet backends.

Two FIXMEs are left in place, the button debouncing code and the lid switch
code. Both need to be handled in future patches.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-11-20 09:55:05 +10:00
Peter Hutterer
3279845d63 evdev: reduce the number of separate calls to log_msg
We somewhat expect log message handlers to figure out how to prefix newlines
correctly anyway, but reducing the number of messages printed separately makes
the simple case better.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-11-14 08:30:17 +10:00
Peter Hutterer
e66cf8def1 evdev: document the change-of-directions issue with the hysteresis
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-10-31 08:44:54 +10:00
Peter Hutterer
6b99fabfe8 fallback: move the fallback code into a separate file
Split out the fallback-specific device handling from the more generic
evdev-specific handling (which is supposed to be available for all devices).

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-09-25 15:33:41 +10:00
Peter Hutterer
27eff1ac03 evdev: abstract the get_switch_state method
Shove it into the generic dispatch interface so we don't entangle evdev and
fallback.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-09-25 15:13:37 +10:00
Peter Hutterer
23a611ea1e fallback: allow for multiple keyboards to toggle the lid switch
Previously we only listened for events on the first one to come up, based on
the assumption that there can only be one internal keyboard. The Razer Blade
laptop keyboards come with with multiple event nodes, all looking like a
normal keyboard. The one that comes up first is one for special keys, so
typing on the internal keyboard after a lid switch does not toggle the write
state.

Fix this by allowing for up to 3 keyboard listeners for a lid switch.

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

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-09-25 14:14:20 +10:00
Peter Hutterer
ca83625a74 evdev: add a comment to the toggle_touch interface
And remove an unnecessary one

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-09-20 13:11:13 +10:00
Peter Hutterer
4cc24876da evdev: drop unused #define DEFAULT_TRACKPOINT_ACCEL
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-09-20 13:10:14 +10:00
Peter Hutterer
9765da94c0 evdev: drop unused enum value DISPATCH_LID_SWITCH
Obsolete since f0f6326490

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-09-20 13:10:14 +10:00
Peter Hutterer
1962c6f2db tablet: add a quirk for the HUION PenTablet that doesn't send proximity out events
Could be fixed in the kernel, but these tablets are effectively abandoned and
fixing them is a one-by-one issue. Let's put the infrastructure in place to
have this fixed once for this type of device and move on.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Yay-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2017-09-20 09:30:06 +10:00
Peter Hutterer
986604fd9d touchpad: if a device has a tablet mode switch, disable the touchpad
On some devices with a tablet mode switch, the touchpad is inacessible when
in tablet mode and we don't really need this except to avoid possible ghost
touches (none have been mentioned so far). On other devices like the Lenovo
Yoga, the touchpad points to the back of the device and it's hard to use the
device without accidentally using the touchpad. For those, disabling the
touchpad is the best solution.

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

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-09-06 09:26:00 +10:00
Peter Hutterer
82f2dd8faa Add support for SW_TABLET_MODE
https://bugs.freedesktop.org/show_bug.cgi?id=101008

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-09-06 09:26:00 +10:00
Peter Hutterer
f0f6326490 evdev: move lid code to the fallback interface
This was originally designed to deal with devices that only have SW_LID. But
it can be moved into the evdev interface to avoid duplication once we have
SW_TABLET_MODE. The original assumption of the lid switch device being a
standalone device with no other switches is not true, having a separate
dispatch hurts us here.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-09-06 09:26:00 +10:00
Peter Hutterer
d9a729e1a7 Add libinput_device_switch_has_switch()
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-09-06 09:24:29 +10:00
Peter Hutterer
3004163725 evdev: remove declarations for two nonexistent functions
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-09-05 10:41:27 +10:00
Peter Hutterer
55d1bb1217 pointer: add button debouncing
Some devices have worn-out switches or just cheap switches that trigger
multiple button events for each press. These can be identified by unfeasably
short time deltas between the release and the next press event. In the
recordings I've seen so far, that timeout is 8ms.

We have a two-stage behavior: by default, we do not delay any events but we
monitor timestamps. The first time a bouncing button is detected we switch to
debounce mode. From then on, release events are delayed slightly to check for
subsequent button events. If one occurs, the releas and press are filtered. If
none occurs, the release event is passed to the caller.

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

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-07-26 00:21:46 +10:00
Peter Hutterer
87b5682824 filter: add a custom trackpoint accelerator
Switch to a pure factor with a max scaled after a function. The offset is just
0 now (will be removed eventually). Both are determined with a function based
on a linear/exponential regression of a sample set of data pairs.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-07-20 11:53:01 +10:00
Peter Hutterer
1cfa1f64cf evdev: read LIBINPUT_ATTR_KEYBOARD_INTEGRATION property
We have heuristics for detecting whether a keyboard is internal or external,
but in some cases (e.g. Surface 3) these heuristics fail. Add a udev property
that we can apply to these cases so we have something that's reliable.

This will likely eventually become ID_INPUT_KEYBOARD_INTEGRATION as shipped by
systemd, similar to the touchpad property.

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

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-05-23 15:10:10 +10:00
Peter Hutterer
78a810cfd5 Remove write-only CYAPA model tag
Obsolete since we moved pressure into the hwdb in
8d5f4decb4

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-05-22 13:25:46 +10:00
Gabriel Laskar
20f5f2d962 util: harmonize container_of() definition with linux kernel one
commit 3925936 introduced changes to container_of, this is hopefully the
last part of it.

In the linux kernel, container_of() takes a type name, and not a
variable. Without this, in some cases it is needed to declare an unused
variable in order to call container_of().

example:

	return container_of(dispatch, struct fallback_dispatch, base);

instead of:

	struct fallback_dispatch *p;
	return container_of(dispatch, p, base);

This introduce also list_first_entry(), a simple wrapper around
container_of() to retrieve the first element of a non empty list. It
allows to simplify list_for_each() and list_for_each_safe().

Signed-off-by: Gabriel Laskar <gabriel@lse.epita.fr>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-05-17 15:04:41 +10:00
Paul Kocialkowski
6af9f8e5fb udev: Remove unused Elantech touchpad model binding
The Elantech touchpad model binding in udev is currently unused, since
pressure values were moved to a udev binding of their own.

This gets rid of the deprecated model binding.

Signed-off-by: Paul Kocialkowski <contact@paulk.fr>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-05-02 10:37:44 +10:00
Peter Hutterer
25b14e1335 evdev: mark the new log functions as printf-style functions
And fix up the one buggy call we had

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-03-23 07:30:08 +10:00
Peter Hutterer
6181adbdcd evdev: standardize log messsages
Prefix device log messages with the device's sysname so it's more obvious
where the messages are coming from. This makes it much easier to grep for a
specific device's messages but also adds some identifier to messages that
were previously without any identifier (e.g. all the state machine debugging)

All info and error messages also automatically prefix the device name, so
those messages are standardised too, e.g

an info message now:
  event4  - SynPS/2 Synaptics TouchPad: is tagged by udev as: Touchpad
a debug message now:
  event4  - using pressure-based touch detection

And since this required changing a lot of the strings in messages anyway,
polish a few minor things too.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Acked-by: Hans de Goede <hdegoede@redhat.com>
2017-02-24 16:04:44 +10:00
Peter Hutterer
6a2870f5ca evdev: add "READY" state to button scrolling
Before, our states were idle, button down and scrolling. This adds a state
where the button is down and the timeout has expired (i.e. we're ready to send
scroll events) but we haven't actually sent any events anymore.

If the button is released in this state, we generate a normal click event.

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

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2017-02-20 21:16:34 +10:00
Peter Hutterer
3697b72071 evdev: convert button scrolling into a state machine
No functional changes, preparation work for adding another state.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2017-02-20 13:51:39 +10:00
Peter Hutterer
f7f849e576 evdev: add quirk for Logitech Marble Mouse
Device needs BTN_MIDDLE disabled, this way middle button emulation is present
by default.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2017-02-20 12:25:05 +10:00
Peter Hutterer
f2f616a1fc touchpad: mark the Apple onebutton touchpad as clickfinger-default
We don't initialize click methods on devices with physical buttons. This model
is a special case, it's not a clickpad but it only has one button (because one
button is all you ever need and whatnot).

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

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-02-09 09:26:07 +10:00
Peter Hutterer
45d7794de2 Merge branch 'wip/switch-interface' 2017-02-01 13:56:32 +10:00
Peter Hutterer
ab563d0920 evdev: fix a comment typo
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-01-31 12:46:51 +10:00
Peter Hutterer
2dc6534ec0 evdev: add a wrapper to get the evdev device from a libinput device
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-01-31 08:00:58 +10:00
Peter Hutterer
60de087e65 evdev: improve type-safety on dispatch switches
Set the dispatch type on creation, then check that whenever we try to get the
dispatch struct. This avoids a potential mismatch between the backends.

Plus, use of container_of means we're not dependent on the exact layout
anymore.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-01-31 07:36:12 +10:00
Peter Hutterer
e6806ce292 switch: move the lid switch bits into their own file
Keep this separate from the other code so it's easier to read

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-01-26 14:44:04 +10:00
James Ye
4aeb3cc018 Add evdev_dispatch interface for lid switch
Create a lid_switch_interface to handle lid switch events, so the touchpad can
be disabled when lid is closed.

Signed-off-by: James Ye <jye836@gmail.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-01-26 14:44:04 +10:00
Peter Hutterer
ebeba8e8ff Merge branch 'wip/wheel-tilt-source' 2017-01-20 12:51:53 +10:00
Peter Hutterer
43ba2dbb30 touchpad: add a model tag to mark touchpads with visible marker
We used to mark dell touchpads this way but let's make this more generic.
Nothing else used the dell touchpad model flag, so we can simply replace it.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2017-01-11 10:39:05 +10:00
Peter Hutterer
4bf8b8934d evdev: add support for wheel tilt
This is added on top of the click angle handling, so the actual axis values
simply fall back onto whatever is set by udev, including the default fallbacks
to 15 and whatnot.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2017-01-04 15:15:28 +10:00
Peter Hutterer
eacdf296a5 touchpad: convert two functions to use the device->phys helpers
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2016-12-14 15:19:50 +10:00