Commit graph

2420 commits

Author SHA1 Message Date
Peter Hutterer
7ae4fabb76 pad: don't clobber the errno if the pad led failed to initialize
pad_led_destroy() may call something that sets errno, so let's protect
against that.

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1070>
2024-10-31 10:28:08 +10:00
Peter Hutterer
181c667266 pad: remove an unused argument
Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1070>
2024-10-31 10:28:08 +10:00
Peter Hutterer
c969b5f6e2 pad: rename an argument for more clarity
Yes, we're using the LED count here but what it is used for is the
number of modes.

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1070>
2024-10-31 10:28:08 +10:00
Peter Hutterer
4fa5ea268e util: add a generic stringbuffer with a few helper functions
Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1067>
2024-10-30 23:20:42 +00:00
Peter Hutterer
817dc42381 util: add the range handling as separate header file
Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1067>
2024-10-30 23:20:42 +00:00
Peter Hutterer
f91f0a7ea5 util: add a bunch more time conversions
Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1067>
2024-10-30 23:20:42 +00:00
Peter Hutterer
02f5faf6f6 util: move libinput_now() into a utility function
Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1067>
2024-10-30 23:20:42 +00:00
Peter Hutterer
d3922661ba util: add xclose(fd) to close-and-reset an fd
This prevents accidentally leaving the fd set after closing.

And it includes the -1 check so we don't need this everywhere ourselves
(not that we use it right now but valgrind likes to complain about
this).

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1067>
2024-10-30 23:20:42 +00:00
Peter Hutterer
5e235a6546 util: make a float to int conversion explicit
Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1071>
2024-10-29 10:18:54 +10:00
Peter Hutterer
e0f671126d util: add the backtrace printing function as separate util
Might as well make this easier to re-use since it doesn't do anything
specific to litest.

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1066>
2024-10-23 10:08:12 +10:00
Peter Hutterer
4546480e13 pad: default a pad group to mode 0 if all LEDs are off
Since our API doesn't accomodate for "dunno" we need to pick a mode that
we are actually in. This happens on the Intuos Pro 2 (PTH-660) which has
all LEDs on brightness zero, resulting in a failure to set up the modes
and we're left without a mode button.

Fix it by just picking zero as the default mode until specified
otherwise.

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1069>
2024-10-22 18:14:15 +00:00
Peter Hutterer
04cff1c721 pad: move a function to save on an ifdef
Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1069>
2024-10-22 18:14:15 +00:00
Peter Hutterer
0c782c4084 pad: don't print a clobbered errno
is_litest_device() may change errno since it calls into libudev.

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1069>
2024-10-22 18:14:15 +00:00
Peter Hutterer
3390f2e647 test: make the TEST_COLLECTION() macro re-usable in the same file
Concat the line number to the generated variable names, this way we can
have more than one TEST_COLLECTION() in the same file.

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1065>
2024-10-18 10:49:47 +10:00
Peter Hutterer
5f744c8928 tablet: fix a memory leak caused by an early return
Previously we'd return early, failing to libwacom_destroy() the device.

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1064>
2024-10-18 09:48:05 +10:00
Peter Hutterer
2b77bdab5c gestures: change a boolean to an enum for more expressive code
Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1049>
2024-10-04 15:13:23 +10:00
Peter Hutterer
0fd074c974 gestures: add debugging for state transitions
Our state machine allows falling through multiple transitions, so let's
make it possible to debug this.

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1049>
2024-10-04 15:13:23 +10:00
Peter Hutterer
68a2ff0d49 gestures: get rid of tp_gestures_start
Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1049>
2024-10-04 15:13:23 +10:00
Peter Hutterer
89596e61f8 gestures: rename gesture_notify_hold to gesture_notify_hold_begin()
HOLD gestures only have begin/end so let's rename this so it's
immediately obvious which one we're sending.

notify_swipe/pinch pass the event type in so it's clear that it's a
BEGIN vs an UPDATE.

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1049>
2024-10-04 15:13:23 +10:00
Peter Hutterer
8899800de8 gestures: rename most events to FOO_START
These events aren't used to signal scroll/swipe/pinch/..., merely to
signal the start of that gesture. So let's rename it to make the code
clearer (e.g. why do we log a bug when for a FOO event when we're in
state FOO?).

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1049>
2024-10-04 15:13:23 +10:00
Peter Hutterer
e88007d4ae gestures: push tp_gesture_start() for hold gestures into the state handling
Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1049>
2024-10-04 15:13:23 +10:00
Peter Hutterer
fd0875029b gestures: push tp_gesture_end() into the actual state machine
Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1049>
2024-10-04 15:13:23 +10:00
Peter Hutterer
c1690d408a gestures: log a bug if we're trying to reset an actual gesture
Now that end/cancel are separate states, we shouldn't get here.

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1049>
2024-10-04 15:13:23 +10:00
Peter Hutterer
942fd0dc8f gestures: distinguish between a gesture reset and a gesture end/cancel
All current states treat them the same way but let's distinguish those
two so we can have different code depending on whether a gesture was
cancelled/reset or ended properly.

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1049>
2024-10-04 15:13:23 +10:00
Peter Hutterer
96500d81fb gestures: replace switch-timeout based gesture_cancel calls with a state
Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1049>
2024-10-04 15:13:23 +10:00
Peter Hutterer
6b5aeab51e gestures: rename tp_gesture_handle_state and tp_gesture_post_gesture
Confusingly, tp_gesture_handle_state() would do almost nothing with our
state machine and the various tp_gesture_handle_state_foo() were called
later from tp_gesture_post_gesture().

