Commit graph

377 commits

Author SHA1 Message Date
Peter Hutterer
2a1095924b Run clang-format over the code
This uses the .clang-format file in the follow-up commit, but committed
prior to that to ease review of said file and various integrations.

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1246>
2025-07-01 16:42:44 +10:00
Peter Hutterer
56f0524115 tablet: always allow BTN_STYLUS* for eraser button configuration
If the button we want to map to isn't enabled by the kernel allow
setting the button nonetheless. On some tablets we only get the
actual number of button codes (e.g. BTN_STYLUS only on an Inspiroy 2S)
so not being able to map the eraser button to some other button makes
this whole feature a bit pointless.

Special-case BTN_STYLUS* because these are the ones we'll always allow.

This fixes an issue with the eraser button defaulting to BTN_STYLUS2
on some devices but it couldn't actually be set to that value by the
caller.

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1231>
2025-06-19 01:51:52 +00:00
Peter Hutterer
34da27650d tablet: take an uint32_t for the eraser button
For consistency with other set_button configuration options.

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1231>
2025-06-19 01:51:52 +00:00
Peter Hutterer
4ef14e14e4 Add an API for configurable eraser button behavior
This adds the public API to configure an eraser button on a tablet tool
to emulate a normal button. In DEFAULT mode the eraser button will
simply do whatever it does by default (i.e. toggle to eraser).
In BUTTON mode the eraser button will be converted to a regular tool
button event, with libinput handling the underlying proximity event
madness.

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1218>
2025-06-18 19:38:14 +10:00
Peter Hutterer
04975b4618 Constify libinput_config_accel_set_points()
We copy the contents of the double array so let's constify this.

Fixes: 5324f425a1 ("Introduce custom acceleration profile")

Closes #1114

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1195>
2025-05-06 04:34:46 +00:00
Peter Hutterer
67428b64e0 doc: fix two duplicated references
Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1155>
2025-03-12 11:43:25 +10:00
Peter Hutterer
1d9e307e2b touchpad: implement support for three-finger drag
Exposed via new configuration option this enables 3 and 4 finger
dragging on touchpads. When enabled a 3/4 finger swipe
gesture is actually a button down + motion + button up sequence.

If tapping is disabled the drag starts immediately, if tapping is
enabled the drag starts after the tap timeout/motion so we can distinguish
between a tap and a drag.

When fingers are released:
- if two fingers remain -> keep dragging
- if one finger remains -> release drag, switch to pointer motion

When 3/4 fingers are set down immediately after releasing all fingers
the drag continues, similar to the tap drag lock feature. This drag lock
is not currently configurable.

This matches the macos behavior for the same feature.

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1042>
2025-02-18 06:44:01 +00:00
Kirill Primak
00bc910df7 tablet: add missing event types in tool/pad event docs
Signed-off-by: Kirill Primak <vyivel@eclair.cafe>
Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1126>
2025-01-20 10:08:36 +00:00
Peter Hutterer
cf5b7bee01 Add tablet area configuration
This adds the configuration option to define a rectangle that serves as
an input area on external tablets such as an Intuos.

The intention behind this is to make this input area behave as if it was
the only physical input area on this tablet with libinput emulating
proximity events as required for where the tools moves in and out
of this area.

This could also be achieved with the existing calibration setting but
area configuration is not calibration and we don't want to expose other
side-effects of the matrix (e.g. scaling and rotation) for these
devices.

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1013>
2024-11-05 12:10:48 +10:00
Peter Hutterer
41b3f5cc29 doc/api: fix wrong references to the tap drag config
It's _tap_get_drag_, not _tap_drag_get_ (and same for set/get_default)

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1039>
2024-09-06 04:23:19 +00:00
satrmb
910d59e836 touchpad: add sticky mode to drag-lock
Sticky mode removes the timeout from drag-lock, only a tap ends a drag.
Timeout mode remains available without changes.

