summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
author ajrhacker <ajrhacker@users.noreply.github.com>2019-08-24 01:00:06 -0400
committer GitHub <noreply@github.com>2019-08-24 01:00:06 -0400
commit8b4db00ad70b5a7144a2139a387b9714de73ddbb (patch)
tree15c7ebe8fcb5807f20153292eef430a618f3a93e
parentb96a689f971fe41d1dbc0bbbd4bdf48ab68e53af (diff)
parent225ef45b7d98c72c4ff34b80320bc26e7116d797 (diff)
Merge pull request #5528 from npwoods/lua_type_group_and_keyboard_codes
Exposing ioport_manager::type_group() and ioport_field::keyboard_codes() to LUA
-rw-r--r--src/frontend/mame/luaengine.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/frontend/mame/luaengine.cpp b/src/frontend/mame/luaengine.cpp
index 688dca7aa44..df730b7019f 100644
--- a/src/frontend/mame/luaengine.cpp
+++ b/src/frontend/mame/luaengine.cpp
@@ -1709,6 +1709,7 @@ void lua_engine::initialize()
* manager:machine():ioport()
*
* ioport:count_players() - get count of player controllers
+ * ioport:type_group(type, player)
*
* ioport.ports[] - ioports table (k=tag, v=ioport_port)
*/
@@ -1716,6 +1717,9 @@ void lua_engine::initialize()
sol().registry().new_usertype<ioport_manager>("ioport", "new", sol::no_constructor,
"count_players", &ioport_manager::count_players,
"natkeyboard", &ioport_manager::natkeyboard,
+ "type_group", [](ioport_manager &im, ioport_type type, int player) {
+ return im.type_group(type, player);
+ },
"ports", sol::property([this](ioport_manager &im) {
sol::table port_table = sol().create_table();
for (auto &port : im.ports())
@@ -1795,6 +1799,7 @@ void lua_engine::initialize()
* field:input_seq(seq_type)
* field:set_default_input_seq(seq_type, seq)
* field:default_input_seq(seq_type)
+ * field:keyboard_codes(which)
*
* field.device - get associated device_t
* field.port - get associated ioport_port
@@ -1846,6 +1851,14 @@ void lua_engine::initialize()
input_seq_type seq_type = parse_seq_type(seq_type_string);
return sol::make_user(f.defseq(seq_type));
},
+ "keyboard_codes", [this](ioport_field &f, int which)
+ {
+ sol::table result = sol().create_table();
+ int index = 1;
+ for (char32_t code : f.keyboard_codes(which))
+ result[index++] = code;
+ return result;
+ },
"device", sol::property(&ioport_field::device),
"port", sol::property(&ioport_field::port),
"name", sol::property(&ioport_field::name),