summaryrefslogtreecommitdiffstats
path: root/src/frontend/mame/luaengine_input.cpp
diff options
context:
space:
mode:
author Vas Crabb <vas@vastheman.com>2021-11-04 03:11:29 +1100
committer Vas Crabb <vas@vastheman.com>2021-11-04 03:11:29 +1100
commit13612bbe0f23030b32a78e09fa0ae217c2d341ca (patch)
tree81f20bc015644fe80821d8ef37203d926eba46f7 /src/frontend/mame/luaengine_input.cpp
parentd29287e0925a308e3cdaba615e32f194071e22d9 (diff)
-emu/ioport.cpp: Fixed some default setting handling issues.
* Issues were unlikely to actually manifest unless you use controller configuration files to change specific system input defaults. -src/emu/output.h: Added size accessor to multi-element output finder. * std::size will work on the top rank of an outut finder now. Sorry for hitting emu.h again so soon. -lua: Exposed a couple more input related things. * Exposed constructor and a few methods on input_seq required for scripts to properly clear assignments or restore default settings. * Exposed ioport_manager::set_type_seq which is required to configure general input assignments properly. * Removed unnecessary use of sol::overload in favour of optional parameters. * Updated documentation and also fixed a few errors. -docs: Added description for axis setting assignments.
Diffstat (limited to 'src/frontend/mame/luaengine_input.cpp')
-rw-r--r--src/frontend/mame/luaengine_input.cpp49
1 files changed, 34 insertions, 15 deletions
diff --git a/src/frontend/mame/luaengine_input.cpp b/src/frontend/mame/luaengine_input.cpp
index de8157e6dcd..f32858ccce3 100644
--- a/src/frontend/mame/luaengine_input.cpp
+++ b/src/frontend/mame/luaengine_input.cpp
@@ -151,24 +151,32 @@ void lua_engine::initialize_input(sol::table &emu)
ioport_manager_type["type_group"] = sol::overload(
&ioport_manager::type_group,
[] (ioport_manager &im, ioport_type type) { return im.type_group(type, 0); });
- ioport_manager_type["type_seq"] = sol::overload(
- [] (ioport_manager &im, ioport_type type, int player, char const *seq_type_string)
+ ioport_manager_type["type_seq"] =
+ [] (ioport_manager &im, ioport_type type, std::optional<int> player, std::optional<char const *> seq_type_string)
{
- input_seq_type seq_type = s_seq_type_parser(seq_type_string);
- return im.type_seq(type, player, seq_type);
- },
- [] (ioport_manager &im, ioport_type type, int player) { return im.type_seq(type, player, SEQ_TYPE_STANDARD); },
- [] (ioport_manager &im, ioport_type type) { return im.type_seq(type, 0, SEQ_TYPE_STANDARD); });
+ if (!player)
+ player = 0;
+ input_seq_type seq_type = seq_type_string ? s_seq_type_parser(*seq_type_string) : SEQ_TYPE_STANDARD;
+ return im.type_seq(type, *player, seq_type);
+ };
+ ioport_manager_type["set_type_seq"] =
+ [] (ioport_manager &im, ioport_type type, std::optional<int> player, std::optional<char const *> seq_type_string, input_seq const &seq)
+ {
+ if (!player)
+ player = 0;
+ input_seq_type seq_type = seq_type_string ? s_seq_type_parser(*seq_type_string) : SEQ_TYPE_STANDARD;
+ im.set_type_seq(type, *player, seq_type, seq);
+ };
ioport_manager_type["token_to_input_type"] =
- [] (ioport_manager &im, std::string const &string)
- {
- int player;
- ioport_type const type = im.token_to_input_type(string.c_str(), player);
- return std::make_tuple(type, player);
- };
+ [] (ioport_manager &im, std::string const &string)
+ {
+ int player;
+ ioport_type const type = im.token_to_input_type(string.c_str(), player);
+ return std::make_tuple(type, player);
+ };
ioport_manager_type["input_type_to_token"] = sol::overload(
- &ioport_manager::input_type_to_token,
- [] (ioport_manager &im, ioport_type type) { return im.input_type_to_token(type, 0); });
+ &ioport_manager::input_type_to_token,
+ [] (ioport_manager &im, ioport_type type) { return im.input_type_to_token(type, 0); });
ioport_manager_type["ports"] = sol::property([] (ioport_manager &im) { return tag_object_ptr_map<ioport_list>(im.ports()); });
@@ -402,6 +410,17 @@ void lua_engine::initialize_input(sol::table &emu)
seqpoll_type["modified"] = sol::property(&input_sequence_poller::modified);
+ auto iptseq_type = emu.new_usertype<input_seq>(
+ "input_seq",
+ sol::call_constructor, sol::constructors<input_seq(), input_seq(input_seq const &)>());
+ iptseq_type["reset"] = &input_seq::reset;
+ iptseq_type["set_default"] = &input_seq::set_default;
+ iptseq_type["empty"] = sol::property(&input_seq::empty);
+ iptseq_type["length"] = sol::property(&input_seq::length);
+ iptseq_type["is_valid"] = sol::property(&input_seq::is_valid);
+ iptseq_type["is_default"] = sol::property(&input_seq::is_default);
+
+
auto input_class_type = sol().registry().new_usertype<input_class>("input_class", sol::no_constructor);
input_class_type["name"] = sol::property(&input_class::name);
input_class_type["enabled"] = sol::property(&input_class::enabled);