Sticky mode is exposed as a new value for the existing drag-lock setting.

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1037>
2024-09-05 00:47:47 +00:00
Nicolas Fella
951ab12afe Fix typo in documentation comment
Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1024>
2024-07-03 15:13:58 +02:00
Peter Hutterer
97284211d4 doc/api: link to a few tablet configuration settings
We have a rough grouping of config options per device type, let's add
the tablet ones there too.

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1012>
2024-06-13 04:21:26 +00:00
Peter Hutterer
9267147ebd Fix @since tags for the pressure range configuration
Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1008>
2024-06-07 10:49:13 +10:00
Julian Orth
857780ede7 Ring positions increase clockwise
Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/994>
2024-04-29 15:06:13 +00:00
Martin Rys
7c91e3539c Add definitions for LIBINPUT_LED_COMPOSE and LIBINPUT_LED_KANA
Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/990>
2024-04-28 23:59:14 +00:00
Tarcísio Eduardo Moreira Crocomo
955158f982 fix: unnecessary braces and mistake in doc
Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/988>
2024-04-09 23:40:34 -03:00
Tarcísio Eduardo Moreira Crocomo
46d1fff0b0 touchpad: add clickfinger button map
Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/988>
2024-04-09 19:08:17 -03:00
José Expósito
a43f1edbfe Add libinput_device_get_id_bustype()
Allow to get the device bus type ID in addition to its vid and pid.

Closes: https://gitlab.freedesktop.org/libinput/libinput/-/issues/975
Signed-off-by: José Expósito <jose.exposito89@gmail.com>
Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/977>
2024-02-28 22:49:29 +00:00
Joshua Goins
beca998122 tablet: add API for relative dials
Some tablets such as those in the XP-PEN PRO series use "dials" which
are actually scrollwheels and emit EV_REL events. These should not be
emulated as rings (which are absolute) so we must expose them as a new
tablet event.

Adds LIBINPUT_EVENT_TABLET_PAD_DIAL that work largely identical as our
high-resolution wheel events (i.e. the values are in multiples or
fractions of of 120). Currently supports two dials.

This is a lot of copy/paste from the ring axes because the interface is
virtually identical. The main difference is that dials give us a v120
value in the same manner as our scroll axes.

Notes:
- REL_DIAL is mutually exclusive with REL_WHEEL, we assume the kernel
  doesn't (at this point) give us devices with both. If this changes for
  devices with three dials (wheel + hwheel + dial) we need to add code
  for that.
- REL_DIAL does not have a high-resolution axis and we assume that any
  device with REL_WHEEL_HI_RES will also have REL_HWHEEL_HI_RES (if the
  second wheel exists).
- With dials being REL_DIAL or REL_WHEEL there is no possibility of
  detecting a finger release (the kernel does not route EV_RELs with a
  value of zero). Unless this is implemented via a side-channel - and it
  doesn't look like any hardware that supports dials does that - we
  cannot forward any information here. So unlike absolute rings we
  cannot provide a source information here.

Closes #600

Co-authored-by: Peter Hutterer <peter.hutterer@who-t.net>
Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/967>
2024-02-20 02:49:05 +00:00
Peter Hutterer
4bc27543e9 tablet: add tablet tool pressure range configuration
Add a configuration option to reduce the available hardware range to a
fraction thereof. This is done by copying the absinfo struct for the
pressure value and adjusting that copy's minimum/maximum value for
scaling into the target normalized range.

The 1%/5% tip thresholds are kept but pressure offset detection is
disabled if there is a custom pressure range.

Unlike the pressure curve which is implemented in the compositor, the
pressure min/max range needs to be in libinput, primarily because the
tip threshold needs to adjust to any new minimum, allowing for
light touches with a pen without triggering tip down even at a higher
hardware pressure.
2024-01-30 14:29:25 +10:00
Llerraf Gnem
38fdfd1dfe
docs: fix "See also" link in libinput_config_accel_profile
Used to be to libinput_device_config_accel_set_points, corrected to
libinput_config_accel_set_points
2023-07-26 11:41:34 -05:00
José Expósito
f8497bf176 doc: document libinput_device_tablet_pad_get_* error case
Like in libinput_device_switch_has_switch()'s documentation, document
the error case in libinput_device_tablet_pad_get_num_buttons(),
libinput_device_tablet_pad_get_num_rings() and
libinput_device_tablet_pad_get_num_strips().

