diff options
author | Vas Crabb <vas@vastheman.com> | 2020-12-09 01:01:22 +1100 |
---|---|---|
committer | Vas Crabb <vas@vastheman.com> | 2020-12-09 01:10:26 +1100 |
commit | e008c7b1b1042d644be2a1e177ffa15d53e942c5 (patch) | |
tree | d248f9fcbe15563c46c1ae9605d35a19ed4ada5e /plugins | |
parent | 06568860e7a30424bab61498cd2a8a44889e4412 (diff) |
-Lua engine cleanup, input edition:
* Modernised and cleaned up Lua bindings for input classes.
* Exposed the input_sequence_poller class to Lua and updated the
autofire and cheat plugins to use it, rather than continuing to
pretend it's part of the input manager.
* Exposed more of the natural keyboard manager, including the ability
to enable/disable individual keyboard and keypad devices like you
can from the keyboard mode menu.
* Exposed a few more things on ioport_port and input_device.
-plugins/cheat: Fixed menu item not updating visually when disabling a
cheat with UI Left.
-plugins/cheatfind: Fixed not finding the first screen after screen
enumerator was exposed as an object rather than using a table.
-bwidow.cpp, pacman.cpp: Minor cleanup to recent changes.
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/autofire/autofire_menu.lua | 13 | ||||
-rw-r--r-- | plugins/cheat/init.lua | 18 | ||||
-rw-r--r-- | plugins/cheatfind/init.lua | 2 |
3 files changed, 18 insertions, 15 deletions
diff --git a/plugins/autofire/autofire_menu.lua b/plugins/autofire/autofire_menu.lua index a880d1c5008..4744de1b2ac 100644 --- a/plugins/autofire/autofire_menu.lua +++ b/plugins/autofire/autofire_menu.lua @@ -108,26 +108,27 @@ end -- Borrowed from the cheat plugin local function poll_for_hotkey() local input = manager:machine():input() + local poller = input:sequence_poller() manager:machine():popmessage(_('Press button for hotkey or wait to leave unchanged')) manager:machine():video():frame_update(true) - input:seq_poll_start('switch') + poller:start('switch') local time = os.clock() local clearmsg = true - while (not input:seq_poll()) and (input:seq_poll_modified() or (os.clock() < time + 1)) do - if input:seq_poll_modified() then - if not input:seq_poll_valid() then + while (not poller:poll()) and (poller.modified or (os.clock() < time + 1)) do + if poller.modified then + if not poller.valid then manager:machine():popmessage(_("Invalid sequence entered")) clearmsg = false break end - manager:machine():popmessage(input:seq_name(input:seq_poll_sequence())) + manager:machine():popmessage(input:seq_name(poller.sequence)) manager:machine():video():frame_update(true) end end if clearmsg then manager:machine():popmessage() end - return input:seq_poll_valid() and input:seq_poll_final() or nil + return poller.valid and poller.sequence or nil end local function handle_configure_menu(index, event) diff --git a/plugins/cheat/init.lua b/plugins/cheat/init.lua index 3fa625fb4d3..970e7f3a848 100644 --- a/plugins/cheat/init.lua +++ b/plugins/cheat/init.lua @@ -610,24 +610,25 @@ function cheat.startplugin() local function hkcbfunc(cheat) local input = manager:machine():input() + local poller = input:sequence_poller() manager:machine():popmessage(_("Press button for hotkey or wait to clear")) manager:machine():video():frame_update(true) - input:seq_poll_start("switch") + poller:start("switch") local time = os.clock() local clearmsg = true - while (not input:seq_poll()) and (input.seq_poll_modified() or (os.clock() < time + 1)) do - if input:seq_poll_modified() then - if not input:seq_poll_valid() then + while (not poller:poll()) and (poller.modified or (os.clock() < time + 1)) do + if poller.modified then + if not poller.valid then manager:machine():popmessage(_("Invalid sequence entered")) clearmsg = false break end - manager:machine():popmessage(input:seq_name(input:seq_poll_sequence())) + manager:machine():popmessage(input:seq_name(poller.sequence)) manager:machine():video():frame_update(true) end end - if input:seq_poll_valid() then - cheat.hotkeys = {pressed = false, keys = input:seq_poll_final()} + if poller.valid then + cheat.hotkeys = { pressed = false, keys = poller.sequence } else cheat.hotkeys = nil end @@ -748,7 +749,8 @@ function cheat.startplugin() return chg else if not cheat.is_oneshot then - return cheat:set_enabled(false) + local state, chg = cheat:set_enabled(false) + return chg end return false end diff --git a/plugins/cheatfind/init.lua b/plugins/cheatfind/init.lua index 83e00e4d51a..e6a359f6564 100644 --- a/plugins/cheatfind/init.lua +++ b/plugins/cheatfind/init.lua @@ -1044,7 +1044,7 @@ function cheatfind.startplugin() end emu.register_menu(menu_callback, menu_populate, _("Cheat Finder")) emu.register_frame_done(function () - local tag, screen = next(manager:machine().screens) + local screen = manager:machine().screens:at(1) local height = mame_manager:ui():get_line_height() for num, watch in ipairs(watches) do screen:draw_text("left", num * height, string.format(watch.format, watch.addr, watch.func())) |