diff options
Diffstat (limited to 'engines')
-rw-r--r-- | engines/wintermute/base/base_keyboard_state.cpp | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/engines/wintermute/base/base_keyboard_state.cpp b/engines/wintermute/base/base_keyboard_state.cpp index a9e2b8ca18..d3614bb357 100644 --- a/engines/wintermute/base/base_keyboard_state.cpp +++ b/engines/wintermute/base/base_keyboard_state.cpp @@ -84,13 +84,30 @@ bool BaseKeyboardState::scCallMethod(ScScript *script, ScStack *stack, ScStack * uint32 vKeyCode; if (val->_type == VAL_STRING && strlen(val->getString()) > 0) { + // IsKeyDown(strings) checks if a key with given ASCII code is pressed + // Only 1st character of given string is used for the check + + // This check must be case insensitive, which means that + // IsKeyDown("a") & IsKeyDown("A") are either both true or both false const char *str = val->getString(); char temp = str[0]; if (temp >= 'A' && temp <= 'Z') { temp += ('a' - 'A'); } - vKeyCode = (int)temp; + + // Common::KeyCode is equal to ASCII code for any lowercase ASCII character + if (temp >= ' ' && temp <= '~') { + vKeyCode = (int)temp; + } else { + warning("Unhandled IsKeyDown(string): check for non-ASCII character"); + vKeyCode = 0; + } } else { + // IsKeyDown(int) checks if a key with given keycode is pressed + // For letters, single keycode is used for upper and lower case + // This mean that IsKeyDown(65) is true for both 'a' and Shift+'a' + + // See "MSDN: Virtual-Key Codes" for more details on original WME keycodes vKeyCode = vKeyToKeyCode(val->getInt()); } |