Commit graph

4456 commits

Author SHA1 Message Date
Peter Hutterer
0cdf459643 tools/record: get rid of indent push/pop, replace with fixed indents
Our file format is static enough that we don't need to use push/pop, we know
exactly which line is going where. So let's replace it with a static
indent instead.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-03-30 09:02:31 +10:00
Peter Hutterer
632eedadf5 tools/record: mark the iprintf function as printf
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-03-30 08:33:49 +10:00
Peter Hutterer
9011f91868 tools/record: switch the output file from an fd to a FILE*
This is prep work to be more consistent with the use of tempfile later for
individual devices.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-03-30 08:33:49 +10:00
Peter Hutterer
7f4df04d59 tools/record: deduplicate the device opening logic
With a new helper function strv_from_argv we can re-use the device opening
loop for all the use-cases we have.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-03-30 08:26:30 +10:00
Peter Hutterer
4da9349a91 tools/record: free the namelist when we're done
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-03-26 10:12:40 +10:00
Peter Hutterer
e511f96201 tools/record: localize a variable
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-03-26 10:12:40 +10:00
Peter Hutterer
8b822a84c4 tools/record: de-duplicate an error message
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-03-26 10:12:40 +10:00
Peter Hutterer
0828fdcea0 tools/record: factor out the output file collection
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-03-26 10:12:40 +10:00
JoseExposito
2babdba1d7 tools/code-formatting: Add EditorConfig file
EditorConfig helps maintain consistent coding styles for multiple developers
working on the same project across various editors and IDEs:
https://editorconfig.org/

Signed-off-by: José Expósito <jose.exposito89@gmail.com>
2021-03-19 08:37:02 +01:00
JoseExposito
cd4f2f32b5 fallback: disable mouse scroll wheel while middle button is pressed
Signed-off-by: José Expósito <jose.exposito89@gmail.com>
2021-03-17 03:23:56 +00:00
JoseExposito
0f79fe6677 fallback: replace fallback_dispatch->wheel with an anonymous struct
The current fallback_dispatch wheel struct, a device_coords, doesn't allow to
save extra information.
The new anonymous struct will allow to add a is_inhibited field to disable mouse
scroll while the middle button is pressed and, potentially, any required extra
state in the future.

Signed-off-by: José Expósito <jose.exposito89@gmail.com>
2021-03-17 03:23:56 +00:00
Greg V
06697b5e85 quirks: add wildcard to HID-over-I2C names (for FreeBSD)
The FreeBSD HID stack adds the device type to the evdev name,
so we get e.g. "ACPI0C50:00 18D1:5028 TouchPad".

