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.
95 lines
2.4 KiB
Lua
95 lines
2.4 KiB
Lua
local fn = ...
|
|
|
|
local input = require("lib.input")
|
|
local enums = require("lib.ev_api.decls").enums
|
|
require("lib.helper.string")
|
|
|
|
local function pprint(key, func)
|
|
if type(func) ~= "function" then
|
|
local obj = func
|
|
func = function() return obj[key] end
|
|
end
|
|
local succ, res = pcall(func)
|
|
print(string.format("%-19s %s", key, res))
|
|
end
|
|
|
|
local inp = input(fn)
|
|
pprint("driver_version", inp)
|
|
pprint("device_id", inp)
|
|
pprint("repeat", inp)
|
|
--inp.rep = inp.rep
|
|
pprint("keycode", function()
|
|
local res = {}
|
|
local kc = inp.keycode
|
|
local _ = kc[0] -- fail early if not supported
|
|
for i=0,1024 do
|
|
if #res >= 16 then
|
|
res[#res+1] = "..."
|
|
break
|
|
end
|
|
pcall(function() res[#res+1] = string.format("%#0x => %s", i, kc[i]) end)
|
|
end
|
|
return "["..table.concat(res, ", ").."]"
|
|
end)
|
|
--inp.keycode[0] = 0
|
|
|
|
-- TODO
|
|
-- print("keycode_v2", inp:ioctl_get_keycode_v2())
|
|
|
|
pprint("name", function() return inp.name:escape() end)
|
|
pprint("phys", function() return inp.phys:escape() end)
|
|
pprint("uniq", function() return inp.uniq:escape() end)
|
|
pprint("prop", inp)
|
|
pprint("mt_slot_count", inp)
|
|
pprint("mt_slots", function()
|
|
local res = {}
|
|
for k,v in pairs(enums.ABS) do
|
|
if type(k) == "string" and k:sub(1,3) == "MT_" then
|
|
pcall(function()
|
|
res[#res+1] = k.." => "..table.concat(inp:get_mt_slots(v), ":")
|
|
end)
|
|
end
|
|
end
|
|
return "["..table.concat(res, ", ").."]"
|
|
end)
|
|
for _,x in ipairs{"key", "led", "snd", "sw"} do
|
|
pprint(x.."_state", inp)
|
|
end
|
|
for _,x in ipairs{"ev", "key", "rel", "abs", "msc", "led", "snd", "ff", "sw"} do
|
|
pprint(x.."_bits", inp)
|
|
end
|
|
local abs_bits = inp.abs_bits
|
|
for k,v in pairs(enums.ABS) do
|
|
if type(k) == "number" and abs_bits[k] then
|
|
pprint("absinfo "..v, function() return inp.absinfo[k] end)
|
|
end
|
|
end
|
|
pprint("ff_count", inp)
|
|
|
|
for _,x in ipairs{"ev", "key", "rel", "abs", "msc", "led", "snd", "ff", "sw"} do
|
|
pprint(x.."_mask", inp)
|
|
end
|
|
|
|
-- danger zone
|
|
-- inp:grab()
|
|
-- inp.clockid = "MONOTONIC"
|
|
-- inp:revoke()
|
|
-- inp.ev_mask = inp.ev_mask:clear()
|
|
|
|
for j=0,10 do
|
|
print(inp:read())
|
|
end
|
|
|
|
-- local id = inp:add_ff{type="RUMBLE", id=-1, direction=49152,
|
|
-- rumble={strong_magnitude=24576, weak_magnitude=8192}}
|
|
-- inp.ff_gain = 0x8000
|
|
-- inp.ff_autocenter = 0xffff
|
|
-- inp:play_ff(id)
|
|
|
|
-- -- note: ffs are stopped on close, so wait a bit
|
|
-- local ffi = require("ffi")
|
|
-- ffi.cdef("unsigned int sleep(unsigned int);")
|
|
-- ffi.C.sleep(1)
|
|
|
|
inp:close()
|