From aaf7ffdd5c160447cfa56468bf0a8c768d14ad5d Mon Sep 17 00:00:00 2001 From: Max Horn Date: Wed, 27 Oct 2010 15:53:53 +0000 Subject: SWORD25: Fix keyboard state handling Previously, you could get the game into a state where it would think a key was constantly being pressed. E.g. by pressing 'p' several times quickly in a row, the game would end in a state where it endlessly toggled between pause mode and regular mode. svn-id: r53878 --- engines/sword25/input/inputengine.cpp | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'engines/sword25/input') 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; -- cgit v1.2.3