binding lock/unlock refactoring
This commit is contained in:
@@ -133,23 +133,14 @@ static int l_reset_bindings(lua::State*) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void enableBinding(std::string& bindname, bool enable) {
|
static int l_enable_binding(lua::State* L) {
|
||||||
|
std::string bindname = lua::require_string(L, 1);
|
||||||
|
bool enable = lua::toboolean(L, 2);
|
||||||
const auto& bind = Events::bindings.find(bindname);
|
const auto& bind = Events::bindings.find(bindname);
|
||||||
if (bind == Events::bindings.end()) {
|
if (bind == Events::bindings.end()) {
|
||||||
throw std::runtime_error("unknown binding " + util::quote(bindname));
|
throw std::runtime_error("unknown binding " + util::quote(bindname));
|
||||||
}
|
}
|
||||||
Events::bindings[bindname].enable = enable;
|
Events::bindings[bindname].enable = enable;
|
||||||
}
|
|
||||||
|
|
||||||
static int l_enable_binding(lua::State* L) {
|
|
||||||
std::string bindname = lua::require_string(L, 1);
|
|
||||||
enableBinding(bindname, true);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int l_disable_binding(lua::State* L) {
|
|
||||||
std::string bindname = lua::require_string(L, 1);
|
|
||||||
enableBinding(bindname, false);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -164,5 +155,4 @@ const luaL_Reg inputlib[] = {
|
|||||||
{"is_pressed", lua::wrap<l_is_pressed>},
|
{"is_pressed", lua::wrap<l_is_pressed>},
|
||||||
{"reset_bindings", lua::wrap<l_reset_bindings>},
|
{"reset_bindings", lua::wrap<l_reset_bindings>},
|
||||||
{"enable_binding", lua::wrap<l_enable_binding>},
|
{"enable_binding", lua::wrap<l_enable_binding>},
|
||||||
{"disable_binding", lua::wrap<l_disable_binding>},
|
|
||||||
{NULL, NULL}};
|
{NULL, NULL}};
|
||||||
|
|||||||
Reference in New Issue
Block a user