From d6e1f93812d90eff07214a41a0c5e7684fea8778 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Thu, 23 Oct 2025 09:59:56 +1000 Subject: [PATCH] plugins: update plugins for the current API A few changes to the Lua API didn't get reflected in the example plugins, let's update them. Also included here is naming of all arguments, instead of _ use the argument name even where unused. These are examples so being expressive is more important than making any lua static checkers happy. Part-of: --- plugins/10-dwt.lua | 8 ++++---- plugins/10-logitech-mx-master-horiz-scroll.lua | 4 ++-- plugins/10-pointer-go-faster.lua | 4 ++-- plugins/10-pointer-go-slower.lua | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/plugins/10-dwt.lua b/plugins/10-dwt.lua index 79a3b584..7d81864c 100644 --- a/plugins/10-dwt.lua +++ b/plugins/10-dwt.lua @@ -13,15 +13,15 @@ tp_enabled = true -libinput:connect("timer-expired", function(_, now) +libinput:connect("timer-expired", function(now) log.debug("touchpad enabled") tp_enabled = true end) -libinput:connect("new-evdev-device", function (_, device) +libinput:connect("new-evdev-device", function (device) local props = device:udev_properties() if props.ID_INPUT_KEYBOARD then - device:connect("evdev-frame", function (_, _, _) + device:connect("evdev-frame", function (device, frame, timestamp) libinput:timer_set_relative(2000000) if tp_enabled then log.debug("touchpad disabled") @@ -30,7 +30,7 @@ libinput:connect("new-evdev-device", function (_, device) end) elseif props.ID_INPUT_TOUCHPAD then log.debug("Touchpad detected: " .. device:name()) - device:connect("evdev-frame", function (_, frame, _) + device:connect("evdev-frame", function (device, frame, timestamp) if not tp_enabled then -- Returning an empty table discards the event. return {} diff --git a/plugins/10-logitech-mx-master-horiz-scroll.lua b/plugins/10-logitech-mx-master-horiz-scroll.lua index d182d631..64a7ef34 100644 --- a/plugins/10-logitech-mx-master-horiz-scroll.lua +++ b/plugins/10-logitech-mx-master-horiz-scroll.lua @@ -17,10 +17,10 @@ -- -- UNCOMMENT THIS LINE TO ACTIVATE THE PLUGIN -- libinput:register({1}) -libinput:connect("new-evdev-device", function (_, device) +libinput:connect("new-evdev-device", function (device) local info = device:info() if info.vid == 0x046D and info.pid == 0xC548 then - device:connect("evdev-frame", function (_, frame, timestamp) + device:connect("evdev-frame", function (device, frame, timestamp) for _, event in ipairs(frame) do if event.usage == evdev.REL_HWHEEL or event.usage == evdev.REL_HWHEEL_HI_RES then event.value = -event.value diff --git a/plugins/10-pointer-go-faster.lua b/plugins/10-pointer-go-faster.lua index 23e8b4be..43082b03 100644 --- a/plugins/10-pointer-go-faster.lua +++ b/plugins/10-pointer-go-faster.lua @@ -6,10 +6,10 @@ -- -- UNCOMMENT THIS LINE TO ACTIVATE THE PLUGIN -- libinput:register({1}) -libinput:connect("new-evdev-device", function(_, device) +libinput:connect("new-evdev-device", function(device) local usages = device:usages() if usages[evdev.REL_X] then - device:connect("evdev-frame", function(_, frame, timestamp) + device:connect("evdev-frame", function(device, frame, timestamp) for _, v in ipairs(frame) do if v.usage == evdev.REL_X or v.usage == evdev.REL_Y then -- Multiply the relative motion by 3 diff --git a/plugins/10-pointer-go-slower.lua b/plugins/10-pointer-go-slower.lua index 56bdea2b..900d521e 100644 --- a/plugins/10-pointer-go-slower.lua +++ b/plugins/10-pointer-go-slower.lua @@ -39,7 +39,7 @@ libinput:connect("new-evdev-device", function(device) local usages = device:usages() if usages[evdev.REL_X] then remainders[device] = { x = 0.0, y = 0.0 } - device:connect("evdev-frame", function(_, frame, timestamp) + device:connect("evdev-frame", function(device, frame, timestamp) for _, v in ipairs(frame) do if v.usage == evdev.REL_X then v.value, _ = decelerate(device, v.value, 0.0)