diff options
author | Max Horn | 2007-06-22 20:04:44 +0000 |
---|---|---|
committer | Max Horn | 2007-06-22 20:04:44 +0000 |
commit | 2b23374468549722c8068d448d9bbf5e100d7301 (patch) | |
tree | 0f932d85abb78a4dc9ecc93799ab7763753f3243 /engines | |
parent | 2496c5b5549f7b3b3f1d7777812631505f8d578f (diff) | |
download | scummvm-rg350-2b23374468549722c8068d448d9bbf5e100d7301.tar.gz scummvm-rg350-2b23374468549722c8068d448d9bbf5e100d7301.tar.bz2 scummvm-rg350-2b23374468549722c8068d448d9bbf5e100d7301.zip |
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
Diffstat (limited to 'engines')
-rw-r--r-- | engines/gob/util.cpp | 28 | ||||
-rw-r--r-- | engines/scumm/input.cpp | 43 |
2 files changed, 36 insertions, 35 deletions
diff --git a/engines/gob/util.cpp b/engines/gob/util.cpp index d7c3ab5337..c1e020679c 100644 --- a/engines/gob/util.cpp +++ b/engines/gob/util.cpp @@ -174,20 +174,20 @@ int16 Util::translateKey(int16 key) { {13, 0x1C0D}, // Enter {27, 0x011B}, // ESC {127, 0x5300}, // Del - {273, 0x4800}, // Up arrow - {274, 0x5000}, // Down arrow - {275, 0x4D00}, // Right arrow - {276, 0x4B00}, // Left arrow - {315, 0x3B00}, // F1 - {316, 0x3C00}, // F2 - {317, 0x3D00}, // F3 - {318, 0x3E00}, // F4 - {319, 0x011B}, // F5 - {320, 0x4000}, // F6 - {321, 0x4100}, // F7 - {322, 0x4200}, // F8 - {323, 0x4300}, // F9 - {324, 0x4400} // F10 + {Common::KEYCODE_UP, 0x4800}, // Up arrow + {Common::KEYCODE_DOWN, 0x5000}, // Down arrow + {Common::KEYCODE_RIGHT, 0x4D00}, // Right arrow + {Common::KEYCODE_LEFT, 0x4B00}, // Left arrow + {Common::ASCII_F1, 0x3B00}, // F1 + {Common::ASCII_F2, 0x3C00}, // F2 + {Common::ASCII_F3, 0x3D00}, // F3 + {Common::ASCII_F4, 0x3E00}, // F4 + {Common::ASCII_F5, 0x011B}, // F5 + {Common::ASCII_F6, 0x4000}, // F6 + {Common::ASCII_F7, 0x4100}, // F7 + {Common::ASCII_F8, 0x4200}, // F8 + {Common::ASCII_F9, 0x4300}, // F9 + {Common::ASCII_F10, 0x4400} // F10 }; for (int i = 0; i < ARRAYSIZE(keys); i++) 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); |