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
428a3299a8 plugin: don't initialize the debounce plugin on a virtual device
Effectively the same motivation as commit 5d23794d53 ("tablet: disable
smoothing for uinput devices") - virtual devices should not need
debouncing and if they do let's do the debouncing on the other end that
creates those devices.

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1307>
2025-08-28 01:56:12 +00:00
Peter Hutterer
4d317eae17 plugin: reset the filtered frame after sending it with buttons
Our filtered frame (frame without any button events) that gets passed
down to here may include relative motion or other events. Once we use
that frame to prepend the button event we need to reset it so we don't
cause duplicate motion and/or events with zero delta timestamps.

With the the previous code we got two identical frames:

  42: event25: plugin button-debounce        - 0.360 EV_MSC           MSC_SCAN               30
  ... event25: plugin button-debounce        - 0.360 EV_KEY           BTN_RIGHT               1
  ... event25: plugin button-debounce        - 0.360 EV_REL           REL_X                  -7
  ... event25: plugin button-debounce        - 0.360 EV_REL           REL_Y                  -7
  ... event25: plugin button-debounce        - 0.360 ----------------- EV_SYN ----------------- +8ms
  ... Plugin:button-debounce - debounce state: DEBOUNCE_STATE_IS_UP → DEBOUNCE_EVENT_OTHERBUTTON → DEBOUNCE_STATE_IS_UP
  ... Plugin:button-debounce - debounce state: DEBOUNCE_STATE_IS_UP → DEBOUNCE_EVENT_PRESS → DEBOUNCE_STATE_IS_DOWN_WAITING
  ... event25: plugin evdev                  - 0.360 EV_MSC           MSC_SCAN               30
  ... event25: plugin evdev                  - 0.360 EV_REL           REL_X                  -7
  ... event25: plugin evdev                  - 0.360 EV_REL           REL_Y                  -7
  ... event25: plugin evdev                  - 0.360 EV_KEY           BTN_RIGHT               1
  ... event25: plugin evdev                  - 0.360 ----------------- EV_SYN ----------------- +0ms
  ... Queuing  event25  POINTER_MOTION               +0.000s	-7.00/ -7.00 ( -7.00/ -7.00)
  ... event25 - middlebutton state: MIDDLEBUTTON_IDLE → MIDDLEBUTTON_EVENT_R_DOWN → MIDDLEBUTTON_RIGHT_DOWN, rc 1
  ... event25: plugin evdev                  - 0.360 EV_MSC           MSC_SCAN               30
  ... event25: plugin evdev                  - 0.360 EV_REL           REL_X                  -7
  ... event25: plugin evdev                  - 0.360 EV_REL           REL_Y                  -7
  ... event25: plugin evdev                  - 0.360 EV_KEY           BTN_RIGHT               1
  ... event25: plugin evdev                  - 0.360 ----------------- EV_SYN ----------------- +0ms
  ... Queuing  event25  POINTER_MOTION               +0.000s	 -nan/  -nan ( -7.00/ -7.00)
 event25  POINTER_MOTION               +0.360s	-7.00/ -7.00 ( -7.00/ -7.00)
 event25  POINTER_MOTION            2  +0.360s	 -nan/  -nan ( -7.00/ -7.00)

The 0ms delta caused a -nan in the custom pointer accel but even without
that bug the pointer would've jumped more than it should.

Closes #1172

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1301>
2025-08-20 07:49:01 +00:00
Peter Hutterer
b2cd9c69a0 plugin: remove the event frame callbacks when disabling a plugin
In all cases we remove the device's handling from the plugin so let's
remove the event frame callback for this device.

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1300>
2025-08-19 15:22:49 +10:00
Peter Hutterer
cf52552eef plugin: allow disabling the button debouncing feature
Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1249>
2025-08-07 10:21:59 +10:00
Peter Hutterer
4f0b82800a plugins: remove two unused cleanup functions
Let's make clang tidy happy so at least one of us is.

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1292>
2025-08-06 07:34:55 +00:00
Peter Hutterer
d1dbbb7328 plugin: register plugins for the plugin-specific usages
The debounce, wheel/wheel-low-res, double-tool and eraser-button plugins can limit
themselves to a specific usage.

The mtdev plugin needs to pass each each event to mtdev and the proximity
timer plugin needs to get each event's timestamp so they cannot be
restricted.

The forced-tool could be restricted but effectively any event on the
devices it works on will have one of those usages set so there's no
point.

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1271>
2025-08-01 14:29:44 +10:00
Peter Hutterer
892e5d35c7 plugin: use evdev_frame_append_one() for simpler code
Instead of creating a struct and passing it in as array let's use the
helper function.

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1260>
2025-07-08 04:02:50 +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
2c6fa261a3 evdev: replace the debounce handler with a plugin
Same functionality but run as a plugin on the evdev stream instead.

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1230>
2025-06-24 12:01:51 +10:00