]> git.lizzy.rs Git - dragonfireclient.git/commitdiff
Fix keyWasDown in input handler
authorsfan5 <sfan5@live.de>
Tue, 23 Feb 2021 13:21:15 +0000 (14:21 +0100)
committersfan5 <sfan5@live.de>
Tue, 23 Feb 2021 18:41:38 +0000 (19:41 +0100)
This was changed 291a6b70d674d9003f522b5875a60f7e2753e32b but should have never been done.

src/client/inputhandler.cpp
src/client/inputhandler.h

index 608a405a8a9baae21fc378a03ace302b557f757b..978baa320dead7c972608b60019f8742d5d64d30 100644 (file)
@@ -113,17 +113,12 @@ bool MyEventReceiver::OnEvent(const SEvent &event)
        if (event.EventType == irr::EET_KEY_INPUT_EVENT) {
                const KeyPress &keyCode = event.KeyInput;
                if (keysListenedFor[keyCode]) {
-                               // If the key is being held down then the OS may
-                               // send a continuous stream of keydown events.
-                               // In this case, we don't want to let this
-                               // stream reach the application as it will cause
-                               // certain actions to repeat constantly.
                        if (event.KeyInput.PressedDown) {
-                               if (!IsKeyDown(keyCode)) {
-                                       keyWasDown.set(keyCode);
+                               if (!IsKeyDown(keyCode))
                                        keyWasPressed.set(keyCode);
-                               }
+
                                keyIsDown.set(keyCode);
+                               keyWasDown.set(keyCode);
                        } else {
                                if (IsKeyDown(keyCode))
                                        keyWasReleased.set(keyCode);
index 7487bbdc70d719213ebd6dbb575efa001dded786..1fb4cf0ec337f50e14b8b734568b9faf8ff87077 100644 (file)
@@ -201,7 +201,7 @@ class MyEventReceiver : public IEventReceiver
        // The current state of keys
        KeyList keyIsDown;
 
-       // Whether a key was down
+       // Like keyIsDown but only reset when that key is read
        KeyList keyWasDown;
 
        // Whether a key has just been pressed