diff options
author | 2021-11-05 02:46:04 +1100 | |
---|---|---|
committer | 2021-11-05 02:46:04 +1100 | |
commit | de9ed121867b8665060fb91fc1dbee0dfa3ca6fa (patch) | |
tree | 790bf80e2da36d3c9cc0542514a96aae2fe7b467 /plugins/inputmacro/inputmacro_persist.lua | |
parent | f196989f8bbd8163b58aaf20f64904eafbfea52f (diff) |
plugins: Reduced amnesia for autofire and inputmacro plugins.
Made autofire and inputmacro plugins capable of remembering settings if
the host input device for the binding is missing or if an input for a
slot device that isn't present is referenced.
Diffstat (limited to 'plugins/inputmacro/inputmacro_persist.lua')
-rw-r--r-- | plugins/inputmacro/inputmacro_persist.lua | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/plugins/inputmacro/inputmacro_persist.lua b/plugins/inputmacro/inputmacro_persist.lua index b66d3c85c5c..4e043852c51 100644 --- a/plugins/inputmacro/inputmacro_persist.lua +++ b/plugins/inputmacro/inputmacro_persist.lua @@ -20,6 +20,7 @@ local function make_macro(setting) local result = { name = setting.name, binding = manager.machine.input:seq_from_tokens(setting.binding), + bindingcfg = setting.binding, earlycancel = setting.earlycancel, loop = setting.loop, steps = { } } @@ -33,13 +34,18 @@ local function make_macro(setting) duration = step.duration } for j, input in ipairs(step.inputs) do if input.port and input.mask and input.type then + local ipt = { + port = input.port, + mask = input.mask, + type = ioport:token_to_input_type(input.type) } local port = ioport.ports[input.port] if port then local field = port:field(input.mask) - if field and (field.type == ioport:token_to_input_type(input.type)) then - table.insert(s.inputs, { port = port, field = field }) + if field and (field.type == ipt.type) then + ipt.field = field end end + table.insert(s.inputs, ipt) end end if #s.inputs > 0 then @@ -66,7 +72,7 @@ local function make_settings(macros) for i, macro in ipairs(macros) do local m = { name = macro.name, - binding = input:seq_to_tokens(macro.binding), + binding = macro.bindingcfg, earlycancel = macro.earlycancel, loop = macro.loop, steps = { } } @@ -79,9 +85,9 @@ local function make_settings(macros) table.insert(m.steps, s) for k, input in ipairs(step.inputs) do local b = { - port = input.port.tag, - mask = input.field.mask, - type = ioport:input_type_to_token(input.field.type) } + port = input.port, + mask = input.mask, + type = ioport:input_type_to_token(input.type) } table.insert(s.inputs, b) end end |