Commit graph

169 commits

Author SHA1 Message Date
Peter Hutterer
a6f0e4ae60 timer: flush the timer funcs if our events come in late
Avoid processing an event with a time later than the earliest timer expiry. If
libinput_dispatch() isn't called frequently enough, we may have e.g. a tap
timeout happening but read a subsequent input event first. In that case we can
erroneously trigger or miss out on taps, see wrong palm detection, etc.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2017-09-21 12:27:46 +10:00
Peter Hutterer
2b867feab7 Put a check in to make sure our events have correct timestamps
This is for debugging purposes only, we cannot guarantee that event timestamps
always go up - at least not across devices. Example: tapping on a touchpad may
delay an event until a timeout expires, but that event is then sent with the
original touch timestamps (i.e. in the past). If any other device produces
events during that timeout period, our timestamps are out-of-order.

This isn't really a bug because we are forced to do that, but for bug-fixing
it can be useful to detect.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-04-28 16:47:38 +10:00
Peter Hutterer
f5d8552cc3 tablet: move definition of tablet_axes down
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Acked-by: Ping Cheng <pingc@wacom.com>
2017-03-23 10:18:09 +10:00
Peter Hutterer
d17e84fc0f Add a helper function for initializing an event listener
Not needed right now as everything assumes the listener was added before it
was removed. This helper is for the cases where we may call listener_remove
before it was ever added.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-01-26 14:44:04 +10:00
James Ye
1f0223e9fd Add a "switch" interface for parts of the SW_* range
This will allow switch devices known to libinput to be exposed. Currently,
this is SW_LID.

libinput also handles switch events internally, e.g. a laptop touchpad will
be disabled autmoatically when the lid is closed. This is transparent to
the caller, although the caller will also receive the event. See
https://bugs.freedesktop.org/show_bug.cgi?id=86223
This features is intended to be the main driver for the interface.

Co-Authored-By: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: James Ye <jye836@gmail.com>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-01-26 14:44:04 +10:00
Peter Hutterer
a64f9df5ce Drop normalized_get_direction, use physical distances instead
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2017-01-23 10:43:04 +10:00
Peter Hutterer
33d708e2de touchpad: convert normalized_length to physical coordinates
Now that the acceleration code doesn't use dpi-normalized coordinates anymore,
we don't need to use them in the touchpad code. Switch to physical distances
instead, it makes debugging a lot saner.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2017-01-23 10:37:08 +10:00
Peter Hutterer
4bf8b8934d evdev: add support for wheel tilt
This is added on top of the click angle handling, so the actual axis values
simply fall back onto whatever is set by udev, including the default fallbacks
to 15 and whatnot.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2017-01-04 15:15:28 +10:00
Peter Hutterer
bdd4264d61 filter: change the filter functions to take raw device coordinates
We used to normalize all deltas to equivalents of a 1000dpi mouse before
passing it into the acceleration functions. This has a bunch of drawbacks, not
least that we already have to un-normalize back into device units for a few
devices already (trackpoints, tablet, low-dpi mice).

Switch the filter code over to use device units, relying on the dpi set
earlier during filter creation to convert to normalized. To make things easy,
the output of the filter code is still normalized data, i.e. data ready to be
handed to the libinput caller.

No effective functional changes. For touchpads, we still send normalized
coordinates (for now, anyway). For the various filter methods, we either drop
the places where we unnormalized before or we normalize where needed.

Two possible changes: for trackpoints and low-dpi mice we had a max dpi factor
of 1.0 before - now we don't anymore. This was only the case if a low-dpi
mouse had more than 1000dpi (never true) or a trackpoint had a const accel
lower than 1.0 (yeah, whatever).

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2016-12-21 10:55:57 +10:00
Peter Hutterer
187c38f660 Add device_float_get_direction
With some upcoming changes we need this function for device float coordinates
as well.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2016-12-21 10:55:56 +10:00
Peter Hutterer
ab42022253 Change the directions bitmask to a uin32_t
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2016-12-15 19:43:41 +10:00
Peter Hutterer
e0b200caa6 Use the LIBINPUT_VERSION define, not the normal VERSION
Not that it really matters, but given we're already setting it anyway...

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Yong Bakos <ybakos@humanoriented.com>
2016-12-01 11:06:32 +10:00
Peter Hutterer
58c7a9cbf0 evdev: implement support for the MOUSE_WHEEL_CLICK_COUNT property
Not all mice have a click angle with integer degrees. The new
MOUSE_WHEEL_CLICK_COUNT property specifies how many clicks per full rotation,
the angle can be calculated from that.

See https://github.com/systemd/systemd/pull/4440 for more information

