Commit graph

300 commits

Author SHA1 Message Date
Peter Hutterer
aaa7622933 evdev: use the button down time for no-scroll middle button press event
When we get the release event within the timeout, we send a press + release
event for the middle button. Rather than using the release event's timestamp
for both, remember and use the button press timestamp.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2015-06-02 09:01:18 +10:00
Peter Hutterer
ec468e8993 evdev: use the udev ID_INPUT_POINTINGSTICK property
Added in systemd 220, but note that for udev backwards compatibility, the
ID_INPUT_POINTINGSTICK tag is set in addition to the ID_INPUT_MOUSE tag.

And use that property to tag a device as trackpoint too, this allows temporary
workarounds for kernel bugs where the input prop isn't set yet.

https://bugzilla.redhat.com/show_bug.cgi?id=1225563

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2015-05-29 12:23:05 +10:00
Peter Hutterer
969d19dd22 Update Red Hat's copyright
Updated to 2015 where appropriate, added where missing.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-05-28 09:58:11 +10:00
Peter Hutterer
cfdb83b305 touchpad: only check keyboards for disable-while-typing
The keyboard test is a simple one, if we have the first row of alphabetic
keys, we assume it's a full keyboard.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Tested-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2015-05-27 17:38:25 +10:00
Peter Hutterer
0c8d76181d evdev: rename evdev_compare_syspath for clarity
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-05-26 08:49:46 +10:00
Peter Hutterer
0ca29c6ddc Add streq() helper to use instead of strcmp() == 0
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-05-26 08:46:05 +10:00
Peter Hutterer
180564c780 evdev: sync the initial state for absolute pointer devices
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Tested-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2015-05-21 21:41:47 +10:00
Peter Hutterer
4889a0c3c2 evdev: sync the initial x/y position for touchscreens
Unlikely, but there's the odd chance of the first touch coming in with the
same X or Y coordinate the kernel already has internally. This would generate
a x/0 or 0/y event in libinput.

Sync the slot state on init, at least for Protocol B devices. For Protocol A
devices and mtdev, don't bother.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Tested-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2015-05-21 21:41:47 +10:00
Peter Hutterer
736e292fc4 evdev: add an interface hook to suspend a device
The touchpad carries enough state around that calling release_all_keys() isn't
enough to properly suspend it. e.g. a button down after tapping won't be
released by trying to release the physical button for it.

We need to clear the state properly, but that's interface-specific so add a
new hook for it.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Tested-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2015-05-21 21:41:47 +10:00
Peter Hutterer
58174416ca evdev: move release_pressed_keys() up
Just a move to make the next diff easier

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Tested-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2015-05-21 21:41:47 +10:00
Peter Hutterer
db567c01a4 evdev: log a bug if releasing a key fails, but don't loop forever
If a physical button is down but releasing said button doesn't actually
release it, we loop endlessly. Detect that and log a bug instead.

Reproducible: trigger a tap-n-drag on a touchpad device, then remove it.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Tested-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2015-05-21 21:41:46 +10:00
Jan Alexander Steffens (heftig)
e39dca063b Rename MODEL_SYSTEM76_CLEVO to MODEL_CLEVO_W740SU
The System76 Galago Ultra Pro is a rebranded Clevo W740SU with changed
firmware strings. To my knowledge, the Clevo W740SU and all its rebrands
possess smooth touchpads.

In the original bug report[1], a Galago Ultra Pro was returned to the
original DMI strings by flashing another firmware. This resulted in the
model identified as MODEL_SYSTEM76_CLEVO.

Since the actual manufacturer of the W740SU is Clevo and the CLEVO hwdb
entry already properly identifies other W740SU rebrands like the Schenker
S413, the model should be renamed to match.

[1]: https://bugs.freedesktop.org/show_bug.cgi?id=90170#c3

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

