filter: move get_direction into shared header

Makes it possible to use from the touchpad code.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
touchpad: implement edge-based basic palm detection

A large part of palm events are situated on the far edges of the touchpad. In
a test run on a T440s while typing a long email all but 2 touch points were
located in the outer ~5% of the touchpad. Define a 5% exclusion zone on the
left and right edges in which new touchpoint is automatically assigned to be a
palm.

A finger may move into that exclusion zone without being marked as palm, it
just can't start in one.

On clickpads, the exclusion zone does not extend into the software buttons.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
touchpad: don't init palm detection on resolution-less touchpads

If we don't know how big the touchpad is we don't know if palm detection on
the edges is even necessary.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
touchpad: if a palm touch moves out of the edge zone within a timeout, unpalm

On small touchpads a touch that is intended to traverse much of the screen
width may start at the very edge, i.e. in the palm zone.
In that case, and if the touch moves out of the palm zone quickly enough, drop
the palm label and make it a normal touchpoint.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
touchpad: require a <45 degree movement for a palm to become a touch

Any legitimate finger movement that starts in the palm area is expected to
move out of the palm area at an angle roughly orthogonal to the edge of the
touchpad. Check for the direction of the movement vector, and if it is within
the accepted cardinal/ordinal directions then proceed.

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