plugins/autofire: permit input sequences (nw)
This commit is contained in:
parent
52bc1df46e
commit
0ec88f2ff7
@ -63,7 +63,7 @@ local function populate_main_menu(buttons)
|
|||||||
-- Round to two decimal places
|
-- Round to two decimal places
|
||||||
rate = math.floor(rate * 100) / 100
|
rate = math.floor(rate * 100) / 100
|
||||||
local text = button.button.name .. ' [' .. rate .. ' Hz]'
|
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, ''}
|
menu[#menu + 1] = {text, subtext, ''}
|
||||||
end
|
end
|
||||||
content_height = #menu
|
content_height = #menu
|
||||||
@ -98,7 +98,7 @@ end
|
|||||||
|
|
||||||
local function populate_configure_menu(menu)
|
local function populate_configure_menu(menu)
|
||||||
local button_name = current_button.button and current_button.button.name or _('NOT SET')
|
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] = {_('Input'), button_name, ''}
|
||||||
menu[#menu + 1] = {_('Hotkey'), key_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'}
|
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)
|
manager:machine():video():frame_update(true)
|
||||||
input:seq_poll_start('switch')
|
input:seq_poll_start('switch')
|
||||||
local time = os.clock()
|
local time = os.clock()
|
||||||
while (not input:seq_poll()) and (os.clock() < time + 1) do end
|
local clearmsg = true
|
||||||
local tokens = input:seq_to_tokens(input:seq_poll_final())
|
while (not input:seq_poll()) and (os.clock() < time + 1) do
|
||||||
manager:machine():popmessage()
|
if input:seq_poll_modified() then
|
||||||
manager:machine():video():frame_update(true)
|
if not input:seq_poll_valid() then
|
||||||
|
manager:machine():popmessage(_("Invalid sequence entered"))
|
||||||
local final_token = nil
|
clearmsg = false
|
||||||
for token in tokens:gmatch('%S+') do
|
break
|
||||||
final_token = token
|
end
|
||||||
|
manager:machine():popmessage(input:seq_name(input:seq_poll_sequence()))
|
||||||
|
manager:machine():video():frame_update(true)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
return final_token and input:code_from_token(final_token) or nil
|
if clearmsg then
|
||||||
|
manager:machine():popmessage()
|
||||||
|
end
|
||||||
|
return input:seq_poll_valid() and input:seq_poll_final() or nil
|
||||||
end
|
end
|
||||||
|
|
||||||
local function handle_configure_menu(index, event)
|
local function handle_configure_menu(index, event)
|
||||||
|
@ -13,7 +13,7 @@ local function initialize_button(settings)
|
|||||||
local new_button = {
|
local new_button = {
|
||||||
port = settings.port,
|
port = settings.port,
|
||||||
field = settings.field,
|
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,
|
on_frames = settings.on_frames,
|
||||||
off_frames = settings.off_frames,
|
off_frames = settings.off_frames,
|
||||||
counter = 0
|
counter = 0
|
||||||
@ -36,7 +36,7 @@ local function serialize_settings(button_list)
|
|||||||
setting = {
|
setting = {
|
||||||
port = button.port,
|
port = button.port,
|
||||||
field = button.field,
|
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,
|
on_frames = button.on_frames,
|
||||||
off_frames = button.off_frames
|
off_frames = button.off_frames
|
||||||
}
|
}
|
||||||
|
@ -24,7 +24,7 @@ function autofire.startplugin()
|
|||||||
local current_rom = nil
|
local current_rom = nil
|
||||||
|
|
||||||
local function process_button(button)
|
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
|
if pressed then
|
||||||
local state = button.counter < button.on_frames and 1 or 0
|
local state = button.counter < button.on_frames and 1 or 0
|
||||||
button.counter = (button.counter + 1) % (button.on_frames + button.off_frames)
|
button.counter = (button.counter + 1) % (button.on_frames + button.off_frames)
|
||||||
|
Loading…
Reference in New Issue
Block a user