fwd.lua (774B)
1 local fn = ... 2 3 local input = require("lib.input") 4 local uinput = require("lib.uinput") 5 local poll = require("lib.helper.posix_io").poll_read 6 7 local inp = input(fn) 8 local ui = uinput() 9 10 ui:copy_caps(inp) 11 ui:setup{ 12 -- id=inp.device_id, 13 -- some apps (like wine) doesn't like if you have multiple devices with the 14 -- same id, in that case fake something here: 15 id={bustype="BLUETOOTH", vendor=1, product=2}, 16 name="Virtual gamepad", 17 ff_effects_max=inp.ff_count 18 } 19 20 ui:create() 21 print("created", ui.sysname) 22 23 inp:grab() -- ! DANGER 24 25 local to_poll = { inp, ui } 26 local ui_ff = ui:gen_ff_forwarder(inp) 27 28 while true do 29 local rdy = poll(to_poll) 30 if rdy[inp] then 31 local rd = inp:read() 32 -- print("inp", rd) 33 ui:write(rd) 34 end 35 36 if rdy[ui] then ui_ff() end 37 end