diff options
author | 2019-11-20 22:35:13 -0600 | |
---|---|---|
committer | 2019-11-20 22:35:13 -0600 | |
commit | 0ec88f2ff75fcc65191c0c89ad47f635ebb8c51a (patch) | |
tree | 30f85e650b89beca52945f3663d93ce9aa616bb8 /plugins/autofire | |
parent | 52bc1df46e17f0412196f16e44ccb2fcfe949ca5 (diff) |
plugins/autofire: permit input sequences (nw)
Diffstat (limited to 'plugins/autofire')
-rw-r--r-- | plugins/autofire/autofire_menu.lua | 28 | ||||
-rw-r--r-- | plugins/autofire/autofire_save.lua | 4 | ||||
-rw-r--r-- | plugins/autofire/init.lua | 2 |
3 files changed, 20 insertions, 14 deletions
diff --git a/plugins/autofire/autofire_menu.lua b/plugins/autofire/autofire_menu.lua index 1533465105f..1109bebe796 100644 --- a/plugins/autofire/autofire_menu.lua +++ b/plugins/autofire/autofire_menu.lua @@ -63,7 +63,7 @@ local function populate_main_menu(buttons) -- Round to two decimal places rate = math.floor(rate * 100) / 100 local text = button.button.name .. ' [' .. rate .. ' Hz]' - local subtext = manager:machine():input():code_name(button.key) + local subtext = manager:machine():input():seq_name(button.key) menu[#menu + 1] = {text, subtext, ''} end content_height = #menu @@ -98,7 +98,7 @@ end local function populate_configure_menu(menu) local button_name = current_button.button and current_button.button.name or _('NOT SET') - local key_name = current_button.key and manager:machine():input():code_name(current_button.key) or _('NOT SET') + local key_name = current_button.key and manager:machine():input():seq_name(current_button.key) or _('NOT SET') menu[#menu + 1] = {_('Input'), button_name, ''} menu[#menu + 1] = {_('Hotkey'), key_name, ''} menu[#menu + 1] = {_('On frames'), current_button.on_frames, current_button.on_frames > 1 and 'lr' or 'r'} @@ -112,16 +112,22 @@ local function poll_for_hotkey() manager:machine():video():frame_update(true) input:seq_poll_start('switch') local time = os.clock() - while (not input:seq_poll()) and (os.clock() < time + 1) do end - local tokens = input:seq_to_tokens(input:seq_poll_final()) - manager:machine():popmessage() - manager:machine():video():frame_update(true) - - local final_token = nil - for token in tokens:gmatch('%S+') do - final_token = token + local clearmsg = true + while (not input:seq_poll()) and (os.clock() < time + 1) do + if input:seq_poll_modified() then + if not input:seq_poll_valid() then + manager:machine():popmessage(_("Invalid sequence entered")) + clearmsg = false + break + end + manager:machine():popmessage(input:seq_name(input:seq_poll_sequence())) + manager:machine():video():frame_update(true) + end + end + if clearmsg then + manager:machine():popmessage() end - return final_token and input:code_from_token(final_token) or nil + return input:seq_poll_valid() and input:seq_poll_final() or nil end local function handle_configure_menu(index, event) diff --git a/plugins/autofire/autofire_save.lua b/plugins/autofire/autofire_save.lua index 2f353417e3e..067368dd2b2 100644 --- a/plugins/autofire/autofire_save.lua +++ b/plugins/autofire/autofire_save.lua @@ -13,7 +13,7 @@ local function initialize_button(settings) local new_button = { port = settings.port, field = settings.field, - key = manager:machine():input():code_from_token(settings.key), + key = manager:machine():input():seq_from_tokens(settings.key), on_frames = settings.on_frames, off_frames = settings.off_frames, counter = 0 @@ -36,7 +36,7 @@ local function serialize_settings(button_list) setting = { port = button.port, field = button.field, - key = manager:machine():input():code_to_token(button.key), + key = manager:machine():input():seq_to_tokens(button.key), on_frames = button.on_frames, off_frames = button.off_frames } diff --git a/plugins/autofire/init.lua b/plugins/autofire/init.lua index 1eb8627b494..da9a223faa4 100644 --- a/plugins/autofire/init.lua +++ b/plugins/autofire/init.lua @@ -24,7 +24,7 @@ function autofire.startplugin() local current_rom = nil local function process_button(button) - local pressed = manager:machine():input():code_pressed(button.key) + local pressed = manager:machine():input():seq_pressed(button.key) if pressed then local state = button.counter < button.on_frames and 1 or 0 button.counter = (button.counter + 1) % (button.on_frames + button.off_frames) |