You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
38 lines
774 B
Lua
38 lines
774 B
Lua
local fn = ...
|
|
|
|
local input = require("lib.input")
|
|
local uinput = require("lib.uinput")
|
|
local poll = require("lib.helper.posix_io").poll_read
|
|
|
|
local inp = input(fn)
|
|
local ui = uinput()
|
|
|
|
ui:copy_caps(inp)
|
|
ui:setup{
|
|
-- id=inp.device_id,
|
|
-- some apps (like wine) doesn't like if you have multiple devices with the
|
|
-- same id, in that case fake something here:
|
|
id={bustype="BLUETOOTH", vendor=1, product=2},
|
|
name="Virtual gamepad",
|
|
ff_effects_max=inp.ff_count
|
|
}
|
|
|
|
ui:create()
|
|
print("created", ui.sysname)
|
|
|
|
inp:grab() -- ! DANGER
|
|
|
|
local to_poll = { inp, ui }
|
|
local ui_ff = ui:gen_ff_forwarder(inp)
|
|
|
|
while true do
|
|
local rdy = poll(to_poll)
|
|
if rdy[inp] then
|
|
local rd = inp:read()
|
|
-- print("inp", rd)
|
|
ui:write(rd)
|
|
end
|
|
|
|
if rdy[ui] then ui_ff() end
|
|
end
|