aboutsummaryrefslogtreecommitdiff
path: root/engines/scumm
diff options
context:
space:
mode:
authorMax Horn2007-06-23 11:53:24 +0000
committerMax Horn2007-06-23 11:53:24 +0000
commit302da0b8550081a8716b26043ab02124125a49b6 (patch)
tree4d98cdf0803ccbbbe9ff0c26540daced8b687721 /engines/scumm
parent3ce5f8abf3a1d293071eba7f640caa1ead0a9596 (diff)
downloadscummvm-rg350-302da0b8550081a8716b26043ab02124125a49b6.tar.gz
scummvm-rg350-302da0b8550081a8716b26043ab02124125a49b6.tar.bz2
scummvm-rg350-302da0b8550081a8716b26043ab02124125a49b6.zip
SCUMM: Added three FIXME comments to the _keyDownMap code, and made it use KEYCODE_ constants for clarity
svn-id: r27659
Diffstat (limited to 'engines/scumm')
-rw-r--r--engines/scumm/input.cpp13
-rw-r--r--engines/scumm/insane/insane.cpp4
-rw-r--r--engines/scumm/script_v6.cpp33
3 files changed, 36 insertions, 14 deletions
diff --git a/engines/scumm/input.cpp b/engines/scumm/input.cpp
index d8fc4dac5b..36440b102a 100644
--- a/engines/scumm/input.cpp
+++ b/engines/scumm/input.cpp
@@ -142,6 +142,19 @@ void ScummEngine::parseEvents() {
VAR(VAR_KEY_STATE) = _keyState;
}
+ // FIXME: There is a discrepancy between EVENT_KEYDOWN and EVENT_KEYUP here:
+ // For EVENT_KEYDOWN, we use _keyPressed.keycode, which has potentially been
+ // modified, while for EVENT_KEYUP we use the unfiltered event.kbd.keycode.
+ // This could lead problems (like a key becoming 'stuck').
+
+ // FIXME #2: We are mixing ascii and keycode values here. We probably should
+ // be using keycodes, but at least INSANE checks for "Shift-V" by looking for
+ // the 'V' key being pressed. It would be easy to solve that by also storing the
+ // the modifier flags. However, since getKeyState() is also called by scripts,
+ // we have to be very careful with semantic changes.
+ // Nevertheless, it's bad to rely on "ascii" holdoing keycode values for special
+ // keys (like the function keys), so this should be fixed.
+
if (_keyPressed.ascii >= 512)
debugC(DEBUG_GENERAL, "_keyPressed > 512 (%d)", _keyPressed.ascii);
else
diff --git a/engines/scumm/insane/insane.cpp b/engines/scumm/insane/insane.cpp
index f445fe490c..252407913e 100644
--- a/engines/scumm/insane/insane.cpp
+++ b/engines/scumm/insane/insane.cpp
@@ -580,10 +580,10 @@ int32 Insane::processKeyboard(void) {
_enemyState[EN_BEN][1] += tmpy;
}
- if (_vm->getKeyState(0x0d))
+ if (_vm->getKeyState(Common::KEYCODE_RETURN))
retval |= 1;
- if (_vm->getKeyState(0x09))
+ if (_vm->getKeyState(Common::KEYCODE_TAB))
retval |= 2;
return retval;
diff --git a/engines/scumm/script_v6.cpp b/engines/scumm/script_v6.cpp
index a408616942..7e0d705377 100644
--- a/engines/scumm/script_v6.cpp
+++ b/engines/scumm/script_v6.cpp
@@ -2803,25 +2803,34 @@ void ScummEngine_v6::o6_kernelGetFunctions() {
int ScummEngine::getKeyState(int key) {
switch (key) {
case 0x147: // Home
- return (_keyDownMap[0x107] || _keyDownMap[0x115]) ? 1 : 0;
+ // FIXME: There seems to be a mistake in the code here ("insert" vs. "home")
+ return (_keyDownMap[Common::KEYCODE_KP7] ||
+ _keyDownMap[Common::KEYCODE_INSERT]) ? 1 : 0;
case 0x148: // Up
- return (_keyDownMap[0x108] || _keyDownMap[0x111] ||
- _keyDownMap[0x38]) ? 1 : 0;
+ return (_keyDownMap[Common::KEYCODE_KP8] ||
+ _keyDownMap[Common::KEYCODE_UP] ||
+ _keyDownMap[Common::KEYCODE_8]) ? 1 : 0;
case 0x149: // PgUp
- return (_keyDownMap[0x109] || _keyDownMap[0x118]) ? 1 : 0;
+ return (_keyDownMap[Common::KEYCODE_KP9] ||
+ _keyDownMap[Common::KEYCODE_PAGEUP]) ? 1 : 0;
case 0x14B: // Left
- return (_keyDownMap[0x104] || _keyDownMap[0x114] ||
- _keyDownMap[0x34]) ? 1 : 0;
+ return (_keyDownMap[Common::KEYCODE_KP4] ||
+ _keyDownMap[Common::KEYCODE_LEFT] ||
+ _keyDownMap[Common::KEYCODE_4]) ? 1 : 0;
case 0x14D: // Right
- return (_keyDownMap[0x106] || _keyDownMap[0x113] ||
- _keyDownMap[0x36]) ? 1 : 0;
+ return (_keyDownMap[Common::KEYCODE_KP6] ||
+ _keyDownMap[Common::KEYCODE_RIGHT] ||
+ _keyDownMap[Common::KEYCODE_6]) ? 1 : 0;
case 0x14F: // End
- return (_keyDownMap[0x101] || _keyDownMap[0x117]) ? 1 : 0;
+ return (_keyDownMap[Common::KEYCODE_KP1] ||
+ _keyDownMap[Common::KEYCODE_END]) ? 1 : 0;
case 0x150: // Down
- return (_keyDownMap[0x102] || _keyDownMap[0x112] ||
- _keyDownMap[0x32]) ? 1 : 0;
+ return (_keyDownMap[Common::KEYCODE_KP2] ||
+ _keyDownMap[Common::KEYCODE_DOWN] ||
+ _keyDownMap[Common::KEYCODE_2]) ? 1 : 0;
case 0x151: // PgDn
- return (_keyDownMap[0x103] || _keyDownMap[0x119]) ? 1 : 0;
+ return (_keyDownMap[Common::KEYCODE_KP3] ||
+ _keyDownMap[Common::KEYCODE_PAGEDOWN]) ? 1 : 0;
default:
return (_keyDownMap[key]) ? 1 : 0;
}