summaryrefslogtreecommitdiffstatshomepage
path: root/src/frontend
diff options
context:
space:
mode:
authorGravatarGravatar npwoods <npwoods@mess.org>2019-08-18 22:41:55 -0400
committerGravatarGravatar npwoods <npwoods@mess.org>2019-08-18 22:41:55 -0400
commit02b5baec56973277a3c57ec5e458ad724502929e (patch)
treec22aa807333562d295368916525a9404c6786856 /src/frontend
parent123d5fad6c7943f47f77cba240699fb8ba82f874 (diff)
Miscellaneous LUA functionality
- Created emu.register_before_load_settings(), to allow LUA scripts to override default input port values before settings are loaded - New ioport_field methods/props ([set_]default_input_seq(), port)
Diffstat (limited to 'src/frontend')
-rw-r--r--src/frontend/mame/luaengine.cpp20
-rw-r--r--src/frontend/mame/luaengine.h1
-rw-r--r--src/frontend/mame/mame.cpp5
-rw-r--r--src/frontend/mame/mame.h2
4 files changed, 27 insertions, 1 deletions
diff --git a/src/frontend/mame/luaengine.cpp b/src/frontend/mame/luaengine.cpp
index 23956fc466d..356c6a73ab6 100644
--- a/src/frontend/mame/luaengine.cpp
+++ b/src/frontend/mame/luaengine.cpp
@@ -691,6 +691,11 @@ void lua_engine::on_machine_stop()
execute_function("LUA_ON_STOP");
}
+void lua_engine::on_machine_before_load_settings()
+{
+ execute_function("LUA_ON_BEFORE_LOAD_SETTINGS");
+}
+
void lua_engine::on_machine_pause()
{
execute_function("LUA_ON_PAUSE");
@@ -784,6 +789,7 @@ void lua_engine::initialize()
* emu.register_callback(callback, name) - register callback to be used by MAME via lua_engine::call_plugin()
* emu.register_menu(event_callback, populate_callback, name) - register callbacks for plugin menu
* emu.register_mandatory_file_manager_override(callback) - register callback invoked to override mandatory file manager
+ * emu.register_before_load_settings(callback) - register callback to be run before settings are loaded
* emu.show_menu(menu_name) - show menu by name and pause the machine
*
* emu.print_verbose(str) - output to stderr at verbose level
@@ -824,6 +830,7 @@ void lua_engine::initialize()
emu["register_frame_done"] = [this](sol::function func){ register_function(func, "LUA_ON_FRAME_DONE"); };
emu["register_periodic"] = [this](sol::function func){ register_function(func, "LUA_ON_PERIODIC"); };
emu["register_mandatory_file_manager_override"] = [this](sol::function func) { register_function(func, "LUA_ON_MANDATORY_FILE_MANAGER_OVERRIDE"); };
+ emu["register_before_load_settings"] = [this](sol::function func) { register_function(func, "LUA_ON_BEFORE_LOAD_SETTINGS"); };
emu["register_menu"] = [this](sol::function cb, sol::function pop, const std::string &name) {
std::string cbfield = "menu_cb_" + name;
std::string popfield = "menu_pop_" + name;
@@ -1786,10 +1793,12 @@ void lua_engine::initialize()
* field:set_value(value)
* field:set_input_seq(seq_type, seq)
* field:input_seq(seq_type)
+ * field:set_default_input_seq(seq_type, seq)
+ * field:default_input_seq(seq_type)
*
* field.device - get associated device_t
+ * field.port - get associated ioport_port
* field.live - get ioport_field_live
-
* field.name
* field.default_name
* field.player
@@ -1829,7 +1838,16 @@ void lua_engine::initialize()
input_seq_type seq_type = parse_seq_type(seq_type_string);
return sol::make_user(f.seq(seq_type));
},
+ "set_default_input_seq", [](ioport_field &f, const std::string &seq_type_string, sol::user<input_seq> seq) {
+ input_seq_type seq_type = parse_seq_type(seq_type_string);
+ f.set_defseq(seq_type, seq);
+ },
+ "default_input_seq", [](ioport_field &f, const std::string &seq_type_string) {
+ input_seq_type seq_type = parse_seq_type(seq_type_string);
+ return sol::make_user(f.defseq(seq_type));
+ },
"device", sol::property(&ioport_field::device),
+ "port", sol::property(&ioport_field::port),
"name", sol::property(&ioport_field::name),
"default_name", sol::property([](ioport_field &f) {
return f.specific_name() ? f.specific_name() : f.manager().type_name(f.type(), f.player());
diff --git a/src/frontend/mame/luaengine.h b/src/frontend/mame/luaengine.h
index b5938d2aee8..4315fe37aa4 100644
--- a/src/frontend/mame/luaengine.h
+++ b/src/frontend/mame/luaengine.h
@@ -51,6 +51,7 @@ public:
void on_frame_done();
void on_periodic();
bool on_missing_mandatory_image(const std::string &instance_name);
+ void on_machine_before_load_settings();
template<typename T, typename U>
bool call_plugin(const std::string &name, const T in, U &out)
diff --git a/src/frontend/mame/mame.cpp b/src/frontend/mame/mame.cpp
index 1266370fe4b..e5a59cd6039 100644
--- a/src/frontend/mame/mame.cpp
+++ b/src/frontend/mame/mame.cpp
@@ -323,6 +323,11 @@ void mame_machine_manager::ui_initialize(running_machine& machine)
m_ui->display_startup_screens(m_firstrun);
}
+void mame_machine_manager::before_load_settings(running_machine& machine)
+{
+ m_lua->on_machine_before_load_settings();
+}
+
void mame_machine_manager::create_custom(running_machine& machine)
{
// start the inifile manager
diff --git a/src/frontend/mame/mame.h b/src/frontend/mame/mame.h
index 36a284ed978..041612de758 100644
--- a/src/frontend/mame/mame.h
+++ b/src/frontend/mame/mame.h
@@ -50,6 +50,8 @@ public:
virtual void ui_initialize(running_machine& machine) override;
+ virtual void before_load_settings(running_machine& machine) override;
+
std::vector<std::reference_wrapper<const std::string>> missing_mandatory_images();
/* execute as configured by the OPTION_SYSTEMNAME option on the specified options */