u/ErCiYuanShaGou

▲ 5 r/Fedora+1 crossposts

I'm trying to use libinput plugins to adjust the orientation of a drawing tablet. Here's my script:

local version = libinput:register({1, 4, 5})
libinput:connect("new-evdev-device", function (device)
    if device:info().vid ~= 0x2d80 then return end
    if device:info().pid ~= 0x3011 then return end
    if device:name():match'Keyboard' then
        libinput:log_info(('%s ignored.'):format(device:name()))
        return
    end
    libinput:log_info(('%s detected.'):format(device:name()))
    for u, uv in ipairs(device:usages()) do
        print(('%x:%s'):format(u, uv))
    end
    device:connect("evdev-frame", function (device, frame, timestamp)
        for _, f in ipairs(frame) do
            if f.usage == 0x30000 then
                f.usage = 0x30001 -- change ABS_X to ABS_Y
            elseif f.usage == 0x30001 then
                f.usage = 0x30000 -- change ABS_Y to ABS_X
            end
        end
        for i, f in ipairs(frame) do
            print(('%d. usage: %x, value: %d'):format(i, f.usage, f.value))
        end

        return frame
    end)
end)

The script does not work although I can see the logs. I can also completely disable the tablet by

return {}

but I just can't modify the frame data at all. What was wrong?

reddit.com
u/ErCiYuanShaGou — 7 days ago