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: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1339>
This commit is contained in:
Peter Hutterer 2025-10-23 09:59:56 +10:00 committed by Marge Bot
parent dd3f931481
commit d6e1f93812
4 changed files with 9 additions and 9 deletions

View file

@ -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 {}

View file

@ -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

View file

@ -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

View file

@ -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)