Commit graph

83 commits

Author SHA1 Message Date
Peter Hutterer
72560e031b fallback: force the palm state to PALM_NONE on touch begin
If we don't have tool-based palm detection, make sure our touch is labelled as
"not palm" during touch down. Otherwise that slot remains on palm forever if
it gets tagged as palm through some other means.

This currently has no effect, nothing in the code would label the touch as
palm. This is prep work for better touch arbitration.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-01-31 05:17:28 +00:00
Peter Hutterer
d3595908e5 evdev: introduce a touch arbitration enum
This enables us to change the types of touch arbitration, with the focus on
allowing location-based touch arbitration as well as the more generic "disable
everything".

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-01-31 05:17:28 +00:00
Peter Hutterer
ab1dbcc996 fallback: add timer-based touch arbitration
When a hand is resting on a pen+touch device, lifting the hand may remove the
stylus from proximity before the hand leaves the surface. If the kernel
performs touch arbitration, this triggers a touch down on proximity out,
followed by a touch up immediately after when the hand stops touching.

This can cause ghost touch events. Prevent this by using a timer-based
arbitration toggle.

Same as 2a378beab0 but for the fallback
interface.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-01-31 05:17:28 +00:00
Peter Hutterer
c75c00dac3 fallback: when force-releasing keys, release them directly
An emulated button is recorded as BTN_MIDDLE in the key down mask. If the
device is removed in that state, the BTN_MIDDLE event processed triggers
an assertion when we try to send out the event twice.

Fixes #201

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-01-31 15:09:44 +10:00
Peter Hutterer
500d03d78e fallback: cancel touches, don't just release them when we suspend
When we disable the touch device, any existing touches should be cancelled,
not just released.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-09-27 10:27:19 +10:00
Peter Hutterer
522a1dca7f evdev: switch the model flags to use the quirks directly
Anything that merely requires a once-off check during initialization can just
use the quirks directly, no need to copy them over to the model flags.

Fixes #146

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-09-20 12:41:24 +10:00
Peter Hutterer
b44f6b4eef fallback: explicitly ignore external keyboards for the tablet mode switch
We already had a check to only pair trackpoints and internal keyboards
but for the ThinkPad Compact Bluetooth Keyboard with TrackPoint that isn't
sufficient - it's an external keyboard that contains a trackpoint. Explicitly
ignore external keyboard, we never want to shut those down in tablet mode
anyway.

Fixes #119

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-08-27 09:19:46 +10:00
Peter Hutterer
da0fbb580f fallback: add support for ABS_MT_TOOL_TYPE for touch screens
Cancel any touches that trigger MT_TOOL_PALM.

Fixes https://gitlab.freedesktop.org/libinput/libinput/issues/25

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-08-03 14:21:18 +10:00
Peter Hutterer
adf0e5a9c7 fallback: move flushing MT events to a helper function
No functional changes

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-08-03 13:29:20 +10:00
Peter Hutterer
da0a630f14 fallback: change a list of if conditions to a switch statement
This used to do a lot more but now it can be handled as simple switch
statement. Bonus: we get to log a bug if we ever get here in NONE state.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-08-03 13:29:20 +10:00
Peter Hutterer
1432a95040 fallback: add another debug message for tablet-mode keyboard suspend
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-08-02 11:22:11 +10:00
Peter Hutterer
0b96f167ad fallback: change a debug message to be less ambiguous
"activated" sounds like we're disabling things here, but we're just pairing
the two devices

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-08-02 11:22:11 +10:00
Peter Hutterer
1f3f681fa7 fallback: cancel the debounce timers during device remove, not destroy
destroy isn't called until the last libinput_device_unref(), so we may trigger
a debounce timer after the device was removed. The same fix is neded for the
touchpad interface.

Fixes https://gitlab.freedesktop.org/libinput/libinput/issues/72

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-06-29 13:52:17 +10:00
Peter Hutterer
d376db0669 touchpad: make the dwt paired keyboard list a struct list
This removes the artificial 3 keyboard limit. If you have more internal
keyboards than that, something is wrong in your setup but that shouldn't stop
us from working. Or more specificially: this can happen easily when running
tests so let's not fail the test suite because we created a few hundred
keyboards.

We'll still throw out a log message though.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-05-30 09:42:06 +10:00
Peter Hutterer
bcbc873651 fallback: make the paired keyboard list a struct list
This removes the artificial 3 keyboard limit. If you have more internal
keyboards than that, something is wrong in your setup but that shouldn't stop
us from working. Or more specificially: this can happen easily when running
tests so let's not fail the test suite because we created a few hundred
keyboards.

