setup.lua (879B)
1 local base = string.match(..., "(.-)[^%.]+%.[^%.]+$") 2 local ffi = require("ffi") 3 local fh = require(base.."helper.ffi_struct") 4 local id = require(base.."ev_api.id").new 5 local string_escape = require(base.."helper.string").escape 6 7 local ffi_string = ffi.string 8 9 local format = string.format 10 11 local mt, index = {}, {} 12 13 function index:get_id() return id(self.raw.id) end 14 -- TODO: probably not the most optimal 15 function index:set_id(...) self.raw.id = id(...).raw end 16 17 function index:get_name() return ffi_string(self.raw.name) end 18 function index:set_name(n) self.raw.name = n end 19 20 fh.gen_raw_accessor(index, "ff_effects_max") 21 22 function index:tostring() 23 return format("setup{id=%s, name=%s, ff_effects_max=%d}", 24 self.id, string_escape(self.name), self.ff_effects_max) 25 end 26 mt.__tostring = index.tostring 27 28 return fh.base(mt, index, ffi.typeof("struct uinput_setup"))