Signed-off-by: José Expósito <jose.exposito89@gmail.com>
2023-03-25 19:33:05 +01:00
Yinon Burgansky
93135c2012 filter: add scroll movement type to the custom acceleration profile
Adds a dedicated scroll movement type to the custom acceleration profile.
Supported by physical mouse and touchpad.
Other profiles remain the same by using the same unaccelerated filter for the scroll filter.

Signed-off-by: Yinon Burgansky <51504-Yinon@users.noreply.gitlab.freedesktop.org>
2023-02-24 13:01:34 +02:00
Yinon Burgansky
5324f425a1 Introduce custom acceleration profile
The custom acceleration profile allow the user to define custom
acceleration functions for each movement type per device, giving
full control over accelerations behavior at different speeds.

This commit introduces 2 movement types which corresponds to the
2 profiles currently in use by libinput.

regular filter is Motion type.
constant filter is Fallback type.

This allows possible expansion of new movement types for the
different devices.

The custom pointer acceleration profile gives the user full control over the
acceleration behavior at different speeds.
The user needs to provide a custom acceleration function f(x) where
the x-axis is the device speed and the y-axis is the pointer speed.

The user should take into account the native device dpi and screen dpi in
order to achieve the desired behavior/feel of the acceleration.

The custom acceleration function is defined using n points which are spaced
uniformly along the x-axis, starting from 0 and continuing in constant steps.
There by the points defining the custom function are:
(0 * step, f[0]), (1 * step, f[1]), ..., ((n-1) * step, f[n-1])
where f is a list of n unitless values defining the acceleration
factor for each velocity.
When a velocity value does not lie exactly on those points, a linear
interpolation of the two closest points will be calculated.
When a velocity value is greater than the max point defined, a linear
extrapolation of the two biggest points will be calculated.

Signed-off-by: Yinon Burgansky <51504-Yinon@users.noreply.gitlab.freedesktop.org>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2023-01-17 01:46:17 +00:00
Lucas Zampieri
fb8d285566 Allow rotation on all mice and for any angle
Previously we restricted rotation to trackballs only and to multiples 
of 90 degrees. Update rotation allow angles other than multiples of 90.

Also enable rotation on all mice. The only devices without rotation
are now pointing sticks.

Fixes #827

Signed-off-by: Lucas Zampieri <lzampier@redhat.com>
2022-12-05 22:57:51 +00:00
pudiva chip líquida
1f1ddbc6df touchpad: new option dwtp (disable-while-trackpointing)
Add option to control whether the touchpad should be disabled while the
trackpoint is in use.

Fix #731

Signed-off-by: pudiva chip líquida <pudiva@skylittlesystem.org>
2022-03-08 01:33:40 +00:00
José Expósito
5f966dc6c6 doc: guarantee end sequence for continuous scroll
GTK handles LIBINPUT_EVENT_POINTER_SCROLL_CONTINUOUS as
GDK_SCROLL_SMOOTH, the same event type that is used to handle
LIBINPUT_EVENT_POINTER_SCROLL_FINGER.

Because Mutter and other compositors, like wlroots based compositors,
translate libinput terminating event to axis_stop instead of doing their
own emulation, if libinput stops sending terminating events, it will
cause client bugs.

Since libinput always sends the terminating event for trackpoints and
button scrolling and there are even tests in place to check for them,
update the documentation to guarantee the terminating scroll sequence.

Signed-off-by: José Expósito <jose.exposito89@gmail.com>
2021-09-19 21:32:59 +02:00
Peter Hutterer
6bb02aaf30 High-resolution scroll wheel support
Starting with kernel v5.0 two new axes are available for high-resolution wheel
scrolling: REL_WHEEL_HI_RES and REL_HWHEEL_HI_RES. Both axes send data in
fractions of 120 where each multiple of 120 amounts to one logical scroll
event. Fractions of 120 indicate a wheel movement less than one detent.