We'll still throw out a log message though.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-05-30 09:42:06 +10:00
Peter Ganzhorn
4cc2b952a2 fallback: Add IBM/Lenovo Scrollpoint mice quirk to enable smooth scrolling.
Instead of a scroll wheel these mice feature trackpoint-like sticks which
generate a huge amount of scroll events that need to be handled differently
than scroll wheel events.

Signed-off-by: Peter Ganzhorn <peter.ganzhorn@gmail.com>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-04-26 09:53:57 +10:00
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
b2fb2adefa Remove some duplicate empty lines
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-04-16 15:14:23 +10:00
Peter Hutterer
50418a0153 fallback: fix touchscreen defuzzing
The hysteresis-returned point always differs from the current point, even if
the hysteresis kicks in. We need to compare to the hysteresis center.

And the returned point is only the new center if we exceed the margin,
otherwise the center stays as-is.

The touch_fuzz() test only succeeded for this because for the values we were
introducing jitter by, the kernel filtered out all the actual movement so
these paths weren't hit.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-03-09 09:49:54 +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
dccc23a77f fallback: remove unused DEBOUNCE_TIME setting
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-01-23 15:28:09 +10:00
Peter Hutterer
1c8636923b fallback: send key events out immediately upon receiving them
Commit db3b6fe5f7 "fallback: change to handle the state at EV_SYN time"
introduced regressions for two types of event sequences.

One is a kernel bug - some devices/drivers like the asus-wireless send a key
press + release within the same event frame which now cancels out and
disappears into the ether. This should be fixed in the kernel drivers but
there appear to be enough of them that we can't just pretend it's an outlier.

The second issue is a libinput bug. If we get two key events in the same frame
(e.g. shift + A) we update the state correctly but the events are sent in the
order of the event codes. KEY_A sorts before KEY_LEFTSHIFT and our shift + A
becomes A + shift.

Fix this by treating key events as before db3b6fe5f7 - by sending them out
as we get them.

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

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-12-08 10:09:26 +10:00
Peter Hutterer
0e0dfe9bdf Merge branch 'wip/button-debouncing-v3' 2017-11-20 10:15:16 +10:00
Peter Hutterer
de994d135e evdev: add new debouncing code
The current debouncing code monitors events and switches on when events are
too close together. From then on, any event can be delayed.

Vicente Bergas provided an algorithm that avoids most of these delays:
on a button state change we now forward the change without delay but start a
timer. If the button changes state during that timer, the changes are
ignored. On timer expiry, events are sent to match the hardware state
with the client's view of the device. This is only done if needed.

Thus, a press-release sequence of: PRP sends a single press event, a sequence of
PRPR sends press and then the release at the end of the timeout. The timeout
is short enough that the delay should not be noticeable.

This new mode is called the 'bounce' mode. The old mode is now referred to as
'spurious' mode and only covers the case of a button held down that loses
contact. It works as before, monitoring a button for these spurious contact
losses and switching on. When on, button release events are delayed as before.

The whole button debouncing moves to a state machine which makes debugging a
lot easier. See the accompanying SVG for the diagram.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-11-20 09:55:05 +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
87920f4992 fallback: create the evdev-fallback.h header file
So we can split up evdev-fallback.c into multiple files where needed.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-11-20 09:55:05 +10:00
Peter Hutterer
2fc394dcde fallback: log an error if we failed to write the switch event
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-11-17 09:22:37 +10:00
Peter Hutterer
eb048529b5 evdev: fix axis mixup for the wheel click angles
vertical wheel is y, not x

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-11-14 12:04:27 +10:00
Peter Hutterer
41a70bbe92 fallback: fix lid switch event listener being initialized twice
Once the lid is closed, the keyboard event listener is set up to open the lid
for us on keyboard events. With the right sequence, we can trigger the
listener to be added to the list multiple times, triggering an assert in the
list test code (or an infinite loop in the 1.8 branch).

Conditions:
* SW_LID value 1 - sets up the keyboard listener
* keyboard event - sets lid_is_closed to false
* SW_LID value 0 - is ignored because we're already open
* SW_LID value 1 - sets up the keyboard listener again

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

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-10-27 15:20:35 +10:00
Peter Hutterer
84d49ee49c fallback: suspend internal keyboards and trackpoints on tablet-mode switch
Because on some devices the keyboard is where the fingers are holding the
device when in tablet mode.

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

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-09-25 15:34:45 +10:00
Peter Hutterer
350ce2b3f1 fallback: add 'interface' to the fallback interface's method names
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-09-25 15:33:41 +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