summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
author cracyc <cracyc@users.noreply.github.com>2019-11-20 21:35:35 -0600
committer cracyc <cracyc@users.noreply.github.com>2019-11-20 21:35:35 -0600
commit0606a77760325b7778f1dd47f78cbf48b8126d25 (patch)
treed9cf241de5efd983ae5ed920318988fa6e59be89
parent4f613c53057d60e04573b29778f738c69f5f964f (diff)
plugins/cheat: show pressed buttons when setting hotkeys (nw)
-rw-r--r--plugins/cheat/init.lua17
-rw-r--r--src/frontend/mame/luaengine.cpp27
2 files changed, 38 insertions, 6 deletions
diff --git a/plugins/cheat/init.lua b/plugins/cheat/init.lua
index 21824626977..35378f1a43e 100644
--- a/plugins/cheat/init.lua
+++ b/plugins/cheat/init.lua
@@ -536,8 +536,21 @@ function cheat.startplugin()
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
- cheat.hotkeys = {pressed = false, keys = input:seq_poll_final()}
+ 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"))
+ break
+ end
+ manager:machine():popmessage(input:seq_name(input:seq_poll_sequence()))
+ manager:machine():video():frame_update(true)
+ end
+ end
+ if input:seq_poll_valid() then
+ cheat.hotkeys = {pressed = false, keys = input:seq_poll_final()}
+ else
+ cheat.hotkeys = nil
+ end
manager:machine():popmessage()
manager:machine():video():frame_update(true)
end
diff --git a/src/frontend/mame/luaengine.cpp b/src/frontend/mame/luaengine.cpp
index 8c5ab6888a1..6cb15537b7e 100644
--- a/src/frontend/mame/luaengine.cpp
+++ b/src/frontend/mame/luaengine.cpp
@@ -2113,12 +2113,31 @@ void lua_engine::initialize()
else
m_seq_poll->start(cls);
});
- input_type.set("seq_poll", [this](input_manager &input) {
- return m_seq_poll->poll();
+ input_type.set("seq_poll", [this](input_manager &input) -> sol::object {
+ if (!m_seq_poll)
+ return sol::make_object(sol(), sol::nil);
+ return sol::make_object(sol(), m_seq_poll->poll());
+ });
+ input_type.set("seq_poll_final", [this](input_manager &input) -> sol::object {
+ if (!m_seq_poll)
+ return sol::make_object(sol(), sol::nil);
+ return sol::make_object(sol(), sol::make_user(m_seq_poll->valid() ? m_seq_poll->sequence() : input_seq()));
+ });
+ input_type.set("seq_poll_modified", [this](input_manager &input) -> sol::object {
+ if (!m_seq_poll)
+ return sol::make_object(sol(), sol::nil);
+ return sol::make_object(sol(), m_seq_poll->modified());
});
- input_type.set("seq_poll_final", [this](input_manager &input) {
- return sol::make_user(m_seq_poll->valid() ? m_seq_poll->sequence() : input_seq());
+ input_type.set("seq_poll_valid", [this](input_manager &input) -> sol::object {
+ if (!m_seq_poll)
+ return sol::make_object(sol(), sol::nil);
+ return sol::make_object(sol(), m_seq_poll->valid());
});
+ input_type.set("seq_poll_sequence", [this](input_manager &input) -> sol::object {
+ if (!m_seq_poll)
+ return sol::make_object(sol(), sol::nil);
+ return sol::make_object(sol(), sol::make_user(m_seq_poll->sequence()));
+ });
input_type.set("device_classes", sol::property([this](input_manager &input) {
sol::table result = sol().create_table();
for (input_device_class devclass_id = DEVICE_CLASS_FIRST_VALID; devclass_id <= DEVICE_CLASS_LAST_VALID; devclass_id++)