Always require mtdev on eventcomm

Since a missing mtdev disables all of multitouch on eventcomm, we might as
well always require it.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Chase Douglas <chase.douglas@canonical.com>
Fix build error - duplicate typedef (#47168)

Introduced in c34cf307f9982b62c6e6dfa2687e1b16f527f2a4.
synapticsstr.h includes synproto.h, which now contains the typedef.

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

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Chase Douglas <chase.douglas@canonical.com>
tools: add hysteresis support to synclient

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Chase Douglas <chase.douglas@canonical.com>
Don't use linear regression when calculating touchpad motion deltas

The results depend on the data rate of the device. A device with a
higher data rate, and thus lower individual deltas, will behave
differently with the regression calculation.

This can be verified on Synaptics semi-mt clickpads. The data rate is
halved when two or more touches are on the device. When trying to press
a button and drag the cursor with another touch, the motion will feel
faster than dragging with only one touch on the device.

Signed-off-by: Chase Douglas <chase.douglas@canonical.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
If the middle button timeout is 0, don't even attempt to emulate.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Chase Douglas <chase.douglas@canonical.com>
Use arrays for st->mt scaling

No functional changes

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Chase Douglas <chase.douglas@canonical.com>
Move st->mt scaling to helper function

No functional changes.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Chase Douglas <chase.douglas@canonical.com>
Move filtering into a separate function

No functional changes.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Chase Douglas <chase.douglas@canonical.com>
Move resetting hw state to separate function.

No functional changes.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Chase Douglas <chase.douglas@canonical.com>
Add an old_hw_state field to remember the last values

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Chase Douglas <chase.douglas@canonical.com>
Only handle ClickFingers on left button press events

ClickFingers doesn't need to be handled on every state, only when the actual
button state changes.

This is a break from the previous behaviour which allowed pressing the
button followed by a two-finger tap to trigger the ClickFinger2 action.
Let's see if anyone complains.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Chase Douglas <chase.douglas@canonical.com>
Add a BTN_EMULATED_FLAG to mark emulated buttons on clickfingers

And when copying the hardware state, don't copy those buttons that were set
through emulation.

This is a temporary fix only, we should add new fields to the hw struct that
represent the various features as they are enabled/disabled and then treat
them accordingly.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Chase Douglas <chase.douglas@canonical.com>
Add clickpad device property

Add it as a writable device property. We may not know how to probe some
clickpads so allow the user to override it.

Signed-off-by: Chase Douglas <chase.douglas@canonical.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Disable middle mouse button emulation on clickpads

Because, well, really, how?

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Chase Douglas <chase.douglas@canonical.com>
Guess the number of clickpad ClickFingers based on finger distance

The actual distance should be done in cm, based on touchpad resolution etc.
That is left as an exercise for the reader.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Chase Douglas <chase.douglas@canonical.com>
Add cumulative_d{x,y} to SynapticsHwState

These values will be used for clickpad press and drag with two fingers.

While the clickpad button is not pressed, cumulative_d{x,y} will match x
and y values. Once the clickpad button is pressed, cumulative_d{x,y}
will be updated with the relative motion of each active touch on the
touchpad. This allows for dragging with one finger while another finger
stays stationary holding the clickpad button down.

This is an easier and less latent approach than trying to guess which
touch was the "dragging" touch.

[fixed build error for mt off]

Signed-off-by: Chase Douglas <chase.douglas@canonical.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Enable clickpad click and drag with two fingers

Use cumulative relative touch motion when the clickpad is pressed. If
more than one touch is active, assume one of the touches is designated
solely for pressing the clickpad button. Thus, decrement the number of
reported touches.

Signed-off-by: Chase Douglas <chase.douglas@canonical.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Disable scrolling when beginning a clickpad press

There really isn't a point to scrolling while a clickpad is pressed. In
particular, the clickpad button areas and the horizontal edge scrolling
areas overlap, so horizontal edge scrolling must be disabled. Also,
performing two finger scrolling while a third finger presses the button
would require us to inhibit touch events until four touches are present.
That is enough reason to disable two finger scrolling as well.

Signed-off-by: Chase Douglas <chase.douglas@canonical.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Calculate touch data for semi-mt devices, but don't send touch events

Previously, all touch data from semi-mt devices was ignored because the
X server doesn't support them. However, the touch data must be used for
proper clickpad handling.

Instead of ignoring semi-mt device touch events, mark the device as
being semi-mt and allow initialization of the touch state. The touches
will then be used in calculating the cumulative_d{x,y} values that are
needed for clickpad support.

When handling the touch data for X event processing, simply skip over
reporting the touches.

Signed-off-by: Chase Douglas <chase.douglas@canonical.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Add soft button areas property

Some clickpad devices have button areas painted on them. Set this
property to the area of the right and middle buttons to enable proper
click actions when clicking in the areas.

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