Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix keyWasDown in input handler
This was changed 291a6b7 but should have never been done.
  • Loading branch information
sfan5 committed Feb 23, 2021
1 parent 35b476c commit 9b59b2f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 9 deletions.
11 changes: 3 additions & 8 deletions src/client/inputhandler.cpp
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/client/inputhandler.h
Expand Up @@ -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
Expand Down

0 comments on commit 9b59b2f

Please sign in to comment.