From cd6f145577453c8025b9b4cb2b062fe80d5034f7 Mon Sep 17 00:00:00 2001 From: Max Horn Date: Sun, 3 Jun 2007 17:32:42 +0000 Subject: Modified version of patch #1723779: SCUMM: Improved ctrl+t subtitle cycling svn-id: r27068 --- engines/scumm/input.cpp | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) (limited to 'engines/scumm/input.cpp') diff --git a/engines/scumm/input.cpp b/engines/scumm/input.cpp index 50307ebc57..64c2169f53 100644 --- a/engines/scumm/input.cpp +++ b/engines/scumm/input.cpp @@ -414,27 +414,23 @@ void ScummEngine_v7::processKeyboard(int lastKeyHit) { void ScummEngine_v6::processKeyboard(int lastKeyHit) { if (lastKeyHit == 20) { - // FIXME: What key is '20' supposed to indicate? I can't trigger - // it with my keyboard, it seems... - char buf[256]; + // FIXME: The 20 seems to indicate Ctrl-T. Of course this is a + // rather ugly way to detect it -- modifier + ascii code would + // be a *lot* cleaner... - _voiceMode++; - if (_voiceMode == 3) - _voiceMode = 0; + SubtitleSettingsDialog dialog(this, _voiceMode); + _voiceMode = runDialog(dialog); switch (_voiceMode) { case 0: - sprintf(buf, "Speech Only"); ConfMan.setBool("speech_mute", false); ConfMan.setBool("subtitles", false); break; case 1: - sprintf(buf, "Speech and Subtitles"); ConfMan.setBool("speech_mute", false); ConfMan.setBool("subtitles", true); break; case 2: - sprintf(buf, "Subtitles Only"); ConfMan.setBool("speech_mute", true); ConfMan.setBool("subtitles", true); break; @@ -443,8 +439,6 @@ void ScummEngine_v6::processKeyboard(int lastKeyHit) { if (VAR_VOICE_MODE != 0xFF) VAR(VAR_VOICE_MODE) = _voiceMode; - GUI::TimedMessageDialog dialog(buf, 1500); - runDialog(dialog); return; } -- cgit v1.2.3 From 2b23374468549722c8068d448d9bbf5e100d7301 Mon Sep 17 00:00:00 2001 From: Max Horn Date: Fri, 22 Jun 2007 20:04:44 +0000 Subject: Converted lots of code to use Common::ASCII_* and COMMON::KEYCODE_* constants. This also revealed the evil mixing of keycodes and ascii we do in many places :-/ svn-id: r27616 --- engines/scumm/input.cpp | 43 ++++++++++++++++++++++--------------------- 1 file changed, 22 insertions(+), 21 deletions(-) (limited to 'engines/scumm/input.cpp') diff --git a/engines/scumm/input.cpp b/engines/scumm/input.cpp index 64c2169f53..4d390517a1 100644 --- a/engines/scumm/input.cpp +++ b/engines/scumm/input.cpp @@ -91,10 +91,11 @@ void ScummEngine::parseEvents() { // because that's what MI2 looks for in // its "instant win" cheat. _keyPressed = event.kbd.keycode + 154; - } else if (event.kbd.ascii == 315 && (_game.id == GID_CMI && !(_game.features & GF_DEMO))) { + } else if (event.kbd.ascii == Common::ASCII_F1 && (_game.id == GID_CMI && !(_game.features & GF_DEMO))) { // FIXME: support in-game menu screen. For now, this remaps F1 to F5 in COMI - _keyPressed = 319; - } else if (event.kbd.ascii < 273 || event.kbd.ascii > 276 || _game.version >= 7) { + _keyPressed = Common::ASCII_F5; + } else if (event.kbd.ascii < Common::KEYCODE_UP || event.kbd.ascii > Common::KEYCODE_LEFT || _game.version >= 7) { +// FIXME: Don't use ASCII value to detect arrow keys, rather, use keycode! // don't let game have arrow keys as we currently steal them // for keyboard cursor control // this fixes bug with up arrow (273) corresponding to @@ -106,8 +107,8 @@ void ScummEngine::parseEvents() { } if (_game.id == GID_MONKEY && _game.platform == Common::kPlatformSegaCD) { - if (event.kbd.ascii >= 273 && event.kbd.ascii <= 276) { - _keyPressed = event.kbd.ascii - 273 + 54; + if (event.kbd.ascii >= Common::KEYCODE_UP && event.kbd.ascii <= Common::KEYCODE_LEFT) { + _keyPressed = event.kbd.ascii - Common::KEYCODE_UP + 54; } } @@ -115,16 +116,16 @@ void ScummEngine::parseEvents() { // Keyboard is controlled via variable int _keyState = 0; - if (event.kbd.ascii == 276) // Left + if (event.kbd.ascii == Common::KEYCODE_LEFT) // Left _keyState = 1; - if (event.kbd.ascii == 275) // Right + if (event.kbd.ascii == Common::KEYCODE_RIGHT) // Right _keyState |= 2; - if (event.kbd.ascii == 273) // Up + if (event.kbd.ascii == Common::KEYCODE_UP) // Up _keyState |= 4; - if (event.kbd.ascii == 274) // Down + if (event.kbd.ascii == Common::KEYCODE_DOWN) // Down _keyState |= 8; if (event.kbd.flags == Common::KBD_SHIFT) @@ -240,8 +241,8 @@ void ScummEngine::clearClickedStatus() { void ScummEngine_v0::processInput() { // F1 - F3 - if (_keyPressed >= 315 && _keyPressed <= 317) { - switchActor(_keyPressed - 315); + if (_keyPressed >= Common::ASCII_F1 && _keyPressed <= Common::ASCII_F3) { + switchActor(_keyPressed - Common::ASCII_F1); } ScummEngine::processInput(); @@ -343,7 +344,7 @@ void ScummEngine_v8::processKeyboard(int lastKeyHit) { // Alt-F5 brings up the original save/load dialog if (lastKeyHit == 440 && !(_game.features & GF_DEMO)) { - lastKeyHit = 315; + lastKeyHit = Common::ASCII_F1; } // If a key script was specified (a V8 feature), and it's trigger @@ -449,14 +450,14 @@ void ScummEngine_v6::processKeyboard(int lastKeyHit) { void ScummEngine_v2::processKeyboard(int lastKeyHit) { if (lastKeyHit == ' ') { // space pauseGame(); - } else if (lastKeyHit == 314+5) { // F5 + } else if (lastKeyHit == Common::ASCII_F5) { mainMenuDialog(); - } else if (lastKeyHit == 314+8) { // F8 + } else if (lastKeyHit == Common::ASCII_F8) { confirmRestartDialog(); } else { if ((_game.version == 0 && lastKeyHit == 27) || - (VAR_CUTSCENEEXIT_KEY != 0xFF && lastKeyHit == 314+VAR(VAR_CUTSCENEEXIT_KEY))) { + (VAR_CUTSCENEEXIT_KEY != 0xFF && lastKeyHit == Common::ASCII_F1-1+VAR(VAR_CUTSCENEEXIT_KEY))) { abortCutscene(); } else { // Fall back to default behavior @@ -466,7 +467,7 @@ void ScummEngine_v2::processKeyboard(int lastKeyHit) { // Alt-F5 brings up the original save/load dialog if (lastKeyHit == 440) { - lastKeyHit = 314+5; + lastKeyHit = Common::ASCII_F5; } // Store the input type. So far we can't distinguish @@ -475,9 +476,9 @@ void ScummEngine_v2::processKeyboard(int lastKeyHit) { // 5) Sentence Bar if (VAR_KEYPRESS != 0xFF && lastKeyHit) { // Key Input - if (315 <= lastKeyHit && lastKeyHit < 315+12) { - // Convert F-Keys for V1/V2 games (they start at 1 instead of at 315) - VAR(VAR_KEYPRESS) = lastKeyHit - 314; + if (Common::ASCII_F1 <= lastKeyHit && lastKeyHit <= Common::ASCII_F9) { + // Convert F-Keys for V1/V2 games (they start at 1 instead of at ASCII_F1) + VAR(VAR_KEYPRESS) = lastKeyHit - Common::ASCII_F1 + 1; } else { VAR(VAR_KEYPRESS) = lastKeyHit; } @@ -486,7 +487,7 @@ void ScummEngine_v2::processKeyboard(int lastKeyHit) { } void ScummEngine_v3::processKeyboard(int lastKeyHit) { - if (_game.platform == Common::kPlatformFMTowns && lastKeyHit == 314+8) { // F8 + if (_game.platform == Common::kPlatformFMTowns && lastKeyHit == Common::ASCII_F8) { confirmRestartDialog(); } else { // Fall back to default behavior @@ -518,7 +519,7 @@ void ScummEngine::processKeyboard(int lastKeyHit) { int saveloadkey; if ((_game.version <= 3) || (_game.id == GID_SAMNMAX) || (_game.id == GID_CMI) || (_game.heversion >= 72)) - saveloadkey = 319; // F5 + saveloadkey = Common::ASCII_F5; else saveloadkey = VAR(VAR_MAINMENU_KEY); -- cgit v1.2.3 From 4e4358e8c33bfcf8213c5b9938551835d583f747 Mon Sep 17 00:00:00 2001 From: Max Horn Date: Sat, 23 Jun 2007 10:38:03 +0000 Subject: Made SCUMM use Common::KeyState, too (but implemented almost no fixes/optimizations based on this) svn-id: r27655 --- engines/scumm/input.cpp | 185 ++++++++++++++++++++++++++---------------------- 1 file changed, 102 insertions(+), 83 deletions(-) (limited to 'engines/scumm/input.cpp') diff --git a/engines/scumm/input.cpp b/engines/scumm/input.cpp index 4d390517a1..dce0340018 100644 --- a/engines/scumm/input.cpp +++ b/engines/scumm/input.cpp @@ -85,17 +85,21 @@ void ScummEngine::parseEvents() { else if (event.kbd.keycode == 's') _res->resourceStats(); else - _keyPressed = event.kbd.ascii; // Normal key press, pass on to the game. + _keyPressed = event.kbd; // Normal key press, pass on to the game. } else if (event.kbd.flags & Common::KBD_ALT) { // The result must be 273 for Alt-W // because that's what MI2 looks for in // its "instant win" cheat. - _keyPressed = event.kbd.keycode + 154; - } else if (event.kbd.ascii == Common::ASCII_F1 && (_game.id == GID_CMI && !(_game.features & GF_DEMO))) { + // FIXME: Handle this specific property inside processKeyboard ? + _keyPressed = event.kbd; + _keyPressed.ascii = event.kbd.keycode + 154; + } else if (event.kbd.ascii == Common::KEYCODE_F1 && (_game.id == GID_CMI && !(_game.features & GF_DEMO))) { // FIXME: support in-game menu screen. For now, this remaps F1 to F5 in COMI - _keyPressed = Common::ASCII_F5; - } else if (event.kbd.ascii < Common::KEYCODE_UP || event.kbd.ascii > Common::KEYCODE_LEFT || _game.version >= 7) { -// FIXME: Don't use ASCII value to detect arrow keys, rather, use keycode! + // FIXME: Handle this specific property inside processKeyboard ? + _keyPressed = Common::KeyState(Common::KEYCODE_F5, Common::ASCII_F5); + } else if (event.kbd.keycode < Common::KEYCODE_UP || event.kbd.keycode > Common::KEYCODE_LEFT || _game.version >= 7) { + // FIXME: Handle this specific property inside processKeyboard ? + // don't let game have arrow keys as we currently steal them // for keyboard cursor control // this fixes bug with up arrow (273) corresponding to @@ -103,12 +107,13 @@ void ScummEngine::parseEvents() { // // This is not applicable to Full Throttle as it processes keyboard // cursor control by itself. Also it fixes derby scene - _keyPressed = event.kbd.ascii; // Normal key press, pass on to the game. + _keyPressed = event.kbd; // Normal key press, pass on to the game. } if (_game.id == GID_MONKEY && _game.platform == Common::kPlatformSegaCD) { - if (event.kbd.ascii >= Common::KEYCODE_UP && event.kbd.ascii <= Common::KEYCODE_LEFT) { - _keyPressed = event.kbd.ascii - Common::KEYCODE_UP + 54; + if (event.kbd.keycode >= Common::KEYCODE_UP && event.kbd.keycode <= Common::KEYCODE_LEFT) { + _keyPressed = event.kbd; + _keyPressed.ascii = event.kbd.ascii - Common::KEYCODE_UP + 54; } } @@ -116,16 +121,16 @@ void ScummEngine::parseEvents() { // Keyboard is controlled via variable int _keyState = 0; - if (event.kbd.ascii == Common::KEYCODE_LEFT) // Left + if (event.kbd.keycode == Common::KEYCODE_LEFT) // Left _keyState = 1; - if (event.kbd.ascii == Common::KEYCODE_RIGHT) // Right + if (event.kbd.keycode == Common::KEYCODE_RIGHT) // Right _keyState |= 2; - if (event.kbd.ascii == Common::KEYCODE_UP) // Up + if (event.kbd.keycode == Common::KEYCODE_UP) // Up _keyState |= 4; - if (event.kbd.ascii == Common::KEYCODE_DOWN) // Down + if (event.kbd.keycode == Common::KEYCODE_DOWN) // Down _keyState |= 8; if (event.kbd.flags == Common::KBD_SHIFT) @@ -137,10 +142,10 @@ void ScummEngine::parseEvents() { VAR(VAR_KEY_STATE) = _keyState; } - if (_keyPressed >= 512) - debugC(DEBUG_GENERAL, "_keyPressed > 512 (%d)", _keyPressed); + if (_keyPressed.ascii >= 512) + debugC(DEBUG_GENERAL, "_keyPressed > 512 (%d)", _keyPressed.ascii); else - _keyDownMap[_keyPressed] = true; + _keyDownMap[_keyPressed.ascii] = true; break; case Common::EVENT_KEYUP: @@ -195,11 +200,11 @@ void ScummEngine::parseEvents() { // checking the gameid. Values are taken from script-14. case Common::EVENT_WHEELDOWN: - _keyPressed = 55; + _keyPressed = Common::KeyState(Common::KEYCODE_7, 55); // '7' break; case Common::EVENT_WHEELUP: - _keyPressed = 54; + _keyPressed = Common::KeyState(Common::KEYCODE_6, 54); // '6' break; case Common::EVENT_QUIT: @@ -219,20 +224,20 @@ void ScummEngine::parseEvents() { void ScummEngine_v90he::clearClickedStatus() { ScummEngine::clearClickedStatus(); if (_game.heversion >= 98) { - _logicHE->processKeyStroke(_keyPressed); + _logicHE->processKeyStroke(_keyPressed.ascii); } } void ScummEngine_v90he::processInput() { if (_game.heversion >= 98) { - _logicHE->processKeyStroke(_keyPressed); + _logicHE->processKeyStroke(_keyPressed.ascii); } ScummEngine::processInput(); } #endif void ScummEngine::clearClickedStatus() { - _keyPressed = 0; + _keyPressed.reset(); _mouseAndKeyboardStat = 0; _leftBtnPressed &= ~msClicked; @@ -241,15 +246,16 @@ void ScummEngine::clearClickedStatus() { void ScummEngine_v0::processInput() { // F1 - F3 - if (_keyPressed >= Common::ASCII_F1 && _keyPressed <= Common::ASCII_F3) { - switchActor(_keyPressed - Common::ASCII_F1); + if (_keyPressed.ascii >= Common::ASCII_F1 && _keyPressed.ascii <= Common::ASCII_F3) { + switchActor(_keyPressed.ascii - Common::ASCII_F1); } ScummEngine::processInput(); } + void ScummEngine::processInput() { - int lastKeyHit = _keyPressed; - _keyPressed = 0; + Common::KeyState lastKeyHit = _keyPressed; + _keyPressed.reset(); // // Clip the mouse coordinates, and compute _virtualMouse.x (and clip it, too) @@ -279,30 +285,36 @@ void ScummEngine::processInput() { _mouseAndKeyboardStat = 0; // Interpret 'return' as left click and 'tab' as right click - if (lastKeyHit && _cursor.state > 0) { - if (lastKeyHit == 9) { + if (lastKeyHit.keycode && _cursor.state > 0) { + if (lastKeyHit.keycode == Common::KEYCODE_TAB) { _mouseAndKeyboardStat = MBS_RIGHT_CLICK; - lastKeyHit = 0; - } else if (lastKeyHit == 13) { + lastKeyHit.reset(); + } else if (lastKeyHit.keycode == Common::KEYCODE_RETURN) { _mouseAndKeyboardStat = MBS_LEFT_CLICK; - lastKeyHit = 0; + lastKeyHit.reset(); } } - if (_leftBtnPressed & msClicked && _rightBtnPressed & msClicked && _game.version >= 4) { + if ((_leftBtnPressed & msClicked) && (_rightBtnPressed & msClicked) && _game.version >= 4) { // Pressing both mouse buttons is treated as if you pressed // the cutscene exit key (i.e. ESC in most games). That mimicks // the behaviour of the original engine where pressing both // mouse buttons also skips the current cutscene. _mouseAndKeyboardStat = 0; - lastKeyHit = (uint)VAR(VAR_CUTSCENEEXIT_KEY); - } else if (_rightBtnPressed & msClicked && (_game.version <= 3 && _game.id != GID_LOOM)) { + lastKeyHit.ascii = (uint)VAR(VAR_CUTSCENEEXIT_KEY); + lastKeyHit.keycode = (Common::KeyCode)lastKeyHit.ascii; + lastKeyHit.flags = 0; + //FIXME: lastKeyHit.keycode = ???; proper value??? + } else if ((_rightBtnPressed & msClicked) && (_game.version <= 3 && _game.id != GID_LOOM)) { // Pressing right mouse button is treated as if you pressed // the cutscene exit key (i.e. ESC in most games). That mimicks // the behaviour of the original engine where pressing right // mouse button also skips the current cutscene. _mouseAndKeyboardStat = 0; - lastKeyHit = (VAR_CUTSCENEEXIT_KEY != 0xFF) ? (uint)VAR(VAR_CUTSCENEEXIT_KEY) : 27; + lastKeyHit.ascii = (VAR_CUTSCENEEXIT_KEY != 0xFF) ? (uint)VAR(VAR_CUTSCENEEXIT_KEY) : 27; + lastKeyHit.keycode = (Common::KeyCode)lastKeyHit.ascii; + lastKeyHit.flags = 0; + //FIXME: lastKeyHit.keycode = ???; proper value??? } else if (_leftBtnPressed & msClicked) { _mouseAndKeyboardStat = MBS_LEFT_CLICK; } else if (_rightBtnPressed & msClicked) { @@ -323,33 +335,36 @@ void ScummEngine::processInput() { _rightBtnPressed &= ~msClicked; #ifdef _WIN32_WCE - if (lastKeyHit == KEY_ALL_SKIP) { + if (lastKeyHit.ascii == KEY_ALL_SKIP) { // Skip talk - if (VAR_TALKSTOP_KEY != 0xFF && _talkDelay > 0) - lastKeyHit = (uint)VAR(VAR_TALKSTOP_KEY); - else - // Escape - lastKeyHit = 27; + if (VAR_TALKSTOP_KEY != 0xFF && _talkDelay > 0) { + lastKeyHit.ascii = (uint)VAR(VAR_TALKSTOP_KEY); + lastKeyHit.keycode = (Common::KeyCode)lastKeyHit.ascii; + lastKeyHit.flags = 0; + //FIXME: lastKeyHit.keycode = ???; proper value??? + } else { + lastKeyHit = Common::KeySate(Common::KEYCODE_ESCAPE); + } } #endif - if (!lastKeyHit) + if (!lastKeyHit.ascii) return; processKeyboard(lastKeyHit); } #ifndef DISABLE_SCUMM_7_8 -void ScummEngine_v8::processKeyboard(int lastKeyHit) { +void ScummEngine_v8::processKeyboard(Common::KeyState lastKeyHit) { // Alt-F5 brings up the original save/load dialog - if (lastKeyHit == 440 && !(_game.features & GF_DEMO)) { - lastKeyHit = Common::ASCII_F1; + if (lastKeyHit.ascii == 440 && !(_game.features & GF_DEMO)) { + lastKeyHit = Common::KeyState(Common::KEYCODE_F1, Common::ASCII_F1); } // If a key script was specified (a V8 feature), and it's trigger // key was pressed, run it. - if (_keyScriptNo && (_keyScriptKey == lastKeyHit)) { + if (_keyScriptNo && (_keyScriptKey == lastKeyHit.ascii)) { runScript(_keyScriptNo, 0, 0, 0); return; } @@ -358,18 +373,18 @@ void ScummEngine_v8::processKeyboard(int lastKeyHit) { ScummEngine_v7::processKeyboard(lastKeyHit); } -void ScummEngine_v7::processKeyboard(int lastKeyHit) { +void ScummEngine_v7::processKeyboard(Common::KeyState lastKeyHit) { // COMI version string is hard coded in the engine, hence we don't // invoke versionDialog here (it would only show nonsense). // Dig/FT version strings are partly hard coded, too. - if (_game.version == 7 && lastKeyHit == VAR(VAR_VERSION_KEY)) { + if (_game.version == 7 && lastKeyHit.ascii == VAR(VAR_VERSION_KEY)) { versionDialog(); return; } #ifndef _WIN32_WCE - if (VAR_CUTSCENEEXIT_KEY != 0xFF && lastKeyHit == VAR(VAR_CUTSCENEEXIT_KEY)) { + if (VAR_CUTSCENEEXIT_KEY != 0xFF && lastKeyHit.ascii == VAR(VAR_CUTSCENEEXIT_KEY)) { // Skip cutscene (or active SMUSH video). if (_smushActive) { if (_game.id == GID_FT) @@ -380,14 +395,14 @@ void ScummEngine_v7::processKeyboard(int lastKeyHit) { if (!_smushActive || _smushVideoShouldFinish) abortCutscene(); - _mouseAndKeyboardStat = lastKeyHit; + _mouseAndKeyboardStat = lastKeyHit.ascii; return; } #else // On WinCE we've also got one special for skipping cutscenes or dialog, whatever is appropriate // Since _smushActive is not a member of the base case class ScummEngine::, we detect here if we're // playing a cutscene and skip it; else we forward the keystroke through to ScummEngine::processInput. - if (lastKeyHit == KEY_ALL_SKIP || (VAR_CUTSCENEEXIT_KEY != 0xFF && lastKeyHit == VAR(VAR_CUTSCENEEXIT_KEY))) { + if (lastKeyHit.ascii == KEY_ALL_SKIP || (VAR_CUTSCENEEXIT_KEY != 0xFF && lastKeyHit.ascii == VAR(VAR_CUTSCENEEXIT_KEY))) { int bail = 1; if (_smushActive) { if (_game.id == GID_FT) { @@ -413,8 +428,9 @@ void ScummEngine_v7::processKeyboard(int lastKeyHit) { } #endif -void ScummEngine_v6::processKeyboard(int lastKeyHit) { - if (lastKeyHit == 20) { +void ScummEngine_v6::processKeyboard(Common::KeyState lastKeyHit) { +printf("lastKeyHit ascii %d, keycode %d, flags %d\n", lastKeyHit.ascii, lastKeyHit.keycode, lastKeyHit.flags); + if (lastKeyHit.ascii == 20) { // FIXME: The 20 seems to indicate Ctrl-T. Of course this is a // rather ugly way to detect it -- modifier + ascii code would // be a *lot* cleaner... @@ -447,17 +463,17 @@ void ScummEngine_v6::processKeyboard(int lastKeyHit) { ScummEngine::processKeyboard(lastKeyHit); } -void ScummEngine_v2::processKeyboard(int lastKeyHit) { - if (lastKeyHit == ' ') { // space +void ScummEngine_v2::processKeyboard(Common::KeyState lastKeyHit) { + if (lastKeyHit.ascii == ' ') { // space pauseGame(); - } else if (lastKeyHit == Common::ASCII_F5) { + } else if (lastKeyHit.ascii == Common::ASCII_F5) { mainMenuDialog(); - } else if (lastKeyHit == Common::ASCII_F8) { + } else if (lastKeyHit.ascii == Common::ASCII_F8) { confirmRestartDialog(); } else { - if ((_game.version == 0 && lastKeyHit == 27) || - (VAR_CUTSCENEEXIT_KEY != 0xFF && lastKeyHit == Common::ASCII_F1-1+VAR(VAR_CUTSCENEEXIT_KEY))) { + if ((_game.version == 0 && lastKeyHit.ascii == 27) || + (VAR_CUTSCENEEXIT_KEY != 0xFF && lastKeyHit.ascii == Common::ASCII_F1-1+VAR(VAR_CUTSCENEEXIT_KEY))) { abortCutscene(); } else { // Fall back to default behavior @@ -466,8 +482,9 @@ void ScummEngine_v2::processKeyboard(int lastKeyHit) { // Alt-F5 brings up the original save/load dialog - if (lastKeyHit == 440) { - lastKeyHit = Common::ASCII_F5; + // FIXME -- use keycode + flags instead + if (lastKeyHit.ascii == 440) { + lastKeyHit = Common::KeyState(Common::KEYCODE_F5, Common::ASCII_F5); } // Store the input type. So far we can't distinguish @@ -475,19 +492,19 @@ void ScummEngine_v2::processKeyboard(int lastKeyHit) { // 1) Verb 2) Scene 3) Inv. 4) Key // 5) Sentence Bar - if (VAR_KEYPRESS != 0xFF && lastKeyHit) { // Key Input - if (Common::ASCII_F1 <= lastKeyHit && lastKeyHit <= Common::ASCII_F9) { + if (VAR_KEYPRESS != 0xFF && lastKeyHit.ascii) { // Key Input + if (Common::ASCII_F1 <= lastKeyHit.ascii && lastKeyHit.ascii <= Common::ASCII_F9) { // Convert F-Keys for V1/V2 games (they start at 1 instead of at ASCII_F1) - VAR(VAR_KEYPRESS) = lastKeyHit - Common::ASCII_F1 + 1; + VAR(VAR_KEYPRESS) = lastKeyHit.ascii - Common::ASCII_F1 + 1; } else { - VAR(VAR_KEYPRESS) = lastKeyHit; + VAR(VAR_KEYPRESS) = lastKeyHit.ascii; } } } } -void ScummEngine_v3::processKeyboard(int lastKeyHit) { - if (_game.platform == Common::kPlatformFMTowns && lastKeyHit == Common::ASCII_F8) { +void ScummEngine_v3::processKeyboard(Common::KeyState lastKeyHit) { + if (_game.platform == Common::kPlatformFMTowns && lastKeyHit.ascii == Common::ASCII_F8) { confirmRestartDialog(); } else { // Fall back to default behavior @@ -496,7 +513,7 @@ void ScummEngine_v3::processKeyboard(int lastKeyHit) { // i brings up an IQ dialog in Indy3 - if (lastKeyHit == 'i' && _game.id == GID_INDY3) { + if (lastKeyHit.ascii == 'i' && _game.id == GID_INDY3) { // SCUMM var 244 is the episode score // and var 245 is the series score char text[50]; @@ -515,7 +532,7 @@ void ScummEngine_v3::processKeyboard(int lastKeyHit) { } } -void ScummEngine::processKeyboard(int lastKeyHit) { +void ScummEngine::processKeyboard(Common::KeyState lastKeyHit) { int saveloadkey; if ((_game.version <= 3) || (_game.id == GID_SAMNMAX) || (_game.id == GID_CMI) || (_game.heversion >= 72)) @@ -525,12 +542,14 @@ void ScummEngine::processKeyboard(int lastKeyHit) { // Alt-F5 brings up the original save/load dialog. - if (lastKeyHit == 440 && _game.version > 2 && _game.version < 8) { - lastKeyHit = saveloadkey; + if (lastKeyHit.ascii == 440 && _game.version > 2 && _game.version < 8) { + // FIXME + lastKeyHit = Common::KeyState((Common::KeyCode)saveloadkey); + saveloadkey = -1; } - if (lastKeyHit == saveloadkey) { + if (lastKeyHit.ascii == saveloadkey) { if (VAR_SAVELOAD_SCRIPT != 0xFF && _currentRoom != 0) runScript(VAR(VAR_SAVELOAD_SCRIPT), 0, 0, 0); @@ -539,25 +558,25 @@ void ScummEngine::processKeyboard(int lastKeyHit) { if (VAR_SAVELOAD_SCRIPT != 0xFF && _currentRoom != 0) runScript(VAR(VAR_SAVELOAD_SCRIPT2), 0, 0, 0); - } else if (VAR_RESTART_KEY != 0xFF && lastKeyHit == VAR(VAR_RESTART_KEY)) { + } else if (VAR_RESTART_KEY != 0xFF && lastKeyHit.ascii == VAR(VAR_RESTART_KEY)) { confirmRestartDialog(); - } else if (VAR_PAUSE_KEY != 0xFF && lastKeyHit == VAR(VAR_PAUSE_KEY)) { + } else if (VAR_PAUSE_KEY != 0xFF && lastKeyHit.ascii == VAR(VAR_PAUSE_KEY)) { pauseGame(); - } else if (VAR_TALKSTOP_KEY != 0xFF && lastKeyHit == VAR(VAR_TALKSTOP_KEY)) { + } else if (VAR_TALKSTOP_KEY != 0xFF && lastKeyHit.ascii == VAR(VAR_TALKSTOP_KEY)) { _talkDelay = 0; if (_sound->_sfxMode & 2) stopTalk(); } else { - if (VAR_CUTSCENEEXIT_KEY != 0xFF && lastKeyHit == VAR(VAR_CUTSCENEEXIT_KEY)) { + if (VAR_CUTSCENEEXIT_KEY != 0xFF && lastKeyHit.ascii == VAR(VAR_CUTSCENEEXIT_KEY)) { abortCutscene(); - } else if (lastKeyHit == '[' || lastKeyHit == ']') { // Change music volume + } else if (lastKeyHit.ascii == '[' || lastKeyHit.ascii == ']') { // Change music volume int vol = ConfMan.getInt("music_volume") / 16; - if (lastKeyHit == ']' && vol < 16) + if (lastKeyHit.ascii == ']' && vol < 16) vol++; - else if (lastKeyHit == '[' && vol > 0) + else if (lastKeyHit.ascii == '[' && vol > 0) vol--; // Display the music volume @@ -570,10 +589,10 @@ void ScummEngine::processKeyboard(int lastKeyHit) { ConfMan.setInt("music_volume", vol); updateSoundSettings(); - } else if (lastKeyHit == '-' || lastKeyHit == '+') { // Change text speed - if (lastKeyHit == '+' && _defaultTalkDelay > 0) + } else if (lastKeyHit.ascii == '-' || lastKeyHit.ascii == '+') { // Change text speed + if (lastKeyHit.ascii == '+' && _defaultTalkDelay > 0) _defaultTalkDelay--; - else if (lastKeyHit == '-' && _defaultTalkDelay < 9) + else if (lastKeyHit.ascii == '-' && _defaultTalkDelay < 9) _defaultTalkDelay++; // Display the talk speed @@ -585,11 +604,11 @@ void ScummEngine::processKeyboard(int lastKeyHit) { if (VAR_CHARINC != 0xFF) VAR(VAR_CHARINC) = _defaultTalkDelay; - } else if (lastKeyHit == '~' || lastKeyHit == '#') { // Debug console + } else if (lastKeyHit.ascii == '~' || lastKeyHit.ascii == '#') { // Debug console _debugger->attach(); } - _mouseAndKeyboardStat = lastKeyHit; + _mouseAndKeyboardStat = lastKeyHit.ascii; } } -- cgit v1.2.3 From 3ce5f8abf3a1d293071eba7f640caa1ead0a9596 Mon Sep 17 00:00:00 2001 From: Max Horn Date: Sat, 23 Jun 2007 10:46:32 +0000 Subject: Made use of full Common::KeyState in SCUMM (there is still lots of room for improvements, though) svn-id: r27656 --- engines/scumm/input.cpp | 34 ++++++++++++++-------------------- 1 file changed, 14 insertions(+), 20 deletions(-) (limited to 'engines/scumm/input.cpp') diff --git a/engines/scumm/input.cpp b/engines/scumm/input.cpp index dce0340018..d8fc4dac5b 100644 --- a/engines/scumm/input.cpp +++ b/engines/scumm/input.cpp @@ -93,7 +93,7 @@ void ScummEngine::parseEvents() { // FIXME: Handle this specific property inside processKeyboard ? _keyPressed = event.kbd; _keyPressed.ascii = event.kbd.keycode + 154; - } else if (event.kbd.ascii == Common::KEYCODE_F1 && (_game.id == GID_CMI && !(_game.features & GF_DEMO))) { + } else if (event.kbd.keycode == Common::KEYCODE_F1 && (_game.id == GID_CMI && !(_game.features & GF_DEMO))) { // FIXME: support in-game menu screen. For now, this remaps F1 to F5 in COMI // FIXME: Handle this specific property inside processKeyboard ? _keyPressed = Common::KeyState(Common::KEYCODE_F5, Common::ASCII_F5); @@ -246,8 +246,8 @@ void ScummEngine::clearClickedStatus() { void ScummEngine_v0::processInput() { // F1 - F3 - if (_keyPressed.ascii >= Common::ASCII_F1 && _keyPressed.ascii <= Common::ASCII_F3) { - switchActor(_keyPressed.ascii - Common::ASCII_F1); + if (_keyPressed.keycode >= Common::KEYCODE_F1 && _keyPressed.keycode <= Common::KEYCODE_F3) { + switchActor(_keyPressed.keycode - Common::KEYCODE_F1); } ScummEngine::processInput(); @@ -358,7 +358,7 @@ void ScummEngine::processInput() { void ScummEngine_v8::processKeyboard(Common::KeyState lastKeyHit) { // Alt-F5 brings up the original save/load dialog - if (lastKeyHit.ascii == 440 && !(_game.features & GF_DEMO)) { + if (lastKeyHit.keycode == Common::KEYCODE_F5 && lastKeyHit.flags == Common::KBD_ALT && !(_game.features & GF_DEMO)) { lastKeyHit = Common::KeyState(Common::KEYCODE_F1, Common::ASCII_F1); } @@ -429,12 +429,7 @@ void ScummEngine_v7::processKeyboard(Common::KeyState lastKeyHit) { #endif void ScummEngine_v6::processKeyboard(Common::KeyState lastKeyHit) { -printf("lastKeyHit ascii %d, keycode %d, flags %d\n", lastKeyHit.ascii, lastKeyHit.keycode, lastKeyHit.flags); - if (lastKeyHit.ascii == 20) { - // FIXME: The 20 seems to indicate Ctrl-T. Of course this is a - // rather ugly way to detect it -- modifier + ascii code would - // be a *lot* cleaner... - + if (lastKeyHit.keycode == Common::KEYCODE_t && lastKeyHit.flags == Common::KBD_CTRL) { SubtitleSettingsDialog dialog(this, _voiceMode); _voiceMode = runDialog(dialog); @@ -466,13 +461,13 @@ printf("lastKeyHit ascii %d, keycode %d, flags %d\n", lastKeyHit.ascii, lastKeyH void ScummEngine_v2::processKeyboard(Common::KeyState lastKeyHit) { if (lastKeyHit.ascii == ' ') { // space pauseGame(); - } else if (lastKeyHit.ascii == Common::ASCII_F5) { + } else if (lastKeyHit.keycode == Common::KEYCODE_F5 && lastKeyHit.flags == 0) { mainMenuDialog(); - } else if (lastKeyHit.ascii == Common::ASCII_F8) { + } else if (lastKeyHit.keycode == Common::KEYCODE_F8 && lastKeyHit.flags == 0) { confirmRestartDialog(); } else { - if ((_game.version == 0 && lastKeyHit.ascii == 27) || + if ((_game.version == 0 && lastKeyHit.keycode == Common::KEYCODE_ESCAPE) || (VAR_CUTSCENEEXIT_KEY != 0xFF && lastKeyHit.ascii == Common::ASCII_F1-1+VAR(VAR_CUTSCENEEXIT_KEY))) { abortCutscene(); } else { @@ -482,8 +477,7 @@ void ScummEngine_v2::processKeyboard(Common::KeyState lastKeyHit) { // Alt-F5 brings up the original save/load dialog - // FIXME -- use keycode + flags instead - if (lastKeyHit.ascii == 440) { + if (lastKeyHit.keycode == Common::KEYCODE_F5 && lastKeyHit.flags == Common::KBD_ALT) { lastKeyHit = Common::KeyState(Common::KEYCODE_F5, Common::ASCII_F5); } @@ -492,10 +486,10 @@ void ScummEngine_v2::processKeyboard(Common::KeyState lastKeyHit) { // 1) Verb 2) Scene 3) Inv. 4) Key // 5) Sentence Bar - if (VAR_KEYPRESS != 0xFF && lastKeyHit.ascii) { // Key Input - if (Common::ASCII_F1 <= lastKeyHit.ascii && lastKeyHit.ascii <= Common::ASCII_F9) { + if (VAR_KEYPRESS != 0xFF && lastKeyHit.keycode) { // Key Input + if (Common::KEYCODE_F1 <= lastKeyHit.keycode && lastKeyHit.keycode <= Common::KEYCODE_F12) { // Convert F-Keys for V1/V2 games (they start at 1 instead of at ASCII_F1) - VAR(VAR_KEYPRESS) = lastKeyHit.ascii - Common::ASCII_F1 + 1; + VAR(VAR_KEYPRESS) = lastKeyHit.ascii - Common::KEYCODE_F1 + 1; } else { VAR(VAR_KEYPRESS) = lastKeyHit.ascii; } @@ -504,7 +498,7 @@ void ScummEngine_v2::processKeyboard(Common::KeyState lastKeyHit) { } void ScummEngine_v3::processKeyboard(Common::KeyState lastKeyHit) { - if (_game.platform == Common::kPlatformFMTowns && lastKeyHit.ascii == Common::ASCII_F8) { + if (_game.platform == Common::kPlatformFMTowns && lastKeyHit.keycode == Common::KEYCODE_F8 && lastKeyHit.flags == 0) { confirmRestartDialog(); } else { // Fall back to default behavior @@ -542,7 +536,7 @@ void ScummEngine::processKeyboard(Common::KeyState lastKeyHit) { // Alt-F5 brings up the original save/load dialog. - if (lastKeyHit.ascii == 440 && _game.version > 2 && _game.version < 8) { + if (lastKeyHit.keycode == Common::KEYCODE_F5 && lastKeyHit.flags == Common::KBD_ALT && _game.version > 2 && _game.version < 8) { // FIXME lastKeyHit = Common::KeyState((Common::KeyCode)saveloadkey); -- cgit v1.2.3 From 302da0b8550081a8716b26043ab02124125a49b6 Mon Sep 17 00:00:00 2001 From: Max Horn Date: Sat, 23 Jun 2007 11:53:24 +0000 Subject: SCUMM: Added three FIXME comments to the _keyDownMap code, and made it use KEYCODE_ constants for clarity svn-id: r27659 --- engines/scumm/input.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'engines/scumm/input.cpp') 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 -- cgit v1.2.3 From 0a21b0c1f15ad1987a63074f25f0460e0e061811 Mon Sep 17 00:00:00 2001 From: Travis Howell Date: Sat, 23 Jun 2007 12:24:49 +0000 Subject: Correct typo. svn-id: r27662 --- engines/scumm/input.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/scumm/input.cpp') diff --git a/engines/scumm/input.cpp b/engines/scumm/input.cpp index 36440b102a..b4962bc773 100644 --- a/engines/scumm/input.cpp +++ b/engines/scumm/input.cpp @@ -356,7 +356,7 @@ void ScummEngine::processInput() { lastKeyHit.flags = 0; //FIXME: lastKeyHit.keycode = ???; proper value??? } else { - lastKeyHit = Common::KeySate(Common::KEYCODE_ESCAPE); + lastKeyHit = Common::KeyState(Common::KEYCODE_ESCAPE); } } #endif -- cgit v1.2.3 From 518cedec9d32902bede6e839878fa02d886f1f4c Mon Sep 17 00:00:00 2001 From: Max Horn Date: Sat, 23 Jun 2007 12:31:42 +0000 Subject: Moved F1 key remapping in COMI to a more appropriate place svn-id: r27663 --- engines/scumm/input.cpp | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'engines/scumm/input.cpp') diff --git a/engines/scumm/input.cpp b/engines/scumm/input.cpp index b4962bc773..8b5167aa54 100644 --- a/engines/scumm/input.cpp +++ b/engines/scumm/input.cpp @@ -93,10 +93,6 @@ void ScummEngine::parseEvents() { // FIXME: Handle this specific property inside processKeyboard ? _keyPressed = event.kbd; _keyPressed.ascii = event.kbd.keycode + 154; - } else if (event.kbd.keycode == Common::KEYCODE_F1 && (_game.id == GID_CMI && !(_game.features & GF_DEMO))) { - // FIXME: support in-game menu screen. For now, this remaps F1 to F5 in COMI - // FIXME: Handle this specific property inside processKeyboard ? - _keyPressed = Common::KeyState(Common::KEYCODE_F5, Common::ASCII_F5); } else if (event.kbd.keycode < Common::KEYCODE_UP || event.kbd.keycode > Common::KEYCODE_LEFT || _game.version >= 7) { // FIXME: Handle this specific property inside processKeyboard ? @@ -369,10 +365,17 @@ void ScummEngine::processInput() { #ifndef DISABLE_SCUMM_7_8 void ScummEngine_v8::processKeyboard(Common::KeyState lastKeyHit) { - // Alt-F5 brings up the original save/load dialog - if (lastKeyHit.keycode == Common::KEYCODE_F5 && lastKeyHit.flags == Common::KBD_ALT && !(_game.features & GF_DEMO)) { - lastKeyHit = Common::KeyState(Common::KEYCODE_F1, Common::ASCII_F1); + if (!(_game.features & GF_DEMO)) { + // F1 (the trigger for the original save/load dialog) is mapped to F5 + if (lastKeyHit.keycode == Common::KEYCODE_F1 && lastKeyHit.flags == 0) { + lastKeyHit = Common::KeyState(Common::KEYCODE_F5, Common::ASCII_F5); + } + + // Alt-F5 brings up the original save/load dialog + if (lastKeyHit.keycode == Common::KEYCODE_F5 && lastKeyHit.flags == Common::KBD_ALT) { + lastKeyHit = Common::KeyState(Common::KEYCODE_F1, Common::ASCII_F1); + } } // If a key script was specified (a V8 feature), and it's trigger -- cgit v1.2.3 From dcae6d14a4f475c42c5f759ff422b0e2808f427c Mon Sep 17 00:00:00 2001 From: Max Horn Date: Sat, 23 Jun 2007 14:16:04 +0000 Subject: Changed the way VAR_VERSION_KEY is handled svn-id: r27665 --- engines/scumm/input.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'engines/scumm/input.cpp') diff --git a/engines/scumm/input.cpp b/engines/scumm/input.cpp index 8b5167aa54..aaad0ff30c 100644 --- a/engines/scumm/input.cpp +++ b/engines/scumm/input.cpp @@ -391,10 +391,12 @@ void ScummEngine_v8::processKeyboard(Common::KeyState lastKeyHit) { void ScummEngine_v7::processKeyboard(Common::KeyState lastKeyHit) { - // COMI version string is hard coded in the engine, hence we don't - // invoke versionDialog here (it would only show nonsense). - // Dig/FT version strings are partly hard coded, too. - if (_game.version == 7 && lastKeyHit.ascii == VAR(VAR_VERSION_KEY)) { + // VAR_VERSION_KEY (usually ctrl-v) is used in COMI, Dig and FT to trigger + // a version dialog, unless VAR_VERSION_KEY is set to 0. However, the COMI + // version string is hard coded in the engine, hence we don't invoke + // versionDialog for it. Dig/FT version strings are partly hard coded, too. + if (_game.id != GID_CMI && 0 != VAR(VAR_VERSION_KEY) && + lastKeyHit.keycode == Common::KEYCODE_v && lastKeyHit.flags == Common::KBD_CTRL) { versionDialog(); return; } -- cgit v1.2.3 From 4297ccc96481872e9b47428c5ed36d6db0a450de Mon Sep 17 00:00:00 2001 From: Max Horn Date: Sat, 23 Jun 2007 16:02:50 +0000 Subject: Revised SCUMM's input code. We now fix the keys F5, '.', space, escape for mainmenu, talkstop, pause, cutsceneExit; this simplifies and clarifies the code, and ensures consistent game behavior svn-id: r27672 --- engines/scumm/input.cpp | 97 +++++++++++++++++++++++++++---------------------- 1 file changed, 53 insertions(+), 44 deletions(-) (limited to 'engines/scumm/input.cpp') diff --git a/engines/scumm/input.cpp b/engines/scumm/input.cpp index aaad0ff30c..ef27937976 100644 --- a/engines/scumm/input.cpp +++ b/engines/scumm/input.cpp @@ -306,24 +306,18 @@ void ScummEngine::processInput() { if ((_leftBtnPressed & msClicked) && (_rightBtnPressed & msClicked) && _game.version >= 4) { // Pressing both mouse buttons is treated as if you pressed - // the cutscene exit key (i.e. ESC in most games). That mimicks + // the cutscene exit key (ESC) in V4+ games. That mimicks // the behaviour of the original engine where pressing both // mouse buttons also skips the current cutscene. _mouseAndKeyboardStat = 0; - lastKeyHit.ascii = (uint)VAR(VAR_CUTSCENEEXIT_KEY); - lastKeyHit.keycode = (Common::KeyCode)lastKeyHit.ascii; - lastKeyHit.flags = 0; - //FIXME: lastKeyHit.keycode = ???; proper value??? + lastKeyHit = Common::KeyState(Common::KEYCODE_ESCAPE); } else if ((_rightBtnPressed & msClicked) && (_game.version <= 3 && _game.id != GID_LOOM)) { // Pressing right mouse button is treated as if you pressed - // the cutscene exit key (i.e. ESC in most games). That mimicks + // the cutscene exit key (ESC) in V0-V3 games. That mimicks // the behaviour of the original engine where pressing right // mouse button also skips the current cutscene. _mouseAndKeyboardStat = 0; - lastKeyHit.ascii = (VAR_CUTSCENEEXIT_KEY != 0xFF) ? (uint)VAR(VAR_CUTSCENEEXIT_KEY) : 27; - lastKeyHit.keycode = (Common::KeyCode)lastKeyHit.ascii; - lastKeyHit.flags = 0; - //FIXME: lastKeyHit.keycode = ???; proper value??? + lastKeyHit = Common::KeyState(Common::KEYCODE_ESCAPE); } else if (_leftBtnPressed & msClicked) { _mouseAndKeyboardStat = MBS_LEFT_CLICK; } else if (_rightBtnPressed & msClicked) { @@ -347,10 +341,7 @@ void ScummEngine::processInput() { if (lastKeyHit.ascii == KEY_ALL_SKIP) { // Skip talk if (VAR_TALKSTOP_KEY != 0xFF && _talkDelay > 0) { - lastKeyHit.ascii = (uint)VAR(VAR_TALKSTOP_KEY); - lastKeyHit.keycode = (Common::KeyCode)lastKeyHit.ascii; - lastKeyHit.flags = 0; - //FIXME: lastKeyHit.keycode = ???; proper value??? + lastKeyHit = Common::KeyState(Common::KEYCODE_PERIOD, '.'); } else { lastKeyHit = Common::KeyState(Common::KEYCODE_ESCAPE); } @@ -401,8 +392,10 @@ void ScummEngine_v7::processKeyboard(Common::KeyState lastKeyHit) { return; } + const bool cutsceneExitKeyEnabled = (VAR_CUTSCENEEXIT_KEY != 0xFF && VAR(VAR_CUTSCENEEXIT_KEY) != 0); + #ifndef _WIN32_WCE - if (VAR_CUTSCENEEXIT_KEY != 0xFF && lastKeyHit.ascii == VAR(VAR_CUTSCENEEXIT_KEY)) { + if (cutsceneExitKeyEnabled && lastKeyHit.keycode == Common::KEYCODE_ESCAPE) { // Skip cutscene (or active SMUSH video). if (_smushActive) { if (_game.id == GID_FT) @@ -413,14 +406,15 @@ void ScummEngine_v7::processKeyboard(Common::KeyState lastKeyHit) { if (!_smushActive || _smushVideoShouldFinish) abortCutscene(); - _mouseAndKeyboardStat = lastKeyHit.ascii; + _mouseAndKeyboardStat = Common::ASCII_ESCAPE; return; } #else // On WinCE we've also got one special for skipping cutscenes or dialog, whatever is appropriate // Since _smushActive is not a member of the base case class ScummEngine::, we detect here if we're // playing a cutscene and skip it; else we forward the keystroke through to ScummEngine::processInput. - if (lastKeyHit.ascii == KEY_ALL_SKIP || (VAR_CUTSCENEEXIT_KEY != 0xFF && lastKeyHit.ascii == VAR(VAR_CUTSCENEEXIT_KEY))) { + if (cutsceneExitKeyEnabled && (lastKeyHit.ascii == KEY_ALL_SKIP || lastKeyHit.keycode == Common::KEYCODE_ESCAPE)) { +// FIXME: I do not quite understand why this code behaves differently on WinCE ?!? int bail = 1; if (_smushActive) { if (_game.id == GID_FT) { @@ -434,7 +428,7 @@ void ScummEngine_v7::processKeyboard(Common::KeyState lastKeyHit) { bail = 0; } if (!bail) { - _mouseAndKeyboardStat = (VAR_CUTSCENEEXIT_KEY != 0xFF) ? (uint)VAR(VAR_CUTSCENEEXIT_KEY) : 27; + _mouseAndKeyboardStat = Common::ASCII_ESCAPE; return; } @@ -485,8 +479,10 @@ void ScummEngine_v2::processKeyboard(Common::KeyState lastKeyHit) { confirmRestartDialog(); } else { - if ((_game.version == 0 && lastKeyHit.keycode == Common::KEYCODE_ESCAPE) || - (VAR_CUTSCENEEXIT_KEY != 0xFF && lastKeyHit.ascii == Common::ASCII_F1-1+VAR(VAR_CUTSCENEEXIT_KEY))) { + const bool cutsceneExitKeyEnabled = (_game.version == 0) || + ((VAR_CUTSCENEEXIT_KEY != 0xFF) ? (VAR(VAR_CUTSCENEEXIT_KEY) != 0) : false); + + if (cutsceneExitKeyEnabled && (lastKeyHit.keycode == Common::KEYCODE_ESCAPE || lastKeyHit.keycode == Common::KEYCODE_F4)) { abortCutscene(); } else { // Fall back to default behavior @@ -494,7 +490,6 @@ void ScummEngine_v2::processKeyboard(Common::KeyState lastKeyHit) { } // Alt-F5 brings up the original save/load dialog - if (lastKeyHit.keycode == Common::KEYCODE_F5 && lastKeyHit.flags == Common::KBD_ALT) { lastKeyHit = Common::KeyState(Common::KEYCODE_F5, Common::ASCII_F5); } @@ -506,8 +501,8 @@ void ScummEngine_v2::processKeyboard(Common::KeyState lastKeyHit) { if (VAR_KEYPRESS != 0xFF && lastKeyHit.keycode) { // Key Input if (Common::KEYCODE_F1 <= lastKeyHit.keycode && lastKeyHit.keycode <= Common::KEYCODE_F12) { - // Convert F-Keys for V1/V2 games (they start at 1 instead of at ASCII_F1) - VAR(VAR_KEYPRESS) = lastKeyHit.ascii - Common::KEYCODE_F1 + 1; + // Convert F-Keys for V1/V2 games (they start at 1) + VAR(VAR_KEYPRESS) = lastKeyHit.keycode - Common::KEYCODE_F1 + 1; } else { VAR(VAR_KEYPRESS) = lastKeyHit.ascii; } @@ -516,7 +511,10 @@ void ScummEngine_v2::processKeyboard(Common::KeyState lastKeyHit) { } void ScummEngine_v3::processKeyboard(Common::KeyState lastKeyHit) { - if (_game.platform == Common::kPlatformFMTowns && lastKeyHit.keycode == Common::KEYCODE_F8 && lastKeyHit.flags == 0) { + const bool restartKeyEnabled = (_game.platform == Common::kPlatformFMTowns); + + // F8 in FM-TOWNS games always triggers restart + if (restartKeyEnabled && (lastKeyHit.keycode == Common::KEYCODE_F8 && lastKeyHit.flags == 0)) { confirmRestartDialog(); } else { // Fall back to default behavior @@ -545,23 +543,31 @@ void ScummEngine_v3::processKeyboard(Common::KeyState lastKeyHit) { } void ScummEngine::processKeyboard(Common::KeyState lastKeyHit) { - int saveloadkey; + const bool restartKeyEnabled = (VAR_RESTART_KEY != 0xFF && VAR(VAR_RESTART_KEY) != 0); + const bool pauseKeyEnabled = (VAR_PAUSE_KEY != 0xFF && VAR(VAR_PAUSE_KEY) != 0); + const bool talkstopKeyEnabled = (VAR_TALKSTOP_KEY != 0xFF && VAR(VAR_TALKSTOP_KEY) != 0); + const bool cutsceneExitKeyEnabled = (VAR_CUTSCENEEXIT_KEY != 0xFF && VAR(VAR_CUTSCENEEXIT_KEY) != 0); + bool mainmenuKeyEnabled = true; + + // For games which use VAR_MAINMENU_KEY, disable the mainmenu key if + // requested by the scripts. We make an exception for COMI (i.e. + // forcefully always enable it there), as that always disables it. + if (VAR_MAINMENU_KEY != 0xFF && (_game.id != GID_CMI)) + mainmenuKeyEnabled = (VAR(VAR_MAINMENU_KEY) != 0); + +/* + FIXME: We also used to force-enable F5 in Sam&Max and HE >= 72 games -- why? if ((_game.version <= 3) || (_game.id == GID_SAMNMAX) || (_game.id == GID_CMI) || (_game.heversion >= 72)) - saveloadkey = Common::ASCII_F5; - else - saveloadkey = VAR(VAR_MAINMENU_KEY); - - // Alt-F5 brings up the original save/load dialog. + mainmenuKeyEnabled = true; +*/ - if (lastKeyHit.keycode == Common::KEYCODE_F5 && lastKeyHit.flags == Common::KBD_ALT && _game.version > 2 && _game.version < 8) { - // FIXME - lastKeyHit = Common::KeyState((Common::KeyCode)saveloadkey); - - saveloadkey = -1; - } + // Alt-F5 should bring up the original save/load dialog, if any. + // Hence remap it to F5 + if ((_game.version > 2 && _game.version < 8) && (lastKeyHit.keycode == Common::KEYCODE_F5 && lastKeyHit.flags == Common::KBD_ALT)) { + _mouseAndKeyboardStat = 319; // SCUMM encoding for F5 - if (lastKeyHit.ascii == saveloadkey) { + } else if (mainmenuKeyEnabled && (lastKeyHit.keycode == Common::KEYCODE_F5 && lastKeyHit.flags == 0)) { if (VAR_SAVELOAD_SCRIPT != 0xFF && _currentRoom != 0) runScript(VAR(VAR_SAVELOAD_SCRIPT), 0, 0, 0); @@ -570,21 +576,24 @@ void ScummEngine::processKeyboard(Common::KeyState lastKeyHit) { if (VAR_SAVELOAD_SCRIPT != 0xFF && _currentRoom != 0) runScript(VAR(VAR_SAVELOAD_SCRIPT2), 0, 0, 0); - } else if (VAR_RESTART_KEY != 0xFF && lastKeyHit.ascii == VAR(VAR_RESTART_KEY)) { + } else if (restartKeyEnabled && (lastKeyHit.keycode == Common::KEYCODE_F8 && lastKeyHit.flags == 0)) { confirmRestartDialog(); - } else if (VAR_PAUSE_KEY != 0xFF && lastKeyHit.ascii == VAR(VAR_PAUSE_KEY)) { + } else if (pauseKeyEnabled && (lastKeyHit.keycode == Common::KEYCODE_SPACE && lastKeyHit.flags == 0)) { pauseGame(); - } else if (VAR_TALKSTOP_KEY != 0xFF && lastKeyHit.ascii == VAR(VAR_TALKSTOP_KEY)) { + } else if (talkstopKeyEnabled && (lastKeyHit.keycode == Common::KEYCODE_PERIOD && lastKeyHit.flags == 0)) { _talkDelay = 0; if (_sound->_sfxMode & 2) stopTalk(); + } else if (cutsceneExitKeyEnabled && (lastKeyHit.keycode == Common::KEYCODE_ESCAPE && lastKeyHit.flags == 0)) { + abortCutscene(); + _mouseAndKeyboardStat = VAR(VAR_CUTSCENEEXIT_KEY); + } else { - if (VAR_CUTSCENEEXIT_KEY != 0xFF && lastKeyHit.ascii == VAR(VAR_CUTSCENEEXIT_KEY)) { - abortCutscene(); - } else if (lastKeyHit.ascii == '[' || lastKeyHit.ascii == ']') { // Change music volume + + if (lastKeyHit.ascii == '[' || lastKeyHit.ascii == ']') { // Change music volume int vol = ConfMan.getInt("music_volume") / 16; if (lastKeyHit.ascii == ']' && vol < 16) vol++; @@ -619,7 +628,7 @@ void ScummEngine::processKeyboard(Common::KeyState lastKeyHit) { } else if (lastKeyHit.ascii == '~' || lastKeyHit.ascii == '#') { // Debug console _debugger->attach(); } - + _mouseAndKeyboardStat = lastKeyHit.ascii; } } -- cgit v1.2.3 From f18132f5b83495510eb5cf52a69d0cd265094f00 Mon Sep 17 00:00:00 2001 From: Max Horn Date: Sat, 23 Jun 2007 16:05:38 +0000 Subject: Simplify code: Since processInput() always overwrite the value of lastKeyHit if KEY_ALL_SKIP is seen, we can never encounter KEY_ALL_SKIP at this spot svn-id: r27673 --- engines/scumm/input.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/scumm/input.cpp') diff --git a/engines/scumm/input.cpp b/engines/scumm/input.cpp index ef27937976..5bb5fd80b7 100644 --- a/engines/scumm/input.cpp +++ b/engines/scumm/input.cpp @@ -413,7 +413,7 @@ void ScummEngine_v7::processKeyboard(Common::KeyState lastKeyHit) { // On WinCE we've also got one special for skipping cutscenes or dialog, whatever is appropriate // Since _smushActive is not a member of the base case class ScummEngine::, we detect here if we're // playing a cutscene and skip it; else we forward the keystroke through to ScummEngine::processInput. - if (cutsceneExitKeyEnabled && (lastKeyHit.ascii == KEY_ALL_SKIP || lastKeyHit.keycode == Common::KEYCODE_ESCAPE)) { + if (cutsceneExitKeyEnabled && lastKeyHit.keycode == Common::KEYCODE_ESCAPE) { // FIXME: I do not quite understand why this code behaves differently on WinCE ?!? int bail = 1; if (_smushActive) { -- cgit v1.2.3 From 558a28f69deedc3da905f322526eb29efb071a5a Mon Sep 17 00:00:00 2001 From: Max Horn Date: Sat, 23 Jun 2007 16:07:38 +0000 Subject: Removing WinCE specific code in ScummEngine_v7::processKeyboard -- it made no sense at all. If this breaks something, please contact me so that we can properly fix it together svn-id: r27674 --- engines/scumm/input.cpp | 26 -------------------------- 1 file changed, 26 deletions(-) (limited to 'engines/scumm/input.cpp') diff --git a/engines/scumm/input.cpp b/engines/scumm/input.cpp index 5bb5fd80b7..cfd263b487 100644 --- a/engines/scumm/input.cpp +++ b/engines/scumm/input.cpp @@ -394,7 +394,6 @@ void ScummEngine_v7::processKeyboard(Common::KeyState lastKeyHit) { const bool cutsceneExitKeyEnabled = (VAR_CUTSCENEEXIT_KEY != 0xFF && VAR(VAR_CUTSCENEEXIT_KEY) != 0); -#ifndef _WIN32_WCE if (cutsceneExitKeyEnabled && lastKeyHit.keycode == Common::KEYCODE_ESCAPE) { // Skip cutscene (or active SMUSH video). if (_smushActive) { @@ -409,31 +408,6 @@ void ScummEngine_v7::processKeyboard(Common::KeyState lastKeyHit) { _mouseAndKeyboardStat = Common::ASCII_ESCAPE; return; } -#else - // On WinCE we've also got one special for skipping cutscenes or dialog, whatever is appropriate - // Since _smushActive is not a member of the base case class ScummEngine::, we detect here if we're - // playing a cutscene and skip it; else we forward the keystroke through to ScummEngine::processInput. - if (cutsceneExitKeyEnabled && lastKeyHit.keycode == Common::KEYCODE_ESCAPE) { -// FIXME: I do not quite understand why this code behaves differently on WinCE ?!? - int bail = 1; - if (_smushActive) { - if (_game.id == GID_FT) { - _insane->escapeKeyHandler(); - bail = 0; - } else - _smushVideoShouldFinish = true; - } - if ((!_smushActive && vm.cutScenePtr[vm.cutSceneStackPointer]) || _smushVideoShouldFinish) { - abortCutscene(); - bail = 0; - } - if (!bail) { - _mouseAndKeyboardStat = Common::ASCII_ESCAPE; - return; - } - - } -#endif // Fall back to V6 behavior ScummEngine_v6::processKeyboard(lastKeyHit); -- cgit v1.2.3 From 1a07bfb2215b1e218fc1694ede1d734211f979e9 Mon Sep 17 00:00:00 2001 From: Max Horn Date: Sat, 23 Jun 2007 16:27:28 +0000 Subject: Reworked the SCUMM input code even more: Merged various code paths and streamlined stuff; as a consequence, e.g. talkstop works in V0-V2 games, too; but also regressions may turn up. Also don't rely on Common::ASCII_F1 etc. values to compute SCUMM specific key codes svn-id: r27675 --- engines/scumm/input.cpp | 163 +++++++++++++++++++++--------------------------- 1 file changed, 72 insertions(+), 91 deletions(-) (limited to 'engines/scumm/input.cpp') diff --git a/engines/scumm/input.cpp b/engines/scumm/input.cpp index cfd263b487..a2a90d4cf9 100644 --- a/engines/scumm/input.cpp +++ b/engines/scumm/input.cpp @@ -360,12 +360,12 @@ void ScummEngine_v8::processKeyboard(Common::KeyState lastKeyHit) { if (!(_game.features & GF_DEMO)) { // F1 (the trigger for the original save/load dialog) is mapped to F5 if (lastKeyHit.keycode == Common::KEYCODE_F1 && lastKeyHit.flags == 0) { - lastKeyHit = Common::KeyState(Common::KEYCODE_F5, Common::ASCII_F5); + lastKeyHit = Common::KeyState(Common::KEYCODE_F5); } // Alt-F5 brings up the original save/load dialog if (lastKeyHit.keycode == Common::KEYCODE_F5 && lastKeyHit.flags == Common::KBD_ALT) { - lastKeyHit = Common::KeyState(Common::KEYCODE_F1, Common::ASCII_F1); + lastKeyHit = Common::KeyState(Common::KEYCODE_F1); } } @@ -392,7 +392,7 @@ void ScummEngine_v7::processKeyboard(Common::KeyState lastKeyHit) { return; } - const bool cutsceneExitKeyEnabled = (VAR_CUTSCENEEXIT_KEY != 0xFF && VAR(VAR_CUTSCENEEXIT_KEY) != 0); + const bool cutsceneExitKeyEnabled = (VAR_CUTSCENEEXIT_KEY == 0xFF || VAR(VAR_CUTSCENEEXIT_KEY) != 0); if (cutsceneExitKeyEnabled && lastKeyHit.keycode == Common::KEYCODE_ESCAPE) { // Skip cutscene (or active SMUSH video). @@ -445,58 +445,29 @@ void ScummEngine_v6::processKeyboard(Common::KeyState lastKeyHit) { } void ScummEngine_v2::processKeyboard(Common::KeyState lastKeyHit) { - if (lastKeyHit.ascii == ' ') { // space - pauseGame(); - } else if (lastKeyHit.keycode == Common::KEYCODE_F5 && lastKeyHit.flags == 0) { - mainMenuDialog(); - } else if (lastKeyHit.keycode == Common::KEYCODE_F8 && lastKeyHit.flags == 0) { - confirmRestartDialog(); - } else { + // Fall back to default behavior + ScummEngine::processKeyboard(lastKeyHit); - const bool cutsceneExitKeyEnabled = (_game.version == 0) || - ((VAR_CUTSCENEEXIT_KEY != 0xFF) ? (VAR(VAR_CUTSCENEEXIT_KEY) != 0) : false); + // Store the input type. So far we can't distinguish + // between 1, 3 and 5. + // 1) Verb 2) Scene 3) Inv. 4) Key + // 5) Sentence Bar - if (cutsceneExitKeyEnabled && (lastKeyHit.keycode == Common::KEYCODE_ESCAPE || lastKeyHit.keycode == Common::KEYCODE_F4)) { - abortCutscene(); + if (VAR_KEYPRESS != 0xFF && _mouseAndKeyboardStat) { // Key Input + if (315 <= _mouseAndKeyboardStat && _mouseAndKeyboardStat <= 323) { + // Convert F-Keys for V1/V2 games (they start at 1) + VAR(VAR_KEYPRESS) = _mouseAndKeyboardStat - 314; } else { - // Fall back to default behavior - ScummEngine::processKeyboard(lastKeyHit); - } - - // Alt-F5 brings up the original save/load dialog - if (lastKeyHit.keycode == Common::KEYCODE_F5 && lastKeyHit.flags == Common::KBD_ALT) { - lastKeyHit = Common::KeyState(Common::KEYCODE_F5, Common::ASCII_F5); - } - - // Store the input type. So far we can't distinguish - // between 1, 3 and 5. - // 1) Verb 2) Scene 3) Inv. 4) Key - // 5) Sentence Bar - - if (VAR_KEYPRESS != 0xFF && lastKeyHit.keycode) { // Key Input - if (Common::KEYCODE_F1 <= lastKeyHit.keycode && lastKeyHit.keycode <= Common::KEYCODE_F12) { - // Convert F-Keys for V1/V2 games (they start at 1) - VAR(VAR_KEYPRESS) = lastKeyHit.keycode - Common::KEYCODE_F1 + 1; - } else { - VAR(VAR_KEYPRESS) = lastKeyHit.ascii; - } + VAR(VAR_KEYPRESS) = _mouseAndKeyboardStat; } } } void ScummEngine_v3::processKeyboard(Common::KeyState lastKeyHit) { - const bool restartKeyEnabled = (_game.platform == Common::kPlatformFMTowns); - - // F8 in FM-TOWNS games always triggers restart - if (restartKeyEnabled && (lastKeyHit.keycode == Common::KEYCODE_F8 && lastKeyHit.flags == 0)) { - confirmRestartDialog(); - } else { - // Fall back to default behavior - ScummEngine::processKeyboard(lastKeyHit); - } - - // i brings up an IQ dialog in Indy3 + // Fall back to default behavior + ScummEngine::processKeyboard(lastKeyHit); + // 'i' brings up an IQ dialog in Indy3 if (lastKeyHit.ascii == 'i' && _game.id == GID_INDY3) { // SCUMM var 244 is the episode score // and var 245 is the series score @@ -517,18 +488,22 @@ void ScummEngine_v3::processKeyboard(Common::KeyState lastKeyHit) { } void ScummEngine::processKeyboard(Common::KeyState lastKeyHit) { - const bool restartKeyEnabled = (VAR_RESTART_KEY != 0xFF && VAR(VAR_RESTART_KEY) != 0); - const bool pauseKeyEnabled = (VAR_PAUSE_KEY != 0xFF && VAR(VAR_PAUSE_KEY) != 0); - const bool talkstopKeyEnabled = (VAR_TALKSTOP_KEY != 0xFF && VAR(VAR_TALKSTOP_KEY) != 0); - const bool cutsceneExitKeyEnabled = (VAR_CUTSCENEEXIT_KEY != 0xFF && VAR(VAR_CUTSCENEEXIT_KEY) != 0); + // Enable the following five special keys conditionally: + bool restartKeyEnabled = (VAR_RESTART_KEY == 0xFF || VAR(VAR_RESTART_KEY) != 0); + bool pauseKeyEnabled = (VAR_PAUSE_KEY == 0xFF || VAR(VAR_PAUSE_KEY) != 0); + bool talkstopKeyEnabled = (VAR_TALKSTOP_KEY == 0xFF || VAR(VAR_TALKSTOP_KEY) != 0); + bool cutsceneExitKeyEnabled = (VAR_CUTSCENEEXIT_KEY == 0xFF || VAR(VAR_CUTSCENEEXIT_KEY) != 0); + bool mainmenuKeyEnabled = (VAR_MAINMENU_KEY == 0xFF || VAR(VAR_MAINMENU_KEY) != 0); + + // In FM-TOWNS games F8 / restart is always enabled + if (_game.platform == Common::kPlatformFMTowns) + restartKeyEnabled = true; - bool mainmenuKeyEnabled = true; - // For games which use VAR_MAINMENU_KEY, disable the mainmenu key if // requested by the scripts. We make an exception for COMI (i.e. // forcefully always enable it there), as that always disables it. - if (VAR_MAINMENU_KEY != 0xFF && (_game.id != GID_CMI)) - mainmenuKeyEnabled = (VAR(VAR_MAINMENU_KEY) != 0); + if (_game.id == GID_CMI) + mainmenuKeyEnabled = true; /* FIXME: We also used to force-enable F5 in Sam&Max and HE >= 72 games -- why? @@ -563,47 +538,53 @@ void ScummEngine::processKeyboard(Common::KeyState lastKeyHit) { } else if (cutsceneExitKeyEnabled && (lastKeyHit.keycode == Common::KEYCODE_ESCAPE && lastKeyHit.flags == 0)) { abortCutscene(); + + // FIXME: Is the following line really necessary? _mouseAndKeyboardStat = VAR(VAR_CUTSCENEEXIT_KEY); - } else { + } else if (lastKeyHit.ascii == '[' || lastKeyHit.ascii == ']') { // Change music volume + int vol = ConfMan.getInt("music_volume") / 16; + if (lastKeyHit.ascii == ']' && vol < 16) + vol++; + else if (lastKeyHit.ascii == '[' && vol > 0) + vol--; - if (lastKeyHit.ascii == '[' || lastKeyHit.ascii == ']') { // Change music volume - int vol = ConfMan.getInt("music_volume") / 16; - if (lastKeyHit.ascii == ']' && vol < 16) - vol++; - else if (lastKeyHit.ascii == '[' && vol > 0) - vol--; - - // Display the music volume - ValueDisplayDialog dlg("Music volume: ", 0, 16, vol, ']', '['); - vol = runDialog(dlg); - - vol *= 16; - if (vol > Audio::Mixer::kMaxMixerVolume) - vol = Audio::Mixer::kMaxMixerVolume; - - ConfMan.setInt("music_volume", vol); - updateSoundSettings(); - } else if (lastKeyHit.ascii == '-' || lastKeyHit.ascii == '+') { // Change text speed - if (lastKeyHit.ascii == '+' && _defaultTalkDelay > 0) - _defaultTalkDelay--; - else if (lastKeyHit.ascii == '-' && _defaultTalkDelay < 9) - _defaultTalkDelay++; - - // Display the talk speed - ValueDisplayDialog dlg("Subtitle speed: ", 0, 9, 9 - _defaultTalkDelay, '+', '-'); - _defaultTalkDelay = 9 - runDialog(dlg); - - // Save the new talkspeed value to ConfMan - setTalkspeed(_defaultTalkDelay); - - if (VAR_CHARINC != 0xFF) - VAR(VAR_CHARINC) = _defaultTalkDelay; - } else if (lastKeyHit.ascii == '~' || lastKeyHit.ascii == '#') { // Debug console - _debugger->attach(); - } + // Display the music volume + ValueDisplayDialog dlg("Music volume: ", 0, 16, vol, ']', '['); + vol = runDialog(dlg); + + vol *= 16; + if (vol > Audio::Mixer::kMaxMixerVolume) + vol = Audio::Mixer::kMaxMixerVolume; + + ConfMan.setInt("music_volume", vol); + updateSoundSettings(); + + } else if (lastKeyHit.ascii == '-' || lastKeyHit.ascii == '+') { // Change text speed + if (lastKeyHit.ascii == '+' && _defaultTalkDelay > 0) + _defaultTalkDelay--; + else if (lastKeyHit.ascii == '-' && _defaultTalkDelay < 9) + _defaultTalkDelay++; - _mouseAndKeyboardStat = lastKeyHit.ascii; + // Display the talk speed + ValueDisplayDialog dlg("Subtitle speed: ", 0, 9, 9 - _defaultTalkDelay, '+', '-'); + _defaultTalkDelay = 9 - runDialog(dlg); + + // Save the new talkspeed value to ConfMan + setTalkspeed(_defaultTalkDelay); + + if (VAR_CHARINC != 0xFF) + VAR(VAR_CHARINC) = _defaultTalkDelay; + + } else if (lastKeyHit.ascii == '~' || lastKeyHit.ascii == '#') { // Debug console + _debugger->attach(); + + } else { + // FIXME: Possibly convert even more keycode/ascii pairs to their SCUMM counterparts? + if (lastKeyHit.keycode >= Common::KEYCODE_F1 && lastKeyHit.keycode <= Common::KEYCODE_F9) + _mouseAndKeyboardStat = lastKeyHit.keycode - Common::KEYCODE_F1 + 315; + else + _mouseAndKeyboardStat = lastKeyHit.ascii; } } -- cgit v1.2.3 From 24f080ab561670839cfa954ba2f111e50c18a0d6 Mon Sep 17 00:00:00 2001 From: Max Horn Date: Sat, 23 Jun 2007 16:46:00 +0000 Subject: Cleanup; also fixed Alt-F5 (orig. saveload menu) in COMI svn-id: r27677 --- engines/scumm/input.cpp | 30 +++++++++++------------------- 1 file changed, 11 insertions(+), 19 deletions(-) (limited to 'engines/scumm/input.cpp') diff --git a/engines/scumm/input.cpp b/engines/scumm/input.cpp index a2a90d4cf9..8b2a5e8862 100644 --- a/engines/scumm/input.cpp +++ b/engines/scumm/input.cpp @@ -341,7 +341,7 @@ void ScummEngine::processInput() { if (lastKeyHit.ascii == KEY_ALL_SKIP) { // Skip talk if (VAR_TALKSTOP_KEY != 0xFF && _talkDelay > 0) { - lastKeyHit = Common::KeyState(Common::KEYCODE_PERIOD, '.'); + lastKeyHit = Common::KeyState(Common::KEYCODE_PERIOD); } else { lastKeyHit = Common::KeyState(Common::KEYCODE_ESCAPE); } @@ -360,17 +360,17 @@ void ScummEngine_v8::processKeyboard(Common::KeyState lastKeyHit) { if (!(_game.features & GF_DEMO)) { // F1 (the trigger for the original save/load dialog) is mapped to F5 if (lastKeyHit.keycode == Common::KEYCODE_F1 && lastKeyHit.flags == 0) { - lastKeyHit = Common::KeyState(Common::KEYCODE_F5); + lastKeyHit = Common::KeyState(Common::KEYCODE_F5, 319); } // Alt-F5 brings up the original save/load dialog if (lastKeyHit.keycode == Common::KEYCODE_F5 && lastKeyHit.flags == Common::KBD_ALT) { - lastKeyHit = Common::KeyState(Common::KEYCODE_F1); + lastKeyHit = Common::KeyState(Common::KEYCODE_F1, 315); } } // If a key script was specified (a V8 feature), and it's trigger - // key was pressed, run it. + // key was pressed, run it. Usually used to display the built-in menu. if (_keyScriptNo && (_keyScriptKey == lastKeyHit.ascii)) { runScript(_keyScriptNo, 0, 0, 0); return; @@ -381,6 +381,7 @@ void ScummEngine_v8::processKeyboard(Common::KeyState lastKeyHit) { } void ScummEngine_v7::processKeyboard(Common::KeyState lastKeyHit) { + const bool cutsceneExitKeyEnabled = (VAR_CUTSCENEEXIT_KEY == 0xFF || VAR(VAR_CUTSCENEEXIT_KEY) != 0); // VAR_VERSION_KEY (usually ctrl-v) is used in COMI, Dig and FT to trigger // a version dialog, unless VAR_VERSION_KEY is set to 0. However, the COMI @@ -389,12 +390,8 @@ void ScummEngine_v7::processKeyboard(Common::KeyState lastKeyHit) { if (_game.id != GID_CMI && 0 != VAR(VAR_VERSION_KEY) && lastKeyHit.keycode == Common::KEYCODE_v && lastKeyHit.flags == Common::KBD_CTRL) { versionDialog(); - return; - } - - const bool cutsceneExitKeyEnabled = (VAR_CUTSCENEEXIT_KEY == 0xFF || VAR(VAR_CUTSCENEEXIT_KEY) != 0); - if (cutsceneExitKeyEnabled && lastKeyHit.keycode == Common::KEYCODE_ESCAPE) { + } else if (cutsceneExitKeyEnabled && lastKeyHit.keycode == Common::KEYCODE_ESCAPE) { // Skip cutscene (or active SMUSH video). if (_smushActive) { if (_game.id == GID_FT) @@ -406,11 +403,11 @@ void ScummEngine_v7::processKeyboard(Common::KeyState lastKeyHit) { abortCutscene(); _mouseAndKeyboardStat = Common::ASCII_ESCAPE; - return; - } - // Fall back to V6 behavior - ScummEngine_v6::processKeyboard(lastKeyHit); + } else { + // Fall back to V6 behavior + ScummEngine_v6::processKeyboard(lastKeyHit); + } } #endif @@ -511,12 +508,7 @@ void ScummEngine::processKeyboard(Common::KeyState lastKeyHit) { mainmenuKeyEnabled = true; */ - // Alt-F5 should bring up the original save/load dialog, if any. - // Hence remap it to F5 - if ((_game.version > 2 && _game.version < 8) && (lastKeyHit.keycode == Common::KEYCODE_F5 && lastKeyHit.flags == Common::KBD_ALT)) { - _mouseAndKeyboardStat = 319; // SCUMM encoding for F5 - - } else if (mainmenuKeyEnabled && (lastKeyHit.keycode == Common::KEYCODE_F5 && lastKeyHit.flags == 0)) { + if (mainmenuKeyEnabled && (lastKeyHit.keycode == Common::KEYCODE_F5 && lastKeyHit.flags == 0)) { if (VAR_SAVELOAD_SCRIPT != 0xFF && _currentRoom != 0) runScript(VAR(VAR_SAVELOAD_SCRIPT), 0, 0, 0); -- cgit v1.2.3 From 1665d158f4a09a57c33bdfe742394a76d310e69a Mon Sep 17 00:00:00 2001 From: Max Horn Date: Sat, 23 Jun 2007 16:51:06 +0000 Subject: More cleanup svn-id: r27678 --- engines/scumm/input.cpp | 37 +++++++++++++++++++------------------ 1 file changed, 19 insertions(+), 18 deletions(-) (limited to 'engines/scumm/input.cpp') diff --git a/engines/scumm/input.cpp b/engines/scumm/input.cpp index 8b2a5e8862..2d7401fe57 100644 --- a/engines/scumm/input.cpp +++ b/engines/scumm/input.cpp @@ -87,29 +87,30 @@ void ScummEngine::parseEvents() { else _keyPressed = event.kbd; // Normal key press, pass on to the game. } else if (event.kbd.flags & Common::KBD_ALT) { - // The result must be 273 for Alt-W - // because that's what MI2 looks for in - // its "instant win" cheat. - // FIXME: Handle this specific property inside processKeyboard ? + // Handle KBD_ALT combos. We know that the result must be 273 for Alt-W + // because that's what MI2 looks for in its "instant win" cheat. + + // FIXME: Handle this specific property of MI2 inside processKeyboard ? _keyPressed = event.kbd; _keyPressed.ascii = event.kbd.keycode + 154; - } else if (event.kbd.keycode < Common::KEYCODE_UP || event.kbd.keycode > Common::KEYCODE_LEFT || _game.version >= 7) { - // FIXME: Handle this specific property inside processKeyboard ? - - // don't let game have arrow keys as we currently steal them - // for keyboard cursor control - // this fixes bug with up arrow (273) corresponding to - // "instant win" cheat in MI2 mentioned above - // - // This is not applicable to Full Throttle as it processes keyboard - // cursor control by itself. Also it fixes derby scene - _keyPressed = event.kbd; // Normal key press, pass on to the game. + } else { + // Normal key press, pass on to the game. + _keyPressed = event.kbd; } - if (_game.id == GID_MONKEY && _game.platform == Common::kPlatformSegaCD) { - if (event.kbd.keycode >= Common::KEYCODE_UP && event.kbd.keycode <= Common::KEYCODE_LEFT) { + if (event.kbd.keycode >= Common::KEYCODE_UP && event.kbd.keycode <= Common::KEYCODE_LEFT) { + if (_game.id == GID_MONKEY && _game.platform == Common::kPlatformSegaCD) { _keyPressed = event.kbd; _keyPressed.ascii = event.kbd.ascii - Common::KEYCODE_UP + 54; + } else if (_game.version < 7) { + // FIXME: Handle this specific property inside processKeyboard ? + + // Don't let game see arrow keys. This fixes bug with up arrow (273) + // corresponding to the "instant win" cheat in MI2 mentioned above. + // + // This is not applicable to V7+ games, which need to see the arrow keys, + // too, else certain things (derby scene, asterorid lander) won't work. + _keyPressed.reset(); } } @@ -363,7 +364,7 @@ void ScummEngine_v8::processKeyboard(Common::KeyState lastKeyHit) { lastKeyHit = Common::KeyState(Common::KEYCODE_F5, 319); } - // Alt-F5 brings up the original save/load dialog + // Alt-F5 should bring up the original save/load dialog, so map it to F1. if (lastKeyHit.keycode == Common::KEYCODE_F5 && lastKeyHit.flags == Common::KBD_ALT) { lastKeyHit = Common::KeyState(Common::KEYCODE_F1, 315); } -- cgit v1.2.3