Skip to content

Instantly share code, notes, and snippets.

@felipsmartins
Last active November 28, 2025 23:28
Show Gist options
  • Select an option

  • Save felipsmartins/ec2d98c64e71654af5ccb4d613e1f39d to your computer and use it in GitHub Desktop.

Select an option

Save felipsmartins/ec2d98c64e71654af5ccb4d613e1f39d to your computer and use it in GitHub Desktop.
libinput 1.30 Released With Support For Writing Plug-Ins In Lua
-- https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1192
libinput:register(1)
function frame(device, frame)
for _, v in ipairs(frame.events) do
if v.type == evdev.EV_KEY then
if v.code == evdev.BTN_RIGHT then
v.code = evdev.BTN_LEFT
elseif v.code == evdev.BTN_LEFT then
v.code = evdev.BTN_RIGHT
end
end
end
return frame
end
function device_new(plugin, device)
local codes = device:event_codes()
if codes[evdev.EV_KEY] and codes[evdev.EV_KEY][evdev.BTN_LEFT] and codes[evdev.EV_KEY][evdev.BTN_RIGHT] then
device:connect("evdev-frame", frame)
end
end
libinput:connect("new-evdev-device", device_new)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment