From dda5f71a40ba2ba3cf463a0891f24296fbd45b34 Mon Sep 17 00:00:00 2001 From: Vas Crabb Date: Thu, 23 Mar 2023 04:02:46 +1100 Subject: -luaengine.cpp: Expose UI controls toggle state. -ui/ui.cpp: Honour UI enable for machines without keyboards. --- docs/source/techspecs/luareference.rst | 2 ++ src/emu/machine.cpp | 2 +- src/frontend/mame/luaengine.cpp | 1 + src/frontend/mame/ui/ui.cpp | 5 +++-- 4 files changed, 7 insertions(+), 3 deletions(-) diff --git a/docs/source/techspecs/luareference.rst b/docs/source/techspecs/luareference.rst index 4c3c5098004..d05c8fa7c9c 100644 --- a/docs/source/techspecs/luareference.rst +++ b/docs/source/techspecs/luareference.rst @@ -250,6 +250,8 @@ machine:logerror(msg) Properties ^^^^^^^^^^ +machine.ui_active (read/write) + A Boolean indicating whether UI control inputs are currently enabled. machine.time (read-only) The elapsed emulated time for the current session as an :ref:`attotime `. diff --git a/src/emu/machine.cpp b/src/emu/machine.cpp index 2af367d7362..b8e0d233a51 100644 --- a/src/emu/machine.cpp +++ b/src/emu/machine.cpp @@ -71,7 +71,7 @@ running_machine::running_machine(const machine_config &_config, machine_manager m_exit_pending(false), m_soft_reset_timer(nullptr), m_rand_seed(0x9d14abd7), - m_ui_active(_config.options().ui_active()), + m_ui_active(true), m_basename(_config.gamedrv().name), m_sample_rate(_config.options().sample_rate()), m_saveload_schedule(saveload_schedule::NONE), diff --git a/src/frontend/mame/luaengine.cpp b/src/frontend/mame/luaengine.cpp index 4518977b938..2f92b279deb 100644 --- a/src/frontend/mame/luaengine.cpp +++ b/src/frontend/mame/luaengine.cpp @@ -1329,6 +1329,7 @@ void lua_engine::initialize() m.popmessage(); }); machine_type.set_function("logerror", [] (running_machine &m, char const *str) { m.logerror("[luaengine] %s\n", str); }); + machine_type["ui_active"] = sol::property(&running_machine::ui_active, &running_machine::set_ui_active); machine_type["time"] = sol::property(&running_machine::time); machine_type["system"] = sol::property(&running_machine::system); machine_type["parameters"] = sol::property(&running_machine::parameters); diff --git a/src/frontend/mame/ui/ui.cpp b/src/frontend/mame/ui/ui.cpp index 36932c91d15..acbb13ec226 100644 --- a/src/frontend/mame/ui/ui.cpp +++ b/src/frontend/mame/ui/ui.cpp @@ -335,6 +335,7 @@ void mame_ui_manager::config_save(config_type cfg_type, util::xml::data_node *pa void mame_ui_manager::initialize(running_machine &machine) { m_machine_info = std::make_unique(machine); + machine.set_ui_active(!machine_info().has_keyboard() || machine.options().ui_active()); // initialize the on-screen display system slider_list = slider_init(machine); @@ -1241,8 +1242,8 @@ uint32_t mame_ui_manager::handler_ingame(render_container &container) } // determine if we should disable the rest of the UI - bool has_keyboard = machine_info().has_keyboard(); - bool ui_disabled = (has_keyboard && !machine().ui_active()); + bool const has_keyboard = machine_info().has_keyboard(); + bool const ui_disabled = !machine().ui_active(); // is ScrLk UI toggling applicable here? if (has_keyboard) -- cgit v1.2.3