Skip to content

Commit 9b59b2f

Browse files
committedFeb 23, 2021
Fix keyWasDown in input handler
This was changed 291a6b7 but should have never been done.
1 parent 35b476c commit 9b59b2f

File tree

2 files changed

+4
-9
lines changed

2 files changed

+4
-9
lines changed
 

‎src/client/inputhandler.cpp

+3-8
Original file line numberDiff line numberDiff line change
@@ -113,17 +113,12 @@ bool MyEventReceiver::OnEvent(const SEvent &event)
113113
if (event.EventType == irr::EET_KEY_INPUT_EVENT) {
114114
const KeyPress &keyCode = event.KeyInput;
115115
if (keysListenedFor[keyCode]) {
116-
// If the key is being held down then the OS may
117-
// send a continuous stream of keydown events.
118-
// In this case, we don't want to let this
119-
// stream reach the application as it will cause
120-
// certain actions to repeat constantly.
121116
if (event.KeyInput.PressedDown) {
122-
if (!IsKeyDown(keyCode)) {
123-
keyWasDown.set(keyCode);
117+
if (!IsKeyDown(keyCode))
124118
keyWasPressed.set(keyCode);
125-
}
119+
126120
keyIsDown.set(keyCode);
121+
keyWasDown.set(keyCode);
127122
} else {
128123
if (IsKeyDown(keyCode))
129124
keyWasReleased.set(keyCode);

‎src/client/inputhandler.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ class MyEventReceiver : public IEventReceiver
201201
// The current state of keys
202202
KeyList keyIsDown;
203203

204-
// Whether a key was down
204+
// Like keyIsDown but only reset when that key is read
205205
KeyList keyWasDown;
206206

207207
// Whether a key has just been pressed

0 commit comments

Comments
 (0)
Please sign in to comment.