This commit adds a new API for scroll events. Three new event types that encode
the axis source in the event type name and a new API to get a normalized-to-120
value that also used by Windows and the kernel (each multiple of 120 represents
a logical scroll click).

This addresses a main shortcoming with the existing API - it was unreliable to
calculate the click angle based on the axis value+discrete events and thus any
caller using the axis value alone would be left with some ambiguity. With the
v120 API it's now possible to (usually) calculate the click angle, but more
importantly it provides the simplest hw-independent way of scrolling by a
click or a fraction of a click.

A new event type is required, the only way to integrate the v120 value
otherwise was to start sending events with a discrete value of 0. This
would break existing xf86-input-libinput (divide by zero, fixed in 0.28.2) and
weston (general confusion). mutter, kwin are unaffected.

With the new API, the old POINTER_AXIS event are deprecated - callers should use
the new API where available and discard any POINTER_AXIS events.

Notable: REL_WHEEL/REL_HWHEEL are emulated by the kernel but there's no
guarantee that they'll come every accumulated 120 values, e.g. Logitech mice
often send events that don't add up to 120 per detent.

We use the kernel's wheel click emulation instead of doing our own.

libinput guarantees high-resolution events even on pre-5.0 kernels.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: José Expósito <jose.exposito89@gmail.com>
2021-08-31 08:45:01 +02:00
José Expósito
b6b15fa304 libinput: add hold gesture public API and tool support
Add hold gestures to the public API and the private functions to notify them.
Also add hold gestures to debug-events and debug-gui.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: José Expósito <jose.exposito89@gmail.com>
2021-06-09 01:18:58 +00:00
satrmb
0e569077fe touchpad: allow tap-and-drag for two-finger and three-finger taps
This commit duplicates the tap states responsible for tap-and drag (TAPPED
and all DRAGGING* states) to cover two-finger and three-finger taps;
the code for the new states is shared with the existing machinery for
one-finger tap-and-drag.

Signed-off-by: satrmb <10471-satrmb@users.noreply.gitlab.freedesktop.org>
2020-09-25 06:01:28 +00:00
Peter Hutterer
9f8b9f5f53 doc: fix a wrongly named parameter
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-09-04 09:54:49 +10:00
Rosen Penev
cd71a73d62
[clang-tidy] fix inconsistent declarations
Found with readability-inconsistent-declaration-parameter-name

Signed-off-by: Rosen Penev <rosenp@gmail.com>
2020-08-27 01:00:31 -07:00
Peter Hutterer
4ff6d6e317 Deprecate wheel tilt as separate axis source
This has never been supported through the stack. No device ever had the
required MOUSE_WHEEL_TILT_VERTICAL/HORIZONTAL udev property set, so
libinput never set the right axis source. Neither weston nor mutter
added the code for it. Even if we added wheel tilt for devices now, it
would break those devices. And the benefit we get from having those
separate is miniscule at best.

So let's do the long-term thing and just deprecate this axis source.

The wheel tilt mouse test device remains in the test suite, with the
udev properties set just to verify that we do indeed ignore those now.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-05-21 07:29:44 +00:00
Peter Hutterer
2d1bcf982a pad: add LIBINPUT_EVENT_TABLET_PAD_KEY for pad keys
The Wacom Cintiq 24HD and later tablets send specific key events for
hardware/soft buttons. KEY_PROG1..KEY_PROG3 on earlier tablets,
KEY_CONTROLPANEL, KEY_ONSCREEN_DISPLAY, and KEY_BUTTONCONFIG on later tablets.
We ignore KEY_PROG1-3 because starting with kernel 5.4 older tablets will too
use the better-named #defines.

These differ from pad buttons as the key code in itself carries semantic
information, so we should pass them on as-is instead of mapping them to
meaningless 0-indexed buttons like we do on the other buttons.

So let's add a new event, LIBINPUT_EVENT_TABLET_PAD_KEY and the associated
functions to handle that case.

