inputor

Evdev remapping utility in lua
git clone https://git.neptards.moe/u3shit/inputor.git
Log | Files | Refs

joystick_remap_to_kbd.lua (614B)


      1 -- remap some joystick buttons to keyboard
      2 -- doesn't hide the joystick
      3 local MAP = {
      4   BTN_START = "KEY_F11",
      5   BTN_SELECT = "KEY_ESC",
      6 }
      7 
      8 local fn = ...
      9 
     10 local input = require("lib.input")
     11 local uinput = require("lib.uinput")
     12 
     13 local inp = input(fn)
     14 local ui = uinput()
     15 
     16 ui:add_keyboard_caps(true)
     17 ui:setup{id={bustype="USB", vendor=0x1234, product=0x5678}, name="virtual kbd"}
     18 ui:create()
     19 
     20 while true do
     21   local ev = inp:read()
     22   if ev.type == "KEY" then
     23     local to = MAP[ev.code]
     24     if to then
     25       ev.code = to
     26       print(ev)
     27       ui:write(ev)
     28       ui:write{type="SYN", code="REPORT"}
     29     end
     30   end
     31 end