Commit graph

448 commits

Author SHA1 Message Date
Peter Hutterer
df212db2a3 evdev: keep the absinfo struct around instead of min/max
We'll need that later for conversion to mm.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2014-06-19 12:00:58 +10:00
Hans de Goede
92a67a3a94 touchpad: tp_current_touch: Fix off by one error
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-06-19 10:09:03 +10:00
Peter Hutterer
fc51daff73 touchpad: always call into the the tap state machine
A button event consumed by the softbutton or clickpad code does not feed into
the tap state machine, leaving it in its current state. The touch generating
that event however may have triggered state changes.

For some tap/click combinations this gives us either double press/release
events or an inconsistent order of events. Those issues include:
* a really short physical click causes a click + tap-click
* a really short physical click on the right software button causes a right
  click + left tap-click
* tap + click causes double button left press events

To avoid these, notify the tap code that a button event has occured and
process that accordingly. Depending on the state this may either continue to
the DEAD state or release the current tap button and then go to the DEAD
state.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2014-06-12 10:29:26 +10:00
Hans de Goede
04c7987443 evdev-mt-touchpad-tap: Switch over to new timer subsystem
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-06-10 20:55:18 +10:00
Hans de Goede
31ef8bff44 evdev-mt-touchpad-buttons: Switch over to new timer subsystem
Besides being a nice cleanup, this gives us proper per touch timeouts.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-06-10 20:55:18 +10:00
Jonas Ådahl
f3084e2c0d Use floating point numbers instead of fixed point numbers
Fixed point numbers can easily overflow, and double to fixed point
conversion is lossy. Use floating point (double) where fixed point
numbers where previously used and remove the li_fixed_t type.

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-06-09 20:46:53 +02:00
Peter Hutterer
14a1d189ff touchpad: whitespace fix
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-06-05 07:58:51 +10:00
Peter Hutterer
82438a2cf6 touchpad: Drop the scroll direction lock, increase threshold instead
The direction lock was intended to avoid erroneous horizontal scroll events
when scrolling vertically (and vice versa). Some testing on my touchpad here
shows that it is too easy to accidentally lock the direction when no lock is
intended (e.g. moving around an image). And quite hard to figure out what a
pure vertical gesture is.

I get movements from 90 degrees to 70 degrees for something my brain would
consider vertical scrolling. Depending on the hand position, the fingers
actually perform a slight curve, not a straight line.

Hence - drop the direction lock, but increase the threshold a little. It
doesn't totally avoid horizontal scroll events but keeps them minimal.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2014-06-05 07:58:16 +10:00
Jonas Ådahl
e18e9d56a8 touchpad: Make anisotropic motion deltas isotropic
The x and y absolute axis may have different resolutions, meaning 1 unit
long motion delta on one axis is not physically as long as 1 unit motion
delta on the other axis.

In order to make these anisotropic input motion deltas output as isotropic
motion deltas, apply scaling to one of the axis making it have the same
dimension as the other, before passing it through the motion filter
which assumes all deltas are isotropic.

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

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2014-05-29 13:06:36 +02:00
Jonas Ådahl
7cb4540916 filter: Add motion filter destruction helper
Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2014-05-29 13:06:16 +02:00
Hans de Goede
bdb13fd1d3 touchpad: Stop scrolling on a button click / tap
On a button click / tap the scrolling event handler no longer gets called,
ensure that any in progress scrolling is stopped.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-05-27 16:35:03 +10:00
Hans de Goede
8d41230d65 touchpad: Refactor tp_post_scroll_events()
Put the actual scroll event posting in the straight path.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-05-27 16:34:58 +10:00
Hans de Goede
ecb132fef6 touchpad: Fix sending of scroll stop events
Setting tp->scroll.direction = 0 before checking tp->scroll.direction
to see if we need to send stop scroll events for vert / horz scrolling does
not really work well.

Also we need to check direction with an axis mask, not the axis number.

While at it also add a tp_stop_scroll_events() helper function for this.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-05-27 16:34:54 +10:00
Hans de Goede
cee3a482f3 touchpad: Clear touches being the pointer when doing 2 finger scrolling
When doing 2 finger scrolling we don't want any spurious movement events after
scrolling. touchpad_2fg_no_motion tests for this, but it lifts touch 0
(which is the pointer as it came down first) first, so it only catches the
case where touch 1 suddenly gets promoted to being the pointer.

