diff options
author | lolbot-iichan | 2019-06-16 21:09:08 +0300 |
---|---|---|
committer | Filippos Karapetis | 2019-06-25 08:10:16 +0300 |
commit | c32027672eed9bddf90b953dada5f04b6f1a3656 (patch) | |
tree | 254131fb65b155f9c6c80576bf4f2d5868580a62 | |
parent | d53bd4e7a83d2a446b6217ea121aad413e91688a (diff) | |
download | scummvm-rg350-c32027672eed9bddf90b953dada5f04b6f1a3656.tar.gz scummvm-rg350-c32027672eed9bddf90b953dada5f04b6f1a3656.tar.bz2 scummvm-rg350-c32027672eed9bddf90b953dada5f04b6f1a3656.zip |
WINTERMUTE: Add comments + warning() for IsKeyDown() method
-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()); } |