diff --git a/res/layouts/pages/settings_controls.xml.lua b/res/layouts/pages/settings_controls.xml.lua index 879f21e5..c7c8632c 100644 --- a/res/layouts/pages/settings_controls.xml.lua +++ b/res/layouts/pages/settings_controls.xml.lua @@ -16,7 +16,7 @@ function on_open() refresh_sensitivity() local panel = document.bindings_panel - local bindings = core.get_bindings() + local bindings = input.get_bindings() table.sort(bindings, function(a, b) return a > b end) for i,name in ipairs(bindings) do panel:add(gui.template("binding", { diff --git a/src/logic/scripting/lua/libcore.cpp b/src/logic/scripting/lua/libcore.cpp index 86b4e9f6..b9df74f2 100644 --- a/src/logic/scripting/lua/libcore.cpp +++ b/src/logic/scripting/lua/libcore.cpp @@ -100,19 +100,6 @@ static int l_reconfig_packs(lua_State* L) { return 0; } -static int l_get_bindings(lua_State* L) { - auto& bindings = Events::bindings; - lua_createtable(L, bindings.size(), 0); - - int i = 0; - for (auto& entry : bindings) { - lua_pushstring(L, entry.first.c_str()); - lua_rawseti(L, -2, i + 1); - i++; - } - return 1; -} - static int l_get_setting(lua_State* L) { auto name = lua_tostring(L, 1); const auto value = scripting::engine->getSettingsHandler().getValue(name); @@ -186,7 +173,6 @@ const luaL_Reg corelib [] = { {"close_world", lua_wrap_errors}, {"delete_world", lua_wrap_errors}, {"reconfig_packs", lua_wrap_errors}, - {"get_bindings", lua_wrap_errors}, {"get_setting", lua_wrap_errors}, {"set_setting", lua_wrap_errors}, {"str_setting", lua_wrap_errors}, diff --git a/src/logic/scripting/lua/libinput.cpp b/src/logic/scripting/lua/libinput.cpp index ed415a16..d870509c 100644 --- a/src/logic/scripting/lua/libinput.cpp +++ b/src/logic/scripting/lua/libinput.cpp @@ -55,11 +55,25 @@ static int l_get_mouse_pos(lua_State* L) { return lua::pushvec2_arr(L, Events::cursor); } +static int l_get_bindings(lua_State* L) { + auto& bindings = Events::bindings; + lua_createtable(L, bindings.size(), 0); + + int i = 0; + for (auto& entry : bindings) { + lua_pushstring(L, entry.first.c_str()); + lua_rawseti(L, -2, i + 1); + i++; + } + return 1; +} + const luaL_Reg inputlib [] = { {"keycode", lua_wrap_errors}, {"mousecode", lua_wrap_errors}, {"add_callback", lua_wrap_errors}, {"get_mouse_pos", lua_wrap_errors}, + {"get_bindings", lua_wrap_errors}, {NULL, NULL} };