1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-10-05 19:31:04 +00:00

Move keybinding settings to (Lua-based) setting menu (#15791)

This commit is contained in:
y5nw 2025-04-20 20:20:49 +02:00 committed by GitHub
parent c1d2124102
commit 23bfb2db72
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
25 changed files with 591 additions and 782 deletions

View file

@ -16,7 +16,6 @@
#include "gui/touchcontrols.h"
#include "gui/touchscreeneditor.h"
#include "gui/guiPasswordChange.h"
#include "gui/guiKeyChangeMenu.h"
#include "gui/guiPasswordChange.h"
#include "gui/guiOpenURL.h"
#include "gui/guiVolumeChange.h"
@ -538,12 +537,6 @@ bool GameFormSpec::handleCallbacks()
g_gamecallback->changevolume_requested = false;
}
if (g_gamecallback->keyconfig_requested) {
(void)make_irr<GUIKeyChangeMenu>(guienv, guiroot, -1,
&g_menumgr, texture_src);
g_gamecallback->keyconfig_requested = false;
}
if (g_gamecallback->touchscreenlayout_requested) {
(new GUITouchscreenLayout(guienv, guiroot, -1,
&g_menumgr, texture_src))->drop();
@ -556,11 +549,6 @@ bool GameFormSpec::handleCallbacks()
g_gamecallback->show_open_url_dialog.clear();
}
if (g_gamecallback->keyconfig_changed) {
m_input->reloadKeybindings(); // update the cache with new settings
g_gamecallback->keyconfig_changed = false;
}
return true;
}

View file

@ -14,6 +14,8 @@
void MyEventReceiver::reloadKeybindings()
{
clearKeyCache();
keybindings[KeyType::FORWARD] = getKeySetting("keymap_forward");
keybindings[KeyType::BACKWARD] = getKeySetting("keymap_backward");
keybindings[KeyType::LEFT] = getKeySetting("keymap_left");

View file

@ -12,6 +12,8 @@
#include <set>
#include <unordered_map>
#include "keycode.h"
#include "settings.h"
#include "util/string.h"
class InputHandler;
@ -132,6 +134,13 @@ private:
class InputHandler
{
public:
InputHandler()
{
for (const auto &name: Settings::getLayer(SL_DEFAULTS)->getNames())
if (str_starts_with(name, "keymap_"))
g_settings->registerChangedCallback(name, &settingChangedCallback, this);
}
virtual ~InputHandler() = default;
virtual bool isRandom() const
@ -163,6 +172,11 @@ public:
virtual void clear() {}
virtual void releaseAllKeys() {}
static void settingChangedCallback(const std::string &name, void *data)
{
static_cast<InputHandler *>(data)->reloadKeybindings();
}
JoystickController joystick;
};