id.lua (660B)
1 local base = string.match(..., "(.-)[^%.]+%.[^%.]+$") 2 local enums = require(base.."ev_api.decls").enums 3 local ffi = require("ffi") 4 local fh = require(base.."helper.ffi_struct") 5 6 local format = string.format 7 8 local mt, index = {}, {} 9 10 fh.gen_enum_accessor(index, enums.BUS, "bustype") 11 fh.gen_raw_accessor(index, "vendor") 12 fh.gen_raw_accessor(index, "product") 13 fh.gen_raw_accessor(index, "version") 14 15 function index:tostring() 16 return format("id{bustype=%s, vendor=%#x, product=%#x, version=%#x}", 17 self.bustype, self.vendor, self.product, self.version) 18 end 19 mt.__tostring = index.tostring 20 21 return fh.base(mt, index, ffi.typeof("struct input_id"))