Signed-off-by: Jan Alexander Steffens (heftig) <jan.steffens@gmail.com>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-05-21 11:31:55 +10:00
Peter Hutterer
d6867dfae0 touchpad: enable clickfinger by default on some System76 laptops
Bonobo, Clevo, Galago and Kudu have clickpads and no markings ->
enable clickfinger by default.

Lemur and Gazelle have physical buttons, no need for extra configuration.

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

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2015-05-05 07:36:14 +10:00
Peter Hutterer
f52dbc5ad9 touchpad: enable clickfinger by default on chromebooks
This matches the vendor default.

Board IDs pulled from modinfo chromeos_laptop, touchpad names from a bit of
googling around.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Tested-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2015-05-04 19:30:46 +10:00
Derek Foreman
28ed7a6265 Set O_CLOEXEC when opening devices
We'd rather keep these out of the hands of children.

Signed-off-by: Derek Foreman <derekf@osg.samsung.com>
Reviewed-by: David Herrmann <dh.herrmann@gmail.com>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-05-01 08:56:11 +10:00
Peter Hutterer
a21ab9eb98 evdev: indentation fix
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-04-30 16:44:43 +10:00
Peter Hutterer
a7b2d04e90 evdev: enable button scrolling by default on mice without wheels
If we have a middle button but no wheels, enable on-button scrolling for the
middle button by default. This applies e.g. to the Logitech trackball added as
new test device here.

This makes the separate check for POINTINGSTICK obsolete but I'd rather leave
this in to be more explicit about it.

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

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2015-04-28 17:12:31 +10:00
Peter Hutterer
5e85957ad2 evdev: init pointer accel filters when we have rel x/y axes
Some devices provide abs x/y and rel x/y. We can't know which event the device
will send. The Microsoft Surface Type Cover sends relative events, which
then crashes libinput when we don't have an accel filter set up.

So instead of checking that the device doesn't have ABS_X/Y, check for the
device to have REL_X/Y instead.

