1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-06-27 16:36:03 +00:00

Improve KeyPress handling (#15923)

* Pass KeyPress by value
* TouchControls: add setting change callback for keybindings
This commit is contained in:
y5nw 2025-03-21 12:07:51 +01:00 committed by GitHub
parent ead44a27ca
commit 4ba438a7ec
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 51 additions and 37 deletions

View file

@ -77,7 +77,7 @@ void KeyCache::populate()
if (handler) {
// First clear all keys, then re-add the ones we listen for
handler->dontListenForKeys();
for (const KeyPress &k : key) {
for (auto k : key) {
handler->listenForKey(k);
}
handler->listenForKey(EscapeKey);
@ -111,7 +111,7 @@ bool MyEventReceiver::OnEvent(const SEvent &event)
// This is separate from other keyboard handling so that it also works in menus.
if (event.EventType == EET_KEY_INPUT_EVENT) {
const KeyPress keyCode(event.KeyInput);
KeyPress keyCode(event.KeyInput);
if (keyCode == getKeySetting("keymap_fullscreen")) {
if (event.KeyInput.PressedDown && !fullscreen_is_down) {
IrrlichtDevice *device = RenderingEngine::get_raw_device();
@ -142,7 +142,7 @@ bool MyEventReceiver::OnEvent(const SEvent &event)
// Remember whether each key is down or up
if (event.EventType == irr::EET_KEY_INPUT_EVENT) {
const KeyPress keyCode(event.KeyInput);
KeyPress keyCode(event.KeyInput);
if (keyCode && keysListenedFor[keyCode]) { // ignore key input that is invalid or irrelevant for the game.
if (event.KeyInput.PressedDown) {
if (!IsKeyDown(keyCode))