CLICK_COUNT overrides CLICK_ANGLE, so we check for the former first and then
fall back to the angle if need be. No changes to the user-facing API.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2016-11-04 12:10:52 +10:00
Peter Hutterer
63990614b0 Move touch_notify_frame declaration to the other touch functions
No functional changes

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2016-10-28 15:38:30 +10:00
Peter Hutterer
b02acd346b Read the horizontal wheel click angle property if available
The Logitech MX master has different click angles for the two wheels.

https://github.com/systemd/systemd/issues/3947

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2016-08-22 11:29:35 +10:00
Peter Hutterer
59fac8e902 Add configurable button map to tappings
The previously hardcoded button map for tapping is 1/2/3 to LRM. But the
middle button is a common feature on the desktop (used for paste, most
prominently) and three-finger tapping is almost impossible to do reliably on
some touchpads (e.g. the T440 has a recognition rate of ~1 in 5).

Left and right buttons have a prominent physical position (either softbuttons
or physical buttons) so make the tap order configurable. Those that require
middle buttons reliably can use the [software] buttons for left/right and
2-finger tap for a middle button.

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

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2016-08-15 09:05:57 +10:00
Peter Hutterer
b1c51ee9d9 evdev: add helper functions to convert between units and mm
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2016-08-01 07:10:27 +10:00
Peter Hutterer
271dc496dc Switch a bunch of internal functions from int to bool
All these effectively returned bools anyway, switch the signature over to be
less ambiguous.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Yong Bakos <ybakos@humanoriented.com>
Reviewed-by: Eric Engestrom <eric.engestrom@imgtec.com>
2016-07-20 11:43:45 +10:00
Peter Hutterer
18f5819d75 pad: implement basic mode group support (1 group with 1 mode)
Until the kernel patches to handle LED group switching are in place we provide
the external API backed by an implementation that simply exposes one group
with one mode and no toggle buttons. This allows us to ship a libinput release
with the API in place and switch libinput later without having all the stack
above us being delayed.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Carlos Garnacho <carlosg@gnome.org>
2016-06-24 13:29:17 +10:00
Peter Hutterer
6583f4bb53 pad: Add a new API for modes and mode groups
Move mode control to libinput. This reduces some flexibility on what we can do
with modes but makes it a lot easier for anyone to implement modes correctly
and have the LEDs apply appropriately, etc. Let's go with the option to make
the 95% use-case easy. Note: whether the mode is actually used is up to the
caller, e.g.  under Windows and OS X the mode only applies to the
rings/strips, not the buttons.

A tablet pad has 1 or more mode groups, all buttons/ring/strips are assigned
to a mode group. That group has a numeric mode index and is hooked to the
LEDs. libinput will switch the LEDs accordingly.

The mode group is a separate object. This allows for better APIs when it comes
to:
* checking whether a button/ring/strip is part of a mode group
* checking whether a button will trigger a mode transition

and in the future potentially:
* checking which mode transition will happen
* setting which button should change the mode transition
* changing what type of mode transition should happen.
* moving a button from one mode group to the other

This patch adds the basic scaffolding, without any real implementation.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Proofread-by: Yong Bakos <ybakos@humanoriented.com>
Reviewed-by: Jason Gerecke <jason.gerecke@wacom.com>
Reviewed-by: Carlos Garnacho <carlosg@gnome.org>
2016-06-22 11:57:07 +10:00
Peter Hutterer
d1a8a92184 Add support for relative device rotation (trackball only)
Trackballs are effectively stationary devices and can be positioned at any
rotation. They are also employed by users with impaired dexterity which
sometimes implies that they are positioned at an non-default angle to make the
buttons easier to reach.

Add a config option for rotation for trackball devices. Currently only
supported for 90-degree angles, if there is a need we can add more angles
later.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2016-05-16 09:21:38 +10:00
Peter Hutterer
4fdaa1b2a9 Make a link to the html docs available as a #define
The "latest" documentation link is the location for the master branch,
released versions have their own directory on the server.

The micro-versions of 90 and above are used for snapshots and release
candidates, so whenever we have a micro version of >= 90 we still want to link
to the "latest" documentation. In all other cases, we link to the current
release.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2016-04-28 10:01:20 +10:00
Peter Hutterer
b2a3706948 Add the LIBINPUT_DEVICE_CAP_TABLET_PAD capability and matching interface
This interface handles the buttons on the physical tablet itself, including
the touch ring and the strip.

A notable difference to other libinput interfaces here is that we do not use
linux/input.h event codes for buttons. Instead, the buttons are merely
numbered sequentially, starting at button 1. This means:
* the API is different, instead of get_button() we have get_button_number() to
  drive the point home