However if touch 1 is lifted first, then touch 0 is still the pointer and
will cause spurious movement events. Swap the 2 litest_touch_up calls to
catch this (and make the test fail), and add code to clear the is_pointer
flag on all touched when doing 2 finger scrolling to fix it again.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-05-27 16:34:51 +10:00
Peter Hutterer
5082eaf250 Merge branch 'clickpad-improvements-v2' of git://people.freedesktop.org/~jwrdegoede/libinput 2014-05-23 08:51:29 +10:00
Jonas Ådahl
4e669bf246 touchpad: Make pointer movements a bit faster by default
Alter the so far hard coded parameters a bit to make the pointer
acceleration profile accelerate the pointer movement a bit more than
before.

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-05-22 21:48:22 +02:00
Hans de Goede
89165da6d6 Change internal timestamps to uint64_t to properly deal with wrapping
We store timestamps in ms since system boot (CLOCK_MONOTONIC). This will wrap
after circa 50 days.

I've considered making our code wrapping safe, but that won't work. We also
use our internal timestamps to program timer-fds for timeouts. And we store
ms in a single integer but the kernel uses 2 integers, one for seconds and
one for usec/nanosec. So at 32 bits our ms containing integer will wrap
in 50 days, while the kernels seconds storing integer lasts a lot longer.
So when we wrap our ms timestamps, we will be programming the timer-fds
with a seconds value in the past.

So change all our internal timestamps to uint64_t to avoid the wrapping
when programming the timer-fds. Note that we move from 64-bit timestamps to
32-bit timestamps when calling the foo_notify_bar functions from
libinput-private.h. Having 64 bit timestamps has no use past this point,
since the wayland input protocol uses 32 bit timestamps (and clients will
have to deal with wrapping).

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-05-22 14:51:41 +02:00
Hans de Goede
a70ef98d57 touchpad: Remove clickpad clicked test from 2 finger scrolling handling
This is no longer needed now that we take the button area and pinned fingers
into account.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-05-22 14:51:41 +02:00
Hans de Goede
55b2ea65f3 touchpad: Ignore fingers in button area for 2 finger scroll
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-05-22 14:51:41 +02:00
Hans de Goede
f6c3731f8a touchpad: Use INPUT_PROP_BUTTONPAD instead of checking for buttons
And warn if INPUT_PROP_BUTTONPAD mismatches right/middle buttons presence.

Also fix the bcm5974 to properly advertise INPUT_PROP_BUTTONPAD.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-05-22 14:45:22 +02:00
Hans de Goede
55d84420e2 touchpad: Rework is_pointer handling
We don't want touches in the button area to cause the pointer to move. So
instead of making a touch the pointer when it moves to TOUCH_BEGIN, wait
with making it the pointer until its buttons state moves to BUTTON_STATE_AREA.

Note that a touch in the main area of the touchpad will move to
BUTTON_STATE_AREA immediately. If software-buttons are not enabled, any finger
is in the BUTTON_STATE_AREA.

While at it also refactor the is_pointer setting in general, removing
code duplicition wrt checking that another touch is not already
the pointer on unpinning a finger, and add safeguards that unpinning
does not make a finger which is not in button state BUTTON_STATE_AREA the
pointer, nor that the button code makes a pinned finger the pointer.

All these sanity checks are combined into a new tp_button_active function,
since they should be taken into account for 2 finger scrolling, etc. too.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-05-22 14:45:01 +02:00
Peter Hutterer
e192ecc6e9 touchpad: Add clickpad-style software buttons
Almost all non Apple touchpads have visible markings for software button areas,
so limit clickfinger behavior to Apple clickpads, and implement software button
areas for others.

This is a slightly fancier implementation than the simplest model and ported
over from libtouchpad. It implements a state machine for the software buttons
with left and right buttons currently implemented. Buttons are oriented
left-to-right, in a horizontal bar. No random button placement allowed.

In general, the procedure is:
- if a finger sets down in the left button area, a click is a left click
- if a finger sets down in the right button area, a click is a right click
- if a finger leaves the button area, a click is a left click
- if a finger starts outside the button area, a click is a left click

Two timeouts are used to handle buttons more smoothly:
- if a finger sets down in a button area but "immediately" moves over
  to a different area, that area takes effect on a click.
