1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-09-30 19:22:14 +00:00

Implement secondary keybindings

This commit is contained in:
y5nw 2025-03-23 21:55:45 +01:00 committed by y5nw
parent 4f42b4308c
commit f767a7a529
7 changed files with 51 additions and 25 deletions

View file

@ -436,7 +436,7 @@ bool GUIChatConsole::OnEvent(const SEvent& event)
}
// Key input
if (KeyPress(event.KeyInput) == getKeySetting("keymap_console")) {
if (keySettingHasMatch("keymap_console", event.KeyInput)) {
closeConsole();
// inhibit open so the_game doesn't reopen immediately

View file

@ -3995,7 +3995,7 @@ bool GUIFormSpecMenu::preprocessEvent(const SEvent& event)
if (event.EventType == EET_KEY_INPUT_EVENT) {
KeyPress kp(event.KeyInput);
if (kp == EscapeKey
|| kp == getKeySetting("keymap_inventory")
|| keySettingHasMatch("keymap_inventory", kp)
|| event.KeyInput.Key==KEY_RETURN) {
gui::IGUIElement *focused = Environment->getFocus();
if (focused && isMyChild(focused) &&
@ -4094,17 +4094,17 @@ bool GUIFormSpecMenu::OnEvent(const SEvent& event)
}
if (event.KeyInput.PressedDown && (
(kp == EscapeKey) ||
((m_client != NULL) && (kp == getKeySetting("keymap_inventory"))))) {
((m_client != NULL) && (keySettingHasMatch("keymap_inventory", kp))))) {
tryClose();
return true;
}
if (m_client != NULL && event.KeyInput.PressedDown &&
(kp == getKeySetting("keymap_screenshot"))) {
(keySettingHasMatch("keymap_screenshot", kp))) {
m_client->makeScreenshot();
}
if (event.KeyInput.PressedDown && kp == getKeySetting("keymap_toggle_debug")) {
if (event.KeyInput.PressedDown && keySettingHasMatch("keymap_toggle_debug", kp)) {
if (!m_client || m_client->checkPrivilege("debug"))
m_show_debug = !m_show_debug;
}

View file

@ -212,11 +212,11 @@ static KeyPress id_to_keypress(touch_gui_button_id id)
auto setting_name = id_to_setting(id);
assert(!setting_name.empty());
auto kp = getKeySetting(setting_name);
if (!kp)
const auto &keylist = getKeySetting(setting_name);
if (keylist.empty())
warningstream << "TouchControls: Unbound or invalid key for "
<< setting_name << ", hiding button." << std::endl;
return kp;
return keylist[0];
}