* there is no seat button count. pads are inherently different devices and
  compositors should treat them as such. The seat button count makes sense
  when you want to know how many devices have BTN_LEFT down, but it makes no
  sense for buttons where all the semantics are handled by the compositor
  anyway.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Jason Gerecke <jason.gerecke@wacom.com>
Reviewed-by: Carlos Garnacho <carlosg@gnome.org>
2016-04-18 09:12:02 +10:00
Peter Hutterer
c9abcb2e1c tablet: change tilt axes to use degrees
The Wacom tilt range is 64 degrees so we map everything into that until we
know otherwise.

This commit also switches the tilt axes around to align the angles with the
x/y orientation, i.e. tilting the top of the stylus towards the positive x
axis now generates a positive x tilt.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Jason Gerecke <jason.gerecke@wacom.com>
2016-02-09 12:19:12 +10:00
Peter Hutterer
ae41aa146d Merge branch 'master' into tablet-support 2016-01-27 13:54:00 +10:00
Peter Hutterer
cba2278c3a touchpad: add a config option to disable tap-and-drag
There are a number of use-cases where tapping may be desirable, but
tap-and-drag is not, e.g. where tapping is used to select multiple items in a
list. Having tap-and-drag on hinders this, and the nature of the interaction
means it cannot be detected based on timeouts, movement thresholds, etc.

Provide an option instead to turn tap-an-drag off. Tap-and-drag remains
enabled by default (though tapping is disabled by default).

For the touchpad tap state diagram, the new option disables the transition
from state TOUCH to state TAPPED and releases the button immediately instead.
This means that multitap-and-drag is disabled too since we now just loop
around in the single-tap state for multitap.

It also makes tapping more responsive - we don't have to wait for the timeout
before we know whether it's a tap event. The first touch time is noted, we now
send the button press with the time of the first touch and the release with
the time of the release. This ensures a realistic time diff between the two
events.

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

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.netto>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2016-01-27 10:03:28 +10:00
Peter Hutterer
de3f1fa6fa Merge branch 'master' into tablet-support 2016-01-25 15:29:11 +10:00
Peter Hutterer
108a191a3e tablet: add support for relative x/y motion deltas
Instead of an explicit tablet mode that device must be changed into, let the
caller decide which coordinates are preferred. The tablet mode may be
application-specific and usually depends on the tool as well.

This patch adds an interface to get a motion delta for the x/y axes in
pixel-like coordinates. libinput provides some magic to convert the tablet
data into something that resembles pixels from a mouse motion.
For unaccelerated relative motion, the caller should use the mm values from
the tablet and calculate deltas manually.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Acked-by: Jason Gerecke <jason.gerecke@wacom.com>
2016-01-22 16:16:55 +10:00
Peter Hutterer
585deda799 gestures: pass the finger count into pinch events
Prep work for multifinger pinch gestures

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2016-01-20 15:38:12 +10:00
Peter Hutterer
d524313d2b tablet: use a struct rather than a double array for axis values
Makes the code less generic, but more expressive. No visible functional
changes.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Acked-by: Jason Gerecke <jason.gerecke@wacom.com>
2016-01-15 10:07:18 +10:00
Peter Hutterer
1a99977ca0 tablet: a tip event can replace an axis event
When we're only dealing with BTN_TOUCH we can make the tip event independent
of the axis event. Now that we handle pressure thresholds to trigger tip state
this does not work, we'd have to send an axis event with the new pressure and
then a tip event. Since the pressure triggers the tip event this seems
disconnected.

Make the tip event officially capable of carrying axes. A caller can then
decide how to forward this to the next layer.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Acked-by: Jason Gerecke <jason.gerecke@wacom.com>
2016-01-11 15:17:46 +10:00
Peter Hutterer
96fbf84862 tablet: add pressure threshold handling
On tablets with ABS_PRESSURE use a pressure value to determine tip state, not
BTN_TOUCH. This enables us (down the road) to have device-specific pressure
thresholds. For now we use a 5% default for all devices.

The threshold is a range, if we go past the upper range we initiate the tip
down, if we go below the lower range we release the tip again.