- if a finger leaves a button area and "immediately" clicks or moves back into
  the area, the button still takes effect on a click.
- if a finger changes between areas and stays there for a timeout, that area
  takes effect on a click.

Note the button area states are named BOTTOM_foo to make it easier to later
add support for a top button area such as can be found on the Thinkpad [2-5]40
series.

Co-authored-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Jonas Ådahl <jadahl@gmail.com>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-05-22 14:44:55 +02:00
Peter Hutterer
21d7b2b50a touchpad: move button-related code into a separate file
This is about to become more complicated with the support for software button
areas. Move it to a separate file to have it logically grouped together.
No functional changes.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2014-05-22 14:39:00 +02:00
Peter Hutterer
cba4560566 touchpad: after a click, lock the finger to its current position
On clickpads, clicking the pad usually causes some motion events. To avoid
erroneous movements, lock all fingers into position on the click and don't
allow for motion events until a finger moves past a given threshold
(currently 2% of the touchpad diagonal).

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Jonas Ådahl <jadahl@gmail.com>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-05-22 14:39:00 +02:00
Peter Hutterer
4b089fbd67 touchpad: set ntouches for single-touch pads depending on key bits
A single-touch touchpad that provides BTN_TOOL_TRIPLETAP has 3 touches, etc.
There aren't a lot of these out there, but some touchpads don't have slots but
do provide two- or three-finger detection.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Jonas Ådahl <jadahl@gmail.com>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2014-05-22 14:39:00 +02:00
Carlos Olmedo Escobar
97af5c33a3 touchpad: check calloc result
Check the value returned by calloc.

Signed-off-by: Carlos Olmedo Escobar <carlos.olmedo.e@gmail.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-04-30 13:24:27 +10:00
Jonas Ådahl
6834dd4628 touchpad: Silence -Wmaybe-uninitialized compiler warning
Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
2014-04-23 00:07:40 +02:00
Peter Hutterer
e49a9888bf touchpad: clean up tap bits on destroy
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-03-25 16:43:35 +10:00
Peter Hutterer
ebed4f0de3 touchpad: add missing flag for ABS_X events
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-03-25 16:37:37 +10:00
Peter Hutterer
7c2da22fc1 touchpad: fix copy/paste error
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-03-25 16:37:31 +10:00
Peter Hutterer
92f5860bfa 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>
2014-03-24 16:39:12 +10:00
Peter Hutterer
f3accd3c05 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>
2014-03-24 16:39:12 +10:00
Peter Hutterer
05f82c573f 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>
2014-03-24 16:39:12 +10:00
Peter Hutterer
4e8f1259cc 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>
2014-03-24 16:39:12 +10:00
Peter Hutterer
efc8d95171 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>
2014-03-24 16:39:12 +10:00
Peter Hutterer
8ea5cb75c1 touchpad: Only move the pointer when there's a single finger down
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-03-24 14:56:41 +10:00
Peter Hutterer
c1a9b24a0a 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>
2014-03-24 14:56:41 +10:00
Peter Hutterer
0d759edc3f touchpad: Filter motion in a certain number of tap states
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-03-24 14:56:41 +10:00
Peter Hutterer
d4bd05184a touchpad: add support for multi-finger tapping
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-03-24 14:56:40 +10:00
Peter Hutterer
3df87f4fe3 touchpad: Make touchpad_get_delta() available from other files
No functional changes.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-03-24 14:56:40 +10:00
Peter Hutterer
1f656f12cf 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>
2014-03-24 14:56:40 +10:00
Peter Hutterer
b9dda43c04 touchpad: mark which events are currently pending processing
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-03-24 14:56:40 +10:00
Peter Hutterer
dc13d3ec96 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>
2014-03-24 14:56:40 +10:00
Peter Hutterer
d22cdf1c47 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>
2014-03-24 14:56:40 +10:00
Peter Hutterer
8d867a2b8a touchpad: hook up the pointer acceleration
Same algorithm as in evdev-touchpad.c

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-03-24 14:56:40 +10:00
Peter Hutterer
e75a0430be touchpad: add hysteresis smoothing for input coordinates
Same algorithm as in evdev-touchpad.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-03-24 14:56:40 +10:00
Peter Hutterer
37a04e0b0d 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>
2014-03-24 14:56:40 +10:00
Peter Hutterer
d2e026d8ae 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>
2014-03-24 14:56:40 +10:00