Pad keys have a fixed hw-defined semantic meaning and are thus not part of
a tablet mode group.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-12-04 15:38:39 +10:00
Peter Hutterer
63f9923013 Add a scroll button lock feature
Scroll button locking is an accessibility feature. When enabled, the scroll
button does not need to be held down, the first click holds it logically down,
to be released on the second click of that same button.

This is implemented as simple event filter, so we still get the same behavior
from the emulated logical button, i.e. a physical double click results in a
single logical click of that button provided no scrolling was triggered.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-10-17 12:21:41 +10:00
Aleix Pol
c20d08ac23 LIBINPUT_EVENT_TABLET_BUTTON doesn't exist, use LIBINPUT_EVENT_TABLET_PAD_BUTTON 2019-10-11 02:37:39 +02:00
Peter Hutterer
b38722317c doc: update reference to the event codes header
The codes have been in input-event-codes.h for quite a few releases now.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-09-25 15:16:45 +10:00
Peter Hutterer
17d792445e tablet: add a the Totem tool type to the tablet interface
This is the public API only, not the internal bits, so nothing will work just
yet.

This interface addition is for the Dell Canvas Totem tool, so let's go with
the same name because options like "Rotary" are too ambiguous.

The totem is a knob that can be placed on the surface, it provides us with
location and rotation data. The touch major/minor fields are filled in by the
current totem, but they're always the same size.

The totem exports BTN_0 as well, so let's add that to the debug-events output.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-06-07 01:03:21 +00:00
Peter Hutterer
4bb2899d00 doc/api: add since tags to all functions after 1.0
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-04-03 09:29:32 +10:00
Peter Hutterer
5d7c93a3d1 doc/api: improve readability of the API docs
Still not great and probably makes any professional designer's eyes bleed, but
at least it's more readable now.

Changes:
- spacing after param name so they don't cuddle up with the description
- color changes and background image removals to drop the doxygen default look
- font size changes to not make things overrun
- font family change to make the function prototypes readable

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-03-27 16:01:10 +10:00
Peter Hutterer
c9728d8403 doc: add missing @ref
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-01-17 12:32:48 +10:00
Peter Hutterer
029c0b199a doc: correct a slightly ambiguous @ref wording
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-01-17 12:32:48 +10:00
Peter Hutterer
a60b5b0f8f doc: fix doxygen references for libinput_get_user_data
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-01-03 12:03:39 +10:00
Peter Hutterer
6304dc1b19 doc/user: more documentation cleanups and fixes
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-08-01 10:07:28 +10:00
Peter Hutterer
e83b1314ba doc: refer to "the libinput documentation" in a few @see cases
This is in preparation for a change to sphinx as the user-visible
documentation. Ideally we could cross-link between the two but that's tricky
to do automatically. Linking to the html pages/anchors directly works fine but
risks the links going stale, especially while the documentation is still in
flux.

Having a generic "refer to the libinput documentation" is a bit of a cop-out
least this way the links cannot go stale.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-07-27 17:24:40 +10:00
Peter Hutterer
fbb66279cc doc: drop a few unnecessary @ref
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-07-27 17:24:02 +10:00
Peter Hutterer
1ac235c792 doc: copy some bits of the tablet docs to doxygen
So it shows up in the doxygen contents. These are the bits that are mostly of
interest to developers, we might remove the user documentation entry later,
but let's leave it there for now.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-07-27 17:24:02 +10:00
Peter Hutterer
33162632cb Revert "Expose a custom acceleration profile"
This looked good on paper but clearly no-one (including myself) ever tested this
in a real-life situation or they would've noticed that the constant factor is
missing, causing a segfault on the first two-finger scroll event, touchpad
gesture or button scrolling.

Adding the constant factor makes the API much worse and the benefit is
unclear, so out of the window it goes. We can revisit this for libinput 1.12
but this isn't going to make the next release.

This reverts commit d8bd650540.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-05-21 12:15:25 +10:00
Peter Hutterer
4277d63bc6 Merge branch 'wip/custom-pointer-acceleration-function-v2' 2018-05-02 10:53:08 +10:00