This affects two current tests:
* Once we have pressure offsets and pressure thresholds, we're biased towards
pressure. So we can only check that distance is zero when there is a pressure
value, not the other way round.
* When the pressure threshold is exceeded on proximity in with a nonzero
distance, we can only warn and handle the pressure as normal. Since this is a
niche case anyway anything fancier is likely unnecessary.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Acked-by: Jason Gerecke <jason.gerecke@wacom.com>
2016-01-11 15:17:46 +10:00
Peter Hutterer
d51c8f9420 tablet: always set the pressure offset
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Acked-by: Jason Gerecke <jason.gerecke@wacom.com>
2016-01-11 15:17:46 +10:00
Peter Hutterer
53ac112d6c tablet: split out axis handling into helper functions
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2015-12-23 07:33:39 +10:00
Peter Hutterer
fa71278c19 tablet: store the wheel delta in the normal axes
Now that we don't provide an API anymore to access the absolute value of the
wheel and the axes are handled separately, we can safely store the wheel delta
in the normal axis array.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2015-12-23 07:33:39 +10:00
Peter Hutterer
9fd0fb0df8 tablet: dump deltas, replace it with a single wheel_delta variable
The wheel is the only one axis that has actual deltas, all others have
straightforward deltas that we don't need to care about, the caller can
calculate those where needed.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2015-12-23 07:33:39 +10:00
Peter Hutterer
d5e18a8e64 tablet: dump deltas_discrete, replace with a single wheel_discrete variable
Only the wheel has a discrete value, no need to keep arrays for a single
value.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2015-12-23 07:33:39 +10:00
Peter Hutterer
8635ba556b tablet: remove the libinput_tablet_tool_axis enum from the public API
Internally we still use it, at least for now.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Acked-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Lyude <cpaul@redhat.com>
2015-12-21 07:59:00 +10:00
Peter Hutterer
db852ef0db tablet: support tool-specific pressure offsets
If a tool wears out, it may have a pre-loaded pressure offset. In that case,
even when the tool is not physically in contact with the tablet surface it
will send pressure events.

Use automatic pressure offset detection, similar to what the X.Org wacom
driver does. On proximity-in, check the pressure and if the distance is above
50% of the range and the pressure is nonzero but below 20% of the range, use
that value as pressure offset.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Ping Cheng <pingc@wacom.com>
2015-12-15 08:21:39 +10:00
Peter Hutterer
7123c37f1c tablet: rename tool_tip_state to tablet_tool_tip_state
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2015-11-18 12:13:53 +10:00
Peter Hutterer
a22b94a22c tablet: rename tool_proximity_state to tablet_tool_proximity state
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2015-11-18 12:13:53 +10:00
Peter Hutterer
b85d57fdf8 tablet: rename libinput_tool_type to libinput_tablet_tool_type
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2015-11-18 12:13:53 +10:00
Peter Hutterer
827abfbb56 tablet: rename the tablet axes to "LIBINPUT_TABLET_TOOL_AXIS_..."
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2015-11-18 12:13:53 +10:00
Peter Hutterer
98df9eb63f tablet: rename libinput_tool to libinput_tablet_tool
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2015-11-18 12:13:53 +10:00
Peter Hutterer
7835e74604 tablet: allow fetching the tip state from any tablet event
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2015-11-16 09:23:59 +10:00
Peter Hutterer
1318ffadb5 tablet: split out tip handling into a separate event
The tablet tip works like a button in the kernel but is otherwise not really
a button. Split it into an explicit tip up/down event instead.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2015-11-12 06:52:51 +10:00
Peter Hutterer
ab6a409cdc Merge branch 'master' into tablet-support 2015-10-21 19:19:01 +10:00
Peter Hutterer
8d9e7a1bcf Add an API to change pointer acceleration profiles
The quartett of new config functions is:
	libinput_device_config_accel_get_profiles
	libinput_device_config_accel_get_profile
	libinput_device_config_accel_set_profile
	libinput_device_config_accel_get_default_profile

The profile defines how the pointer acceleration works, from a very high-level
perspective. Two profiles are on offer, "adaptive", the standard one we have
used so far and "flat" which is a simple multiplier of input deltas and
provides 1:1 mapping of device movement vs pointer movement.

The speed setting is on top of the profile, a speed of 0 (default) is the
equivalent to "no pointer acceleration". This is popular among gamers and
users of switchable-dpi mice.

The flat profile unnormalizes the deltas, i.e. you get what the device does
and any device below 800dpi will feel excruciatingly slow. The speed range
[-1, 1] maps into 0-200% of the speed. At 200%, a delta of 1 is translated
into a 2 pixel movement, anything higher makes it rather pointless.

The flat profile is currently available for all pointer devices but touchpads.

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

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2015-09-11 00:54:01 +10:00
Peter Hutterer
0c7ef582eb Fix leaking device groups
If a caller has a reference to a device group when the context is destroyed,
the memory for the group is never released. Calling
libinput_device_group_unref() will release it and there are no side-effects
since the group has no back-references. It's inconsistent with the rest of
libinput though - all other resources get released on libinput_unref().

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Jonas Ådahl <jadahl@gmail.com>
2015-09-10 01:11:06 +10:00
Peter Hutterer
8fe7f08e85 Merge branch 'master' into tablet-support 2015-08-26 14:24:16 +10:00