mirror of
https://github.com/holub/mame
synced 2025-06-21 03:36:33 +03:00
Changes LUA seq_poll_start to take the input_item_class as a string (#5503)
This seems to work around a problem that (at least for me) caused the 'sol::object seq' parameter to not properly handle a specified sol::user<input_seq>. This problem could be reproduced with the following command at the LUA console: manager:machine():input():seq_poll_start("absolute", manager:machine():input():seq_from_tokens("KEYCODE_Q")) I would feel more comfortable if I understood why the existing code failed; it isn't clear to me if this is a bug in our sol handling for input_item_class, a bug in sol itself, or a compiler bug, but this change works for me and should definitely not introduce any problems.
This commit is contained in:
parent
d7dce40b4a
commit
47447da16b
@ -145,33 +145,6 @@ namespace sol
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
template <>
|
template <>
|
||||||
struct checker<input_item_class>
|
|
||||||
{
|
|
||||||
template <typename Handler>
|
|
||||||
static bool check (lua_State* L, int index, Handler&& handler, record& tracking)
|
|
||||||
{
|
|
||||||
return stack::check<const std::string &>(L, index, handler);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
template <>
|
|
||||||
struct getter<input_item_class>
|
|
||||||
{
|
|
||||||
static input_item_class get(lua_State* L, int index, record& tracking)
|
|
||||||
{
|
|
||||||
const std::string item_class = stack::get<const std::string &>(L, index);
|
|
||||||
if(item_class == "switch")
|
|
||||||
return ITEM_CLASS_SWITCH;
|
|
||||||
else if(item_class == "absolute" || item_class == "abs")
|
|
||||||
return ITEM_CLASS_ABSOLUTE;
|
|
||||||
else if(item_class == "relative" || item_class == "rel")
|
|
||||||
return ITEM_CLASS_RELATIVE;
|
|
||||||
else if(item_class == "maximum" || item_class == "max")
|
|
||||||
return ITEM_CLASS_MAXIMUM;
|
|
||||||
else
|
|
||||||
return ITEM_CLASS_INVALID;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
template <>
|
|
||||||
struct pusher<sol::buffer *>
|
struct pusher<sol::buffer *>
|
||||||
{
|
{
|
||||||
static int push(lua_State* L, sol::buffer *buff)
|
static int push(lua_State* L, sol::buffer *buff)
|
||||||
@ -2052,7 +2025,19 @@ void lua_engine::initialize()
|
|||||||
"seq_pressed", [](input_manager &input, sol::user<input_seq> seq) { return input.seq_pressed(seq); },
|
"seq_pressed", [](input_manager &input, sol::user<input_seq> seq) { return input.seq_pressed(seq); },
|
||||||
"seq_to_tokens", [](input_manager &input, sol::user<input_seq> seq) { return input.seq_to_tokens(seq); },
|
"seq_to_tokens", [](input_manager &input, sol::user<input_seq> seq) { return input.seq_to_tokens(seq); },
|
||||||
"seq_name", [](input_manager &input, sol::user<input_seq> seq) { return input.seq_name(seq); },
|
"seq_name", [](input_manager &input, sol::user<input_seq> seq) { return input.seq_name(seq); },
|
||||||
"seq_poll_start", [](input_manager &input, input_item_class cls, sol::object seq) {
|
"seq_poll_start", [](input_manager &input, const char *cls_string, sol::object seq) {
|
||||||
|
input_item_class cls;
|
||||||
|
if (!strcmp(cls_string, "switch"))
|
||||||
|
cls = ITEM_CLASS_SWITCH;
|
||||||
|
else if (!strcmp(cls_string, "absolute") || !strcmp(cls_string, "abs"))
|
||||||
|
cls = ITEM_CLASS_ABSOLUTE;
|
||||||
|
else if (!strcmp(cls_string, "relative") || !strcmp(cls_string, "rel"))
|
||||||
|
cls = ITEM_CLASS_RELATIVE;
|
||||||
|
else if (!strcmp(cls_string, "maximum") || !strcmp(cls_string, "max"))
|
||||||
|
cls = ITEM_CLASS_MAXIMUM;
|
||||||
|
else
|
||||||
|
cls = ITEM_CLASS_INVALID;
|
||||||
|
|
||||||
input_seq *start = nullptr;
|
input_seq *start = nullptr;
|
||||||
if(seq.is<sol::user<input_seq>>())
|
if(seq.is<sol::user<input_seq>>())
|
||||||
start = &seq.as<sol::user<input_seq>>();
|
start = &seq.as<sol::user<input_seq>>();
|
||||||
|
Loading…
Reference in New Issue
Block a user