ff_periodic_effect.lua (1143B)
1 local base = string.match(..., "(.-)[^%.]+%.[^%.]+$") 2 local eh = require(base.."helper.enum") 3 local enums = require(base.."ev_api.decls").enums 4 local ff_envelope = require(base.."ev_api.ff_envelope").new 5 local ffi = require("ffi") 6 local fh = require(base.."helper.ffi_struct") 7 8 local format = string.format 9 10 local mt, index = {}, {} 11 12 local FF_WAVEFORM = eh.filter_min_max( 13 enums.FF, enums.FF.WAVEFORM_MIN, enums.FF.WAVEFORM_MAX) 14 index.FF_WAVEFORM = FF_WAVEFORM 15 fh.gen_enum_accessor(index, FF_WAVEFORM, "waveform") 16 17 fh.gen_raw_accessor(index, "period") -- ms 18 fh.gen_raw_accessor(index, "magnitude") 19 fh.gen_raw_accessor(index, "offset") 20 fh.gen_raw_accessor(index, "phase") 21 fh.gen_wrap_accessor(index, "envelope", ff_envelope) 22 23 -- custom: no device supports it, nobody knows how the API is supposed to work 24 25 function index:tostring() 26 return format( 27 "ff_periodic_effect{waveform=%s, period=%d, magnitude=%d, offset=%d, phase=%d, envelope=%s}", 28 self.waveform, self.period, self.magnitude, self.offset, self.phase, 29 self.envelope) 30 end 31 mt.__tostring = index.tostring 32 33 return fh.base(mt, index, ffi.typeof("struct ff_periodic_effect"))