https://bugzilla.redhat.com/show_bug.cgi?id=1206869

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-By: Derek Foreman <derekf@osg.samsung.com>
2015-04-28 07:45:32 +10:00
Peter Hutterer
6083fafe53 evdev: reject devices with only REL_X but no REL_Y (or vice versa)
Not sure if any exists, if they do let's see if a user files a bug report
first so we know what to do with those (they're most likely buttonsets).

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-By: Derek Foreman <derekf@osg.samsung.com>
2015-04-28 07:45:17 +10:00
Benjamin Tissoires
26ceea3e3b evdev: use a different filter for low resolution touchpad on the Lenovo X230
Those touchpads presents an actual lower resolution that what is
advertised.

We see some jumps from the cursor due to the big steps in X and Y
when we are receiving data.

For instance, we receive:

E: 13.471932 0003 0000 16366    # EV_ABS / ABS_X                16366
E: 13.471932 0003 0001 9591     # EV_ABS / ABS_Y                9591
E: 13.471932 0000 0000 0000     # ------------ SYN_REPORT (0) ----------
E: 13.479924 0003 0000 16316    # EV_ABS / ABS_X                16316
E: 13.479924 0003 0001 9491     # EV_ABS / ABS_Y                9491
E: 13.479924 0000 0000 0000     # ------------ SYN_REPORT (0) ----------
E: 13.487939 0003 0000 16271    # EV_ABS / ABS_X                16271
E: 13.487939 0003 0001 9403     # EV_ABS / ABS_Y                9403
E: 13.487939 0000 0000 0000     # ------------ SYN_REPORT (0) ----------

-> jumps of ~50 in X in each report, and ~100 for Y.

Apply a factor to minimize those jumps at low speed, and try
keeping the same feeling as regular touchpads at high speed.
It still feels slower but it is usable at least

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Tested-by: Vasily Khoruzhick <anarsoul@gmail.com>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-04-27 10:00:10 +10:00
Peter Hutterer
0515a670af evdev: add support for LIBINPUT_MODEL_* udev tags
Some devices need specific configuration or different defaults.
Push that into udev rules and a hwdb file, that's where detection is the
easiest. The LIBINPUT_MODEL_ prefix is used to determine some type of device
model. Note that this property is a private API and subject to change at
any time without notice.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Tested-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2015-04-24 08:38:58 +10:00
Peter Hutterer
4996076a7c Add libinput_device_keyboard_has_key()
Similar to libinput_device_pointer_has_button(), this function returns whether
a given device has a specific keycode.

This enables a caller to determine if the device is really a keyboard (check
for KEY_A-KEY_Z) or just a media key device (check for KEY_PLAY or somesuch),
depending on the context required.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Derek Foreman <derekf@osg.samsung.com>
2015-04-23 10:32:31 +10:00
Hans de Goede
5c671e0375 evdev: Add support for POINTINGSTICK_CONST_ACCEL udev property
There is quite a wide spread in the delta events generated by trackpoints,
some generate deltas of 1-2 under normal use, while others generate deltas
from 1-20.

It is desirable to normalize trackpoint deltas just like we are normalizing
mouse deltas to 1000 dpi, so as to give different model laptops aprox.
the same trackpoint cursor speed ootb.

Recent versions of udev + hwdb set a POINTINGSTICK_CONST_ACCEL udev property
which can be used to adjust trackpoints which are too slow / too fast
ootb, this commit implements support for that property.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-04-22 09:35:28 +02:00
Peter Hutterer
776bf4938d evdev: accept but disable ABS_MISC and above for min/max == 0
This is sort-of legitimate, so simply disable the axes and continue.
Any real axis we require to have a real range.

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

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2015-04-21 11:36:19 +10:00
Peter Hutterer
1ba7004dbc evdev: enable middle button configuration on some devices
Devices that have left and right buttons but no middle button get middle
button emulation (without config). Devices that have a middle button too get
a config option but default to off. Most mice have LMR set as buttons,
regardless whether they have a middle button.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2015-04-17 12:50:08 +10:00
Peter Hutterer
75f15917a3 evdev: add support for middle button emulation
This is just the required framework, it's not hooked up to anything just yet.
Hooking it up comes as separate commit to better detail why/when a device
supports emulation.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2015-04-17 12:50:03 +10:00
Peter Hutterer
3c500b597c evdev: add evdev_pointer_notify_physical_button
No functional changes at this point, this merely splits up any physical
buttons (i.e. that represent buttons that exist on that device) vs. other
buttons that are emulated in some way or another.

This is in preparation for the addition of middle button emulation.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2015-04-17 12:49:43 +10:00
Peter Hutterer
a5c7de04c4 evdev: merge two conditions into one with a sub condition
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-04-15 10:43:13 +10:00
Peter Hutterer
6f1c8cda85 evdev: add a event-debugging log statement (ifdef'd out)
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-04-15 10:43:13 +10:00
Peter Hutterer
e15a7a740d evdev: any scroll device must have CAP_POINTER
Follow-up to e2f61b8fb7.

Scroll events are sent through the pointer interface, so we must set the
capability. Otherwise a caller may not have the required bits set up and is a
bit surprised by events coming out of an interface the device doesn't actually
have (xf86-input-libinput crashes when this happens).

Reported-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Tested-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2015-04-13 11:47:39 +02:00
Peter Hutterer
36ec8b5133 evdev: reject devices with only one of x/y resolution
This is a kernel bug, reject such devices outright. This saves us from a bunch
of extra double checks to make sure that the resolutions are always set up.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2015-04-09 14:18:27 +02:00
Peter Hutterer
c6d81c84de evdev: fix inverted mouse normalization
Regression introduced in 9f8edc5fd8 where it
changed from delta / (dpi/default) to delta * dpi/default, causing the inverse
effect of what the dpi setting is supposed to achieve.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2015-04-08 11:42:58 +02:00
Peter Hutterer
e2f61b8fb7 evdev: if a keyboard has a scroll wheel, allow natural scrolling
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2015-04-08 11:42:47 +02:00
Peter Hutterer
e2b13e6022 evdev: fix handling of fake MT devices without ABS_X/Y
The previous code didn't handle fake MT devices without ABS_X/Y axes (like the
Razer BlackWidow keyboard). Those devices usually start at ABS_MISC and go up
to ABS_MAX, thus triggering the Android check.

Split the condition up: if the device is not a fake MT device we check for the
Android missing axes first and add them. Then we proceed, but now we know that
the ABS_X axis must exist on any valid device.

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

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2015-04-08 11:42:40 +02:00
Peter Hutterer
67208c0b1a evdev: fix crash for missing ABS_X/Y
libevdev_set_abs_info() is a noop if the event code isn't enabled on the
device. This leaves ABS_X/Y on NULL, causing a crash later when dereferencing
the absinfo.

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

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2015-04-08 11:42:26 +02:00
Hans de Goede
b87251ca71 Add a normalized_is_zero helper function
Add a normalized_is_zero helper function, and use it where applicable.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-03-25 15:16:41 +01:00
Peter Hutterer
0e262e55bc evdev: reject devices with a min == max axis range
Except for a few axes where this may be correct, a min == max axis range
indicates a broken kernel driver. To avoid potential divisions by zero when
scaling this axis later, reject such a device outright.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2015-03-23 14:24:27 +10:00
Peter Hutterer
69d5bbbeba filter: switch to normalized_coords
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2015-03-19 12:06:48 +10:00
Peter Hutterer
70f8ae5678 evdev: factor out setting up the MT slots/mtdev
No functional changes

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2015-03-17 15:13:55 +10:00
Peter Hutterer
1e4116beb9 evdev: refactor fake resolution setting
Make the helper function accessible from other places (will be needed in an
upcoming patchset). This also now takes a custom resolution as argument
instead of always setting it to 1, and allows overriding a fake resolution
after the fact.

And instead of a hardcoded 1 everywhere, use a define for the resolution.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2015-03-17 15:13:55 +10:00
Peter Hutterer
522a42e9b4 Push the touchpad magic slowdown to the touchpad accel code
This way the unaccelerated deltas returned by libinput are correct.

To maintain the current behavior we slow down the input speed by the magic
factor and likewise the accelerated output speed. This produces virtually the
same accelerated deltas as the previous code.

The magic factor is applied to the default denominator for guessing a
resolution based on the touchpad diagonal. We can't really get around this
without having a resolution from the touchpad; meanwhile this produces
virtually the same coordinates before/after.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2015-03-17 15:13:55 +10:00
Peter Hutterer
99d0c743f4 evdev: don't try to fix abs devices without x/y
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2015-03-17 15:13:55 +10:00
Peter Hutterer
edd534807d evdev: add evdev_reject_device to reject a couple of oddball devices
We really don't need to deal with devices that have x but not y or vice versa.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2015-03-17 15:13:55 +10:00
Peter Hutterer
dc1d946170 evdev: fix android MT devices
These devices don't provide ABS_X/Y, but do have proper multitouch.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2015-03-17 12:34:17 +10:00
Peter Hutterer
1df0208f4f Add another data type for discrete coordinates
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2015-03-17 09:02:47 +10:00
Peter Hutterer
a3c8d72625 Use typesafe coordinates in touch events
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2015-03-17 09:02:12 +10:00
Peter Hutterer
2d54b550b7 Use typesafe coords in motion events
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2015-03-17 09:01:39 +10:00
Peter Hutterer
47d7989682 Use typesafe coordinates for scrolling events
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2015-03-17 09:01:39 +10:00
Peter Hutterer
f5a0a381cb evdev: start introducing some type-safety for device/normalized coordinates
Make it clear where we're dealing with device coordinates and where we're
dealing with DPI-normalized coordinates.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2015-03-17 09:01:39 +10:00
Peter Hutterer
9f8edc5fd8 evdev: add helper function to normalize delta coordinates
No functional changes.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2015-03-17 09:01:39 +10:00