diff options
author | 2022-02-27 18:12:25 +0300 | |
---|---|---|
committer | 2022-02-28 02:12:25 +1100 | |
commit | 300206e308c2c5f9ad8898fb62f1873be682df5a (patch) | |
tree | cb780133d4b724eb390bf84fa9c14a7b7ee4dc1a /src/frontend/mame/luaengine_input.cpp | |
parent | 029f4232fe9779cbe7d2f9cf2d3e991108da75dc (diff) |
Lua engine: Make setting analog I/O port field values user-friendly. (#9322)
Exposed minimum/maximum values for analog fields. together with defvalue, they can be used to check range of values and neutral position.
Previously you had to send a normalised value between -65535 and 65535 which would be scaled depending on machine specifics. You could read the scaled value from the port, but you couldn't send scaled values in. This allows scripts to set scaled values as seen by the machine.
Diffstat (limited to 'src/frontend/mame/luaengine_input.cpp')
-rw-r--r-- | src/frontend/mame/luaengine_input.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/frontend/mame/luaengine_input.cpp b/src/frontend/mame/luaengine_input.cpp index 1812bdc17b3..4f13b7e2484 100644 --- a/src/frontend/mame/luaengine_input.cpp +++ b/src/frontend/mame/luaengine_input.cpp @@ -257,6 +257,7 @@ void lua_engine::initialize_input(sol::table &emu) auto ioport_field_type = sol().registry().new_usertype<ioport_field>("ioport_field", sol::no_constructor); ioport_field_type["set_value"] = &ioport_field::set_value; + ioport_field_type["clear_value"] = &ioport_field::clear_value; ioport_field_type["set_input_seq"] = [] (ioport_field &f, std::string const &seq_type_string, const input_seq &seq) { @@ -312,6 +313,16 @@ void lua_engine::initialize_input(sol::table &emu) ioport_field_type["player"] = sol::property(&ioport_field::player, &ioport_field::set_player); ioport_field_type["mask"] = sol::property(&ioport_field::mask); ioport_field_type["defvalue"] = sol::property(&ioport_field::defvalue); + ioport_field_type["minvalue"] = sol::property( + [] (ioport_field &f) + { + return f.is_analog() ? std::make_optional(f.minval()) : std::nullopt; + }); + ioport_field_type["maxvalue"] = sol::property( + [] (ioport_field &f) + { + return f.is_analog() ? std::make_optional(f.maxval()) : std::nullopt; + }); ioport_field_type["sensitivity"] = sol::property(&ioport_field::sensitivity); ioport_field_type["way"] = sol::property(&ioport_field::way); ioport_field_type["type_class"] = sol::property( |