util: add min/max macros

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
evdev-touchpad: replace some numbers with a #define

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
evdev-touchpad: don't post motion events for 0/0 deltas

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Add a customizable log handler

The previous log handler wasn't actually hooked up to anything. Add a public
API for the log handler with priority filtering, defaulting to priority
'error' and stderr as output stream.

And to keep the diff down and convenience up, provide a few simple wrappers
for logging. The generic is log_msg(), but let's use log_info, log_error, etc.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
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>
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>
touchpad: add hysteresis smoothing for input coordinates

Same algorithm as in evdev-touchpad.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
touchpad: hook up the pointer acceleration

Same algorithm as in evdev-touchpad.c

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
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>
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>
touchpad: mark which events are currently pending processing

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
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>
touchpad: Make touchpad_get_delta() available from other files

No functional changes.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
touchpad: add support for multi-finger tapping

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
touchpad: Filter motion in a certain number of tap states

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
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>
touchpad: Only move the pointer when there's a single finger down

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
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>
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>
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>