Exposing ioport_manager::type_group() and ioport_field::keyboard_codes()

to LUA
This commit is contained in:
npwoods 2019-08-23 20:01:49 -04:00
parent 70f176f74f
commit 225ef45b7d

View File

@ -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),