Check touch record bounds before access

We guess ten simultaneous touches if the device does not tell us. The
Linux drivers for the Apple multitouch trackpads do not tell the number
of simultaneous touches, but they can do more than ten. When this
occurs, the array index into the touch records will be invalid. We must
not process the touch or else we will segfault.

Signed-off-by: Chase Douglas <chase.douglas@canonical.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Replace hardcoded max number of touches with a define.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Chase Douglas <chase.douglas@canonical.com>
tools: skip non-existing properties

If a property doesn't exist on a device, skip it.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Chase Douglas <chase.douglas@canonical.com>
Don't count fingers twice when guessing distance (#48316)

A finger may be closer than the required distance to more than one finger.
e.g. for fingers A, B, C, AB, AC and BC may trigger the check and count
C twice -resulting in a 4 finger click.

Avoid double-counting by marking those fingers already close enough to a
previous finger to avoid overcounting.

X.Org Bug 48316 <http://bugs.freedesktop.org/show_bug.cgi?id=48316>

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Chase Douglas <chase.douglas@canonical.com>
Fix coasting speed

Fixes a bug introduced in commit 2603ad69b997c999404ecc441e0d64ea2cc22018
(Use the scroll distances as increment for scrolling valuator axes)

Since this commit, scroll distance was set with SetScrollValuator function
but it was still used as a divisor to calculate coasting,
thus making coasting too slow. (at least on my computer)

Deleting the divisor fixes the issue.

A report of the same bug : https://bugs.archlinux.org/task/28955

Signed-off-by: Pierre Lulé <pierre@lule.fr>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Use maximum number of touches reported by evdev

This resolves a regression from da461b91659d0c64aa6827e065aee2682116a57e
where three touch tap and click actions on certain devices no longer
work.

Some devices report a higher touch count than the number of touches they
can provide data for. For example, many Synaptics touchpads can report
up to five touches, but only provide data for two of them. We need to be
able to report the correct number of touches for these devices when
there are three touches. Using the maximum of the reported touch count
and the number of touches provided ensures the count is accurate for all
device types.

Signed-off-by: Chase Douglas <chase.douglas@canonical.com>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Support inverted scroll direction.

This patch allows scroll direction to be inverted by allowing
VertScrollDelta and HorizScrollDelta to be set to negative values. This
enables behaviour that is consistent with modern touchscreen devices,
where the content scrolls in the same direction as the user's finger
movement.

Signed-off-by: Alyssa Hung <ahung@isisview.org>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
synaptics 1.5.99.903

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>