mirror of
https://gitlab.freedesktop.org/libinput/libinput.git
synced 2025-12-20 06:50:05 +01:00
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:
parent
dd3f931481
commit
d6e1f93812
4 changed files with 9 additions and 9 deletions
|
|
@ -13,15 +13,15 @@
|
||||||
|
|
||||||
tp_enabled = true
|
tp_enabled = true
|
||||||
|
|
||||||
libinput:connect("timer-expired", function(_, now)
|
libinput:connect("timer-expired", function(now)
|
||||||
log.debug("touchpad enabled")
|
log.debug("touchpad enabled")
|
||||||
tp_enabled = true
|
tp_enabled = true
|
||||||
end)
|
end)
|
||||||
|
|
||||||
libinput:connect("new-evdev-device", function (_, device)
|
libinput:connect("new-evdev-device", function (device)
|
||||||
local props = device:udev_properties()
|
local props = device:udev_properties()
|
||||||
if props.ID_INPUT_KEYBOARD then
|
if props.ID_INPUT_KEYBOARD then
|
||||||
device:connect("evdev-frame", function (_, _, _)
|
device:connect("evdev-frame", function (device, frame, timestamp)
|
||||||
libinput:timer_set_relative(2000000)
|
libinput:timer_set_relative(2000000)
|
||||||
if tp_enabled then
|
if tp_enabled then
|
||||||
log.debug("touchpad disabled")
|
log.debug("touchpad disabled")
|
||||||
|
|
@ -30,7 +30,7 @@ libinput:connect("new-evdev-device", function (_, device)
|
||||||
end)
|
end)
|
||||||
elseif props.ID_INPUT_TOUCHPAD then
|
elseif props.ID_INPUT_TOUCHPAD then
|
||||||
log.debug("Touchpad detected: " .. device:name())
|
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
|
if not tp_enabled then
|
||||||
-- Returning an empty table discards the event.
|
-- Returning an empty table discards the event.
|
||||||
return {}
|
return {}
|
||||||
|
|
|
||||||
|
|
@ -17,10 +17,10 @@
|
||||||
--
|
--
|
||||||
-- UNCOMMENT THIS LINE TO ACTIVATE THE PLUGIN
|
-- UNCOMMENT THIS LINE TO ACTIVATE THE PLUGIN
|
||||||
-- libinput:register({1})
|
-- libinput:register({1})
|
||||||
libinput:connect("new-evdev-device", function (_, device)
|
libinput:connect("new-evdev-device", function (device)
|
||||||
local info = device:info()
|
local info = device:info()
|
||||||
if info.vid == 0x046D and info.pid == 0xC548 then
|
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
|
for _, event in ipairs(frame) do
|
||||||
if event.usage == evdev.REL_HWHEEL or event.usage == evdev.REL_HWHEEL_HI_RES then
|
if event.usage == evdev.REL_HWHEEL or event.usage == evdev.REL_HWHEEL_HI_RES then
|
||||||
event.value = -event.value
|
event.value = -event.value
|
||||||
|
|
|
||||||
|
|
@ -6,10 +6,10 @@
|
||||||
--
|
--
|
||||||
-- UNCOMMENT THIS LINE TO ACTIVATE THE PLUGIN
|
-- UNCOMMENT THIS LINE TO ACTIVATE THE PLUGIN
|
||||||
-- libinput:register({1})
|
-- libinput:register({1})
|
||||||
libinput:connect("new-evdev-device", function(_, device)
|
libinput:connect("new-evdev-device", function(device)
|
||||||
local usages = device:usages()
|
local usages = device:usages()
|
||||||
if usages[evdev.REL_X] then
|
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
|
for _, v in ipairs(frame) do
|
||||||
if v.usage == evdev.REL_X or v.usage == evdev.REL_Y then
|
if v.usage == evdev.REL_X or v.usage == evdev.REL_Y then
|
||||||
-- Multiply the relative motion by 3
|
-- Multiply the relative motion by 3
|
||||||
|
|
|
||||||
|
|
@ -39,7 +39,7 @@ libinput:connect("new-evdev-device", function(device)
|
||||||
local usages = device:usages()
|
local usages = device:usages()
|
||||||
if usages[evdev.REL_X] then
|
if usages[evdev.REL_X] then
|
||||||
remainders[device] = { x = 0.0, y = 0.0 }
|
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
|
for _, v in ipairs(frame) do
|
||||||
if v.usage == evdev.REL_X then
|
if v.usage == evdev.REL_X then
|
||||||
v.value, _ = decelerate(device, v.value, 0.0)
|
v.value, _ = decelerate(device, v.value, 0.0)
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue