You are not logged in.

#1 Yesterday 19:33:48

msl09
Member
Registered: 2022-10-01
Posts: 19

[SOLVED] libinput plugin development

Does any of you have experience developing libinput plugins? I'm making a plugin to (try to) prevent accidental key presses. The problem I'm facing is that none of the debug messages get output. I know that the plugin is being loaded because if I try to add bad code to it libinput complains.

This is the code:

libinput:register({1})
libinput:log_debug("Starting plugin")
prevTime = -1
prevFrame = nil
INTERVAL = 50000 -- 50 miliseconds

function frame(_, frame, timestamp)
    libinput:log_debug("New frame detected")
    -- if the same keys are being affected return them
    if equalKeys(frame, prevFrame) then
        libinput:log_debug("Same key pressed")
        prevTime = timestamp
        return frame
    else
        libinput:log_debug("Different key pressed")
        if timestamp - prevTime > INTERVAL then
            prevTime = timestamp
            prevFrame = frame
            libinput:log_debug("New key bubbled up")
            return frame
        else
            libinput:log_debug("Key suppressed")
            return {} --
        end
    end
end

function device_new(device)
    local usages = device:usages()
    if usages[evdev.KEY_SCROLLLOCK] then
        libinput:log_debug("Connecting to new device")
        device:connect("evdev-frame", frame)
    end
end

function equalKeys(t1, t2)
    if t1 == t2 then return true end
    if type(t1) ~= "table" or type(t2) ~= "table" then return false end
    for k in pairs(t1) do
        if t1[k] == nil then return false end
    end

    for k in pairs(t2) do
        if t1[k] == nil then return false end
    end
    return true
end

libinput:connect("new-evdev-device", device_new)

I'm testing it with

sudo libinput debug-events --enable-plugins

Last edited by msl09 (Yesterday 22:18:04)

Offline

#2 Yesterday 19:49:04

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 77,953

Re: [SOLVED] libinput plugin development

Tried good old print()  or "--quiet --verbose"?

Offline

#3 Yesterday 22:17:23

msl09
Member
Registered: 2022-10-01
Posts: 19

Re: [SOLVED] libinput plugin development

Yep, it was --verbose. Thanks seth!

Offline

Board footer

Powered by FluxBB