binding lock/unlock refactoring
This commit is contained in:
parent
4a4e9e8330
commit
7e25b6f825
@ -133,23 +133,14 @@ static int l_reset_bindings(lua::State*) {
|
||||
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);
|
||||
if (bind == Events::bindings.end()) {
|
||||
throw std::runtime_error("unknown binding " + util::quote(bindname));
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
||||
@ -164,5 +155,4 @@ const luaL_Reg inputlib[] = {
|
||||
{"is_pressed", lua::wrap<l_is_pressed>},
|
||||
{"reset_bindings", lua::wrap<l_reset_bindings>},
|
||||
{"enable_binding", lua::wrap<l_enable_binding>},
|
||||
{"disable_binding", lua::wrap<l_disable_binding>},
|
||||
{NULL, NULL}};
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user