aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/sword25/input/inputengine.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/engines/sword25/input/inputengine.cpp b/engines/sword25/input/inputengine.cpp
index a85096bc2f..0226458f5f 100644
--- a/engines/sword25/input/inputengine.cpp
+++ b/engines/sword25/input/inputengine.cpp
@@ -87,7 +87,14 @@ bool InputEngine::init() {
void InputEngine::update() {
Common::Event event;
+
+ // We keep two sets of keyboard states: The current one, and that of
+ // the previous frame. This allows us to detect which keys changed
+ // state. Also, by keeping a single central keystate array, we
+ // ensure that all script queries for key state during a single
+ // frame get the same consistent replies.
_currentState ^= 1;
+ memcpy(_keyboardState[_currentState], _keyboardState[_currentState ^ 1], sizeof(_keyboardState[0]));
// Loop through processing any pending events
bool handleEvents = true;