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:
parent
ead44a27ca
commit
4ba438a7ec
7 changed files with 51 additions and 37 deletions
|
@ -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))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue