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.

34 lines
1.1 KiB
Lua

local base = string.match(..., "(.-)[^%.]+%.[^%.]+$")
local eh = require(base.."helper.enum")
local enums = require(base.."ev_api.decls").enums
local ff_envelope = require(base.."ev_api.ff_envelope").new
local ffi = require("ffi")
local fh = require(base.."helper.ffi_struct")
local format = string.format
local mt, index = {}, {}
local FF_WAVEFORM = eh.filter_min_max(
enums.FF, enums.FF.WAVEFORM_MIN, enums.FF.WAVEFORM_MAX)
index.FF_WAVEFORM = FF_WAVEFORM
fh.gen_enum_accessor(index, FF_WAVEFORM, "waveform")
fh.gen_raw_accessor(index, "period") -- ms
fh.gen_raw_accessor(index, "magnitude")
fh.gen_raw_accessor(index, "offset")
fh.gen_raw_accessor(index, "phase")
fh.gen_wrap_accessor(index, "envelope", ff_envelope)
-- custom: no device supports it, nobody knows how the API is supposed to work
function index:tostring()
return format(
"ff_periodic_effect{waveform=%s, period=%d, magnitude=%d, offset=%d, phase=%d, envelope=%s}",
self.waveform, self.period, self.magnitude, self.offset, self.phase,
self.envelope)
end
mt.__tostring = index.tostring
return fh.base(mt, index, ffi.typeof("struct ff_periodic_effect"))