Commit graph

10 commits

Author SHA1 Message Date
Peter Hutterer
a202ed6115 Use a newtype usec_t for timestamps for better type-safety
This avoids mixing up milliseconds and usec, both by failing if
we're providing just a number somewhere we expect usecs and also
by making the API blindingly obvious that we're in usecs now.

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1373>
2025-12-12 04:15:15 +00:00
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
41e988c99e Introduce our own evdev_event struct
In addition to the evdev_frame this struct is what contains our actual
events instead of a struct input_event. The goal of this is twofold:
slightly better memory usage per frame since we can skip the timestamp
and refer to the evdev frame's timestamp only. This also improves
handling a frame since we no longer need to care about updating
all events when the timestamp changes during appending events.

Secondly it merges the evdev type + code into a single "usage"
(term obviously and shamelessly stolen from HID). Those usages
are the same as the code names but with an extra EVDEV_ prepended,
i.e.  EV_SYN / SYN_REPORT becomes EVDEV_SYN_REPORT.

And they are wrapped in a newtype so passing it around provides
some typesafety.

This only switches one part of the processing over, the dispatch
interfaces still use a struct input_event

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1215>
2025-06-12 18:20:40 +10:00
Peter Hutterer
9f00f77bc4 Add an evdev_frame wrapper struct
The kernel only ever gives us a frame of events in one go (it flushes on
SYN_REPORT). We then need to look at that frame as a single state change
(keyboards excepted for historical reasons) so let's push this into a
proper struct we can pass around.

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1215>
2025-06-12 18:20:40 +10:00
Peter Hutterer
cfbdca5953 Move evdev_convert_to_mm to a more generic helper
Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1013>
2024-11-05 12:05:05 +10:00
Peter Hutterer
df242c108d Move scale_axis to a utility header so we can re-use it better
Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1013>
2024-11-05 12:05:05 +10:00
Peter Hutterer
72eca2db56 util: add a helper to normalize an axis to [0.0, 1.0]
Like the input axis, a normalized range has min/max inclusive so we
cannot use the absinfo_range() helper which assumes the max is exclusive.

Reverts parts of 4effe6b1b9
2024-01-30 14:29:25 +10:00
Peter Hutterer
4effe6b1b9 evdev: add a helper macro for the absinfo range
The range is (max - min + 1) because the kernel range is inclusive min
and max. Let's fix that once and for all with a helper function.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2023-08-29 17:07:38 +00:00
Peter Hutterer
a5dd45e8ce Remove duplicate empty lines in our source
We only touch src and tools, imported headers from include are not ours
to change.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2022-11-25 10:08:20 +10:00
Peter Hutterer
5dc1a7ebd3 Adjust for 64bit time_t for 32bit architectures
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-11-26 15:11:44 +10:00