(Maybe this shouldn't be matched by name at all though...)

Signed-off-by: Greg V <greg@unrelenting.technology>
2021-03-17 02:34:30 +00:00
Greg V
6941f74070 quirks: implement DMI support on FreeBSD
FreeBSD does not use Linux modaliases, so we have to generate these strings.
Unfortunately for us, the data in kenv has the chassis type pre-parsed into
a nice string, so we have to match these strings back into numbers.
Only relevant types are included to avoid bloating the code.

Signed-off-by: Greg V <greg@unrelenting.technology>
2021-03-17 02:34:30 +00:00
Greg V
d8b1a773e3 quirks: add quirks for Apple SPI input devices
The Linux applespi driver currently uses the Synaptics vendor ID
on the trackpad for some reason (even though, at least from bcm5974
we only know that Broadcom is involved..) but my upcoming FreeBSD driver
uses the Apple vendor ID everywhere, so add two quirks.

Signed-off-by: Greg V <greg@unrelenting.technology>
2021-03-17 02:34:30 +00:00
Greg V
5f00c32d9e quirks: recognize SPI bus
Apple MacBooks (Broadwell/Skylake/Kaby Lake and Apple Silicon)
use SPI to communicate with the keyboard and trackpad.

Signed-off-by: Greg V <greg@unrelenting.technology>
2021-03-17 02:34:30 +00:00
Peter Hutterer
83b3670c9a tests: add a gesture test to ensure our unaccel deltas are in a sane range
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-03-16 21:29:56 +00:00
Alexander Mikhaylenko
60d5172e15 gestures: Filter unaccelerated deltas for gestures
Make sure the unaccelerated deltas are comparable to scroll deltas.

edit by whot:
The original intention of the unaccelerated motion data here was to provide
both accelerated and unaccelerated motion for gestures so it was possible to
have 1:1 mapping from gesture motion to screen activity.

Normalizing to 1000dpi this way would've worked for mice but touchpad
acceleration also includes the TP_MAGIC_SLOWDOWN (amongst other tricks) which
slows down motion to around 27% *before* applying the acceleration function.
On a 1000dpi touchpad (~40 units/mm) simply normalizing touchpad motion to
1000dpi results in pointer motion that is way too fast, it's lacking that
slowdown to 27% of original speed.

This results in the accelerated and unaccelerated gesture data being in
effectively two different coordinate systems with the caller having no ability
to relate the two.

Switching to the special constant acceleration applies that slowdown and
matches the data to the part of the acceleration curve where no (additional)
acceleration is applied.

It makes the gesture unaccelerated data comparable to the accelerated data
and to scroll data which uses the same process.

Fixes #582

Signed-off-by: Alexander Mikhaylenko <alexm@gnome.org>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-03-16 21:29:56 +00:00
Peter Hutterer
1d9cdf76a5 test: push/pop event frames around three-touch movements
Without this, each finger movement happens in a different evdev event frame.
Since we average deltas for gestures, this messes with the expected data.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-03-16 21:29:56 +00:00
Peter Hutterer
dee0e5e725 test: simplify the helper for moving three touches at the same time
There's no test case where we need to do something immediately after the last
event so we might as well do everything in the same loop.

This also fixes a bug where the first movement would usually get swallowed.
Test cases in general put the finger down at x/y, then move them to some other
position. We'd expect the first event in a loop to happen at x+n/y+n, not at
x/y again.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-03-16 21:29:56 +00:00
Peter Hutterer
5129d178b3 test: fix debugging messages for gesture begin event
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-03-16 21:29:56 +00:00
Peter Hutterer
2f8dab4537 doc/user: explain why we are doing motion normalization
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-03-16 21:29:56 +00:00
Peter Hutterer
1d0dbd2461 filter: correct comments about the threshold's unit
See d6e5313497 for confirmation that the
threshold is intended to be in mm/s, the comment here is simply a leftover from
earlier times when the acceleration method was using device-units only.

Fixes #585

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-03-16 06:03:56 +00:00
Peter Hutterer
cbff56e6a2 test: update a few tests for more modern helpers
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-03-15 16:17:19 +10:00
Peter Hutterer
3427b457ce test: localize a few variables
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-03-15 16:15:57 +10:00
Peter Hutterer
42d6fed868 touchpad: always push a touch's current point to the motion history
The way touchpads (generally) work is that they get the position of each
finger on each scanout. The kernel filters touches that haven't moved to
reduce bandwidth so any touch that is logically down that we don't see an
update for is in the same position as during the last scanout.

Previously, touches that didn't sent events were effectively ignored, causing
our jump detection to fail:
- time t0: touch moves to position x/y, motion history time is set to t0
- time t1..t5: touch remains at position for several frames, no updates to the
  motion history
- time t6: touch jumps to position x+a/y+b
  - tp_detect_jumps() sees the last update time is t0 which is too long ago
    and exits without detecting a jump

This is fixed by pushing to the motion history any time we have *any* update -
if the touchpad notices a state change on any touch update all touches with
their current position, whether it changed or not.

This obsoletes the `time` field in the tp_touch struct, most of this patch is
passing down the current time to the few users of t->time.

Fixes #578

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-03-11 16:33:00 +10:00
Peter Hutterer
832c346b2b test: add a comment to the thumb speed test
Incorrect comment, the purpose of this test was to ensure that an unused slot
doesn't affect how other touches are treated, see commit 928bad9.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-03-11 16:32:59 +10:00
Peter Hutterer
31d20acdf6 test: fix two inadvertent pointer jumps in a test
Got papered over by bugs in the implementation and didn't trigger the jump
detection or movement detection otherwise.

Related to #578

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-03-11 16:32:59 +10:00
Peter Hutterer
39b64107e9 tools/debug-gui: draw a sprite for the unaccelerated pointer as well
Add a second grey v-shaped (upside down triangle) pointer that moves around
with the unaccelerated deltas. This makes it easier to visualize how the
unaccelerated pointer moves around, the snake helps for some use-cases but not
all of them.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-03-11 10:40:00 +10:00
Peter Hutterer
1926a66fab tools/debug-gui: move the abs pointer position into a struct point
No functional changes

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-03-11 10:40:00 +10:00
Peter Hutterer
e99f59422c tools/debug-gui: move the pointer position into a struct point
No functional change

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-03-11 10:40:00 +10:00
Peter Hutterer
c71fa06607 tools/debug-gui: start the unaccelerated motion deltas in the screen center
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-03-11 10:40:00 +10:00
Peter Hutterer
de70661213 util: document our list interface
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-03-10 03:48:21 +00:00
Peter Hutterer
f17ef2d543 tools/per-slot-delta: handle KeyboardInterrupts nicely
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-03-10 00:24:51 +00:00
Peter Hutterer
fe30bea36e tools/per-slot-delta: print the button state too while analyzing
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-03-10 00:24:51 +00:00
Peter Hutterer
40b83b1105 completion: add missing libinput analyze subtools to the zsh completions
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-03-10 09:54:07 +10:00
weizhixiang
c00c5cb691 replace strncmp with strneq for safety-check
Signed-off-by: weizhixiang <weizhixiang@uniontech.com>
2021-03-08 20:59:20 +00:00
Pedro Ribeiro
5e69c5f9ae Add Lenovo Legion 5 keyboard to 50-system-lenovo.quirks
Signed-off-by: Pedro Ribeiro <pedrib@gmail.com>
2021-03-02 23:07:48 +00:00
Konstantin Kharlamov
3d3d9b7f69 treewide: get rid of tmp argument in list_for_each_safe
Signed-off-by: Konstantin Kharlamov <Hi-Angel@yandex.ru>
2021-03-02 09:10:35 +03:00
Konstantin Kharlamov
3f2c483439 util-list.h: simplify code by removing an excess initialization
The assignment of zero is done to work around false-positives of
coverity about uninitialized variable usage. Getting rid of it inside
the macro will allow in later commit to declare a variable inside
`for-loop` rather than outside of it.

Do it by declaring a new list_first_entry_by_type helper which accepts a
type rather than a variable.

Signed-off-by: Konstantin Kharlamov <Hi-Angel@yandex.ru>
2021-03-02 09:07:42 +03:00
Peter Hutterer
9477d91d69 libinput 1.17.0
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-02-23 19:02:45 +10:00
Peter Hutterer
1b00eb5e03 tools/record: fix two coverity complaints
In both cases we only read to drain the fd, we don't care about the return
value.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-02-23 16:55:58 +10:00
Peter Hutterer
6a6435ae4b tools: add a tool to print a libinput recording as a table
This makes it easier to visualize changes in various axes or key states that
should not be there, doubly so for long recordings.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-02-23 13:46:00 +10:00
Peter Hutterer
9323cdfc11 meson.build: build libinput replay as well
Just like the other python-based tools it's just a basename copy, so let's be
consistent here and have all tools perform that way.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-02-23 13:30:42 +10:00
Peter Hutterer
627a3dd2b2 tools/record: use a helper function to get the next event for a device
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-02-23 10:56:53 +10:00
Peter Hutterer
4a7dece88c tools/record: switch record over to using epoll
Using poll means more difficult fd management, epoll (together with am
modified version of the libinput_sources) makes this a lot easier by simply
using dispatch.

This means we are no longer reliant on a specific file descriptor order in the
poll array.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-02-23 10:56:53 +10:00
Peter Hutterer
d8b64d413d tools/record: reword parts of the man page
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-02-23 10:56:53 +10:00
Peter Hutterer
ca9067992e tools/record: use safe_basename() to get to the hid report descriptor
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-02-23 10:56:53 +10:00
Peter Hutterer
671eb8cbbb utils: add a safe version of basename
So we don't need to worry about the libgen.h include game.
And we can switch trunkname over to that, making it a bit simpler.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-02-23 10:56:53 +10:00
Peter Hutterer
fd9d165a77 tools/record: simplify the behavior to emulate Python's join()
Instead of a boolean "is_first", just change the separator.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-02-23 10:56:53 +10:00
Peter Hutterer
ff87151764 tools/replay: Enter quits if there are no events
If we have no events in any of the recorded devices, state that this is the
case and make Enter simply quit instead of a pointless while loop.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-02-23 10:53:31 +10:00