From 54d668ac13f57d8acf5d8e627a5daeaa8166ecb3 Mon Sep 17 00:00:00 2001 From: Max Horn Date: Fri, 22 Jun 2007 21:10:57 +0000 Subject: Changed more code to use Common::KEYCODE_ enum svn-id: r27624 --- engines/cine/main_loop.cpp | 24 ++++++++++++------------ engines/cine/various.cpp | 22 +++++++++++----------- engines/kyra/kyra.cpp | 2 +- engines/lure/menu.cpp | 6 +++--- engines/lure/surface.cpp | 6 +++--- engines/queen/journal.cpp | 2 +- 6 files changed, 31 insertions(+), 31 deletions(-) diff --git a/engines/cine/main_loop.cpp b/engines/cine/main_loop.cpp index b55ee361c2..7ad20a7ec7 100644 --- a/engines/cine/main_loop.cpp +++ b/engines/cine/main_loop.cpp @@ -70,61 +70,61 @@ void manageEvents(int count) { break; case Common::EVENT_KEYDOWN: switch (event.kbd.keycode) { - case '\n': - case '\r': - case 261: // Keypad 5 + case Common::KEYCODE_RETURN: + case Common::KEYCODE_KP_ENTER: + case Common::KEYCODE_KP5: if (allowPlayerInput) { mouseLeft = 1; } break; - case 27: // ESC + case Common::KEYCODE_ESC: if (allowPlayerInput) { mouseRight = 1; } break; - case 282: // F1 + case Common::KEYCODE_F1: if (allowPlayerInput) { playerCommand = 0; // EXAMINE makeCommandLine(); } break; - case 283: // F2 + case Common::KEYCODE_F2: if (allowPlayerInput) { playerCommand = 1; // TAKE makeCommandLine(); } break; - case 284: // F3 + case Common::KEYCODE_F3: if (allowPlayerInput) { playerCommand = 2; // INVENTORY makeCommandLine(); } break; - case 285: // F4 + case Common::KEYCODE_F4: if (allowPlayerInput) { playerCommand = 3; // USE makeCommandLine(); } break; - case 286: // F5 + case Common::KEYCODE_F5: if (allowPlayerInput) { playerCommand = 4; // ACTIVATE makeCommandLine(); } break; - case 287: // F6 + case Common::KEYCODE_F6: if (allowPlayerInput) { playerCommand = 5; // SPEAK makeCommandLine(); } break; - case 290: // F9 + case Common::KEYCODE_F9: if (allowPlayerInput && !inMenu) { makeActionMenu(); makeCommandLine(); } break; - case 291: // F10 + case Common::KEYCODE_F10: if (!disableSystemMenu && !inMenu) { g_cine->makeSystemMenu(); } diff --git a/engines/cine/various.cpp b/engines/cine/various.cpp index c9bb672e21..e17f68b36b 100644 --- a/engines/cine/various.cpp +++ b/engines/cine/various.cpp @@ -3204,7 +3204,7 @@ bool makeTextEntryMenu(const char *messagePtr, char *inputString, int stringMaxL ch[1] = 0; manageEvents(); - int ascii = getKeyData(); + int keycode = getKeyData(); uint16 mouseButton, mouseX, mouseY; getMouseData(0, &mouseButton, &mouseX, &mouseY); @@ -3214,14 +3214,14 @@ bool makeTextEntryMenu(const char *messagePtr, char *inputString, int stringMaxL else if (mouseButton & 1) quit = 1; - switch (ascii) { - case 8: // backspace + switch (keycode) { + case Common::KEYCODE_BACKSPACE: if (inputPos <= 1) { break; } inputPos--; redraw = true; - case 127: // del + case Common::KEYCODE_DELETE: if (inputPos <= inputLength) { if (inputPos != 1) { strncpy(tempString, inputString, inputPos - 1); @@ -3234,25 +3234,25 @@ bool makeTextEntryMenu(const char *messagePtr, char *inputString, int stringMaxL redraw = true; } break; - case 276: // left + case Common::KEYCODE_LEFT: if (inputPos > 1) { inputPos--; redraw = true; } break; - case 275: // right + case Common::KEYCODE_RIGHT: if (inputPos <= inputLength) { inputPos++; redraw = true; } break; default: - if (((ascii >= 'a') && (ascii <='z')) || - ((ascii >= '0') && (ascii <='9')) || - ((ascii >= 'A') && (ascii <='Z')) || - (ascii == ' ')) { + if (((keycode >= 'a') && (keycode <='z')) || + ((keycode >= '0') && (keycode <='9')) || + ((keycode >= 'A') && (keycode <='Z')) || + (keycode == ' ')) { if (inputLength < stringMaxLength - 1) { - ch[0] = ascii; + ch[0] = keycode; if (inputPos != 1) { strncpy(tempString, inputString, inputPos - 1); strcat(tempString, ch); diff --git a/engines/kyra/kyra.cpp b/engines/kyra/kyra.cpp index 197182e8f3..7e4f5103e7 100644 --- a/engines/kyra/kyra.cpp +++ b/engines/kyra/kyra.cpp @@ -617,7 +617,7 @@ void KyraEngine::delay(uint32 amount, bool update, bool isMainLoop) { _quitFlag = true; } else if (event.kbd.keycode == '.') _skipFlag = true; - else if (event.kbd.keycode == 13 || event.kbd.keycode == 32 || event.kbd.keycode == 27) { + else if (event.kbd.keycode == Common::KEYCODE_RETURN || event.kbd.keycode == Common::KEYCODE_SPACE || event.kbd.keycode == Common::KEYCODE_ESC) { _abortIntroFlag = true; _skipFlag = true; } diff --git a/engines/lure/menu.cpp b/engines/lure/menu.cpp index 8b3003c808..95b27470cd 100644 --- a/engines/lure/menu.cpp +++ b/engines/lure/menu.cpp @@ -478,14 +478,14 @@ uint16 PopupMenu::Show(int numEntries, const char *actions[]) { byte ch = e.event().kbd.ascii; uint16 keycode = e.event().kbd.keycode; - if (((keycode == 0x108) || (keycode == 0x111)) && (selectedIndex > 0)) { + if (((keycode == Common::KEYCODE_KP8) || (keycode == Common::KEYCODE_UP)) && (selectedIndex > 0)) { --selectedIndex; refreshFlag = true; - } else if (((keycode == 0x102) || (keycode == 0x112)) && + } else if (((keycode == Common::KEYCODE_KP2) || (keycode == Common::KEYCODE_DOWN)) && (selectedIndex < numEntries-1)) { ++selectedIndex; refreshFlag = true; - } else if ((ch == '\xd') || (keycode == 0x10f)) { + } else if ((ch == '\xd') || (keycode == Common::KEYCODE_KP_ENTER)) { goto bail_out; } else if (ch == '\x1b') { selectedIndex = 0xffff; diff --git a/engines/lure/surface.cpp b/engines/lure/surface.cpp index b7baf53a76..0775d4261b 100644 --- a/engines/lure/surface.cpp +++ b/engines/lure/surface.cpp @@ -420,7 +420,7 @@ bool Surface::getString(Common::String &line, int maxSize, bool isNumeric, bool char ch = events.event().kbd.ascii; uint16 keycode = events.event().kbd.keycode; - if ((ch == 13) || (keycode == 0x10f)) { + if ((keycode == Common::KEYCODE_RETURN) || (keycode == Common::KEYCODE_KP_ENTER)) { // Return character screen.screen().fillRect( Rect(x, y, x + maxSize - 1, y + FONT_HEIGHT), bgColour); @@ -430,13 +430,13 @@ bool Surface::getString(Common::String &line, int maxSize, bool isNumeric, bool mouse.cursorOn(); return true; } - else if (ch == 27) { + else if (keycode == Common::KEYCODE_ESC) { // Escape character screen.screen().fillRect( Rect(x, y, x + maxSize - 1, y + FONT_HEIGHT), bgColour); screen.update(); abortFlag = true; - } else if (ch == 8) { + } else if (keycode == Common::KEYCODE_BACKSPACE) { // Delete the last character if (newLine.size() == 1) continue; diff --git a/engines/queen/journal.cpp b/engines/queen/journal.cpp index 3db7ce82f0..18674db4a3 100644 --- a/engines/queen/journal.cpp +++ b/engines/queen/journal.cpp @@ -515,7 +515,7 @@ void Journal::initTextField(const char *desc) { void Journal::updateTextField(uint16 ascii, int keycode) { bool dirty = false; switch (keycode) { - case 8: // backspace + case Common::KEYCODE_BACKSPACE: if (_textField.textCharsCount > 0) { --_textField.textCharsCount; _textField.text[_textField.textCharsCount] = '\0'; -- cgit v1.2.3