Rename those functions into so that we have
tp_gesture_update_finger_state() first followed by
tp_gesture_handle_state() which is responsible for dealing with the
state machine.

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1049>
2024-10-04 15:13:23 +10:00
Peter Hutterer
c9c128f2b1 gestures: make a error message more informative
Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1049>
2024-10-04 15:13:23 +10:00
Peter Hutterer
1d4e2e2e2d gestures: log the finger count together with the gesture state
Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1049>
2024-10-04 15:13:23 +10:00
Peter Hutterer
54dccd66d1 Fix a few potential NULL dereferences
Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1052>
2024-09-30 15:35:36 +00:00
Peter Hutterer
1790171c76 util: add a safe version of strlen
Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1052>
2024-09-30 15:35:36 +00:00
Peter Hutterer
b1b3692e08 gestures: use a colon-suffixed debug prefix like the other state machines
Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1048>
2024-09-12 15:24:45 +10:00
Peter Hutterer
e8495b8d36 gestures: cancel the hold before initializing the pinch
If we're in state HOLD we have an ongoing hold gesture - make sure we
cancel that one first before we initialize the pinch.

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1046>
2024-09-11 09:38:29 +00: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
Peter Hutterer
f159abdc57 quirks: allow for parsing multiple products
This allows for a slight optimization of the quirks parser: where
multiple devices from the same vendor require the same quirk, allow
for multiple product matches in the form:

MatchProduct=0x0001;0x0002;

This is stored as a fixed-sized zero-terminated array - a product ID of
zero isn't something we need to worry about in real situations.

Closes #879

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1038>
2024-09-05 13:54:07 +00:00
Peter Hutterer
ea7ad8d25c util: add a strv_for_each helper function
Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1038>
2024-09-05 13:54:07 +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
Jason Gerecke
66106b9746 tablet: Remove unnecessary scale factor on REL_HWHEEL_HI_RES
The two high-res axes should already be scaled appropriately by the
kernel. This unnecessary scale factor causes 1 click of the dial to
produce an event delta of +-14400 rather than the expected +-120.

Fixes: beca998122 ("tablet: add API for relative dials")
Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1029>
2024-07-29 22:46:57 +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
6fee92c959 pad: switch the REL_WHEEL direction to match dials with scroll wheels
REL_WHEEL sends -1 for "down" and +1 for "up", so let's make sure we
keep that correct here too.

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1021>
2024-06-21 10:02:07 +10:00
Peter Hutterer
978676be1e tablet: allow calibration if libwacom says our tablet is a display tablet
Not all display tablets have INPUT_PROP_DIRECT SET (looking at you,
Huion Kamvas 12) so our calibration went nowhere. Let libwacom override
whatever the kernel says.

This also makes testing without matching hardware a bit easier now since
we only need to override the libwacom file, not the whole device.

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1019>
2024-06-19 12:37:44 +10:00
Peter Hutterer
41a4b128e9 tablet: rework a helper function to be more reusable
This allows us to look more things up from libwacom in one go.

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1019>
2024-06-19 12:37:44 +10:00
Peter Hutterer
8326f71df5 touchpad: special-case shift as modifier for dwt
We ignore modifiers for disable-while-typing because we don't want to
disable the touchpad for things like shift-click or ctrl-click.

We also do remember the modifier state so that we don't disable the
touchpad for once-offs like ctrl+s.

Shift is however a special case - shift + something else is means the
user is typing and we should disable the touchpad for that.

Closes #1005

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1015>
2024-06-17 08:31:25 +00:00
Peter Hutterer
78cb25c2f7 Whitespace fix
Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1012>
2024-06-13 04:21:26 +00: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
Peter Hutterer
a2f0cc35c5 quirks: add support for Uniq matching
Same as MatchName but matches on the UNIQ udev property instead. This
is needed for some Huion, Gaomon and other tablet devices that only
differentiate each other through the Uniq string which contains the
firmware version.

Closes #997

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1006>
2024-06-05 11:35:59 +00:00
Peter Hutterer
fe3175748a evdev: don't return a size for 0-1 axes
Tablet pads historically need to have ABS_X/Y to be detected as tablets
but their min/max values are 0 and 1. Let's not return a size for those.

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1004>
2024-05-27 14:51:23 +10:00
José Expósito
a2515fc3f6 evdev: log the right mouse wheel angle
Signed-off-by: José Expósito <jose.exposito89@gmail.com>
Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1002>
2024-05-18 18:55:29 +02: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