Use the KEYCODE constants.

svn-id: r27593
This commit is contained in:
Torbjörn Andersson 2007-06-21 19:33:05 +00:00
parent bd9ba26109
commit db8e5332fc
4 changed files with 14 additions and 12 deletions

View file

@ -429,7 +429,7 @@ void MoviePlayer::play(SequenceTextInfo *textList, uint32 numLines, int32 leadIn
terminate = true; terminate = true;
break; break;
case Common::EVENT_KEYDOWN: case Common::EVENT_KEYDOWN:
if (event.kbd.keycode == 27) if (event.kbd.keycode == Common::KEYCODE_ESCAPE)
terminate = true; terminate = true;
break; break;
default: default:

View file

@ -26,6 +26,7 @@
*/ */
#include "common/stdafx.h" #include "common/stdafx.h"
#include "common/events.h"
#include "common/rect.h" #include "common/rect.h"
#include "common/config-manager.h" #include "common/config-manager.h"
#include "common/system.h" #include "common/system.h"
@ -317,9 +318,9 @@ int Dialog::runModal() {
KeyboardEvent *ke = _vm->keyboardEvent(); KeyboardEvent *ke = _vm->keyboardEvent();
if (ke) { if (ke) {
if (ke->keycode == 27) if (ke->keycode == Common::KEYCODE_ESCAPE)
setResult(0); setResult(0);
else if (ke->keycode == '\n' || ke->keycode == '\r') else if (ke->keycode == Common::KEYCODE_RETURN || ke->keycode == Common::KEYCODE_KP_ENTER)
setResult(1); setResult(1);
} }
@ -1130,8 +1131,8 @@ public:
virtual void onKey(KeyboardEvent *ke) { virtual void onKey(KeyboardEvent *ke) {
if (_editable) { if (_editable) {
if (ke->keycode == 8) if (ke->keycode == Common::KEYCODE_BACKSPACE)
_parent->onAction(this, 8); _parent->onAction(this, Common::KEYCODE_BACKSPACE);
else if (ke->ascii >= ' ' && ke->ascii <= 255) { else if (ke->ascii >= ' ' && ke->ascii <= 255) {
// Accept the character if the font renderer // Accept the character if the font renderer
// has what looks like a valid glyph for it. // has what looks like a valid glyph for it.
@ -1354,7 +1355,7 @@ void SaveRestoreDialog::onAction(Widget *widget, int result) {
drawEditBuffer(slot); drawEditBuffer(slot);
} }
break; break;
case 8: case Common::KEYCODE_BACKSPACE:
if (_editPos > _firstPos) { if (_editPos > _firstPos) {
_editBuffer[_editPos - 1] = _editBuffer[_editPos]; _editBuffer[_editPos - 1] = _editBuffer[_editPos];
_editBuffer[_editPos--] = 0; _editBuffer[_editPos--] = 0;

View file

@ -31,6 +31,7 @@
#include "common/stdafx.h" #include "common/stdafx.h"
#include "common/system.h" #include "common/system.h"
#include "common/events.h"
#include "sword2/sword2.h" #include "sword2/sword2.h"
#include "sword2/defs.h" #include "sword2/defs.h"
@ -1091,7 +1092,7 @@ void Screen::rollCredits() {
KeyboardEvent *ke = _vm->keyboardEvent(); KeyboardEvent *ke = _vm->keyboardEvent();
if (ke && ke->keycode == 27) { if (ke && ke->keycode == Common::KEYCODE_ESCAPE) {
if (!abortCredits) { if (!abortCredits) {
abortCredits = true; abortCredits = true;
fadeDown(); fadeDown();

View file

@ -381,17 +381,17 @@ int Sword2Engine::go() {
KeyboardEvent *ke = keyboardEvent(); KeyboardEvent *ke = keyboardEvent();
if (ke) { if (ke) {
if ((ke->modifiers == Common::KBD_CTRL && ke->keycode == 'd') || ke->ascii == '#' || ke->ascii == '~') { if ((ke->modifiers == Common::KBD_CTRL && ke->keycode == Common::KEYCODE_d) || ke->ascii == '#' || ke->ascii == '~') {
_debugger->attach(); _debugger->attach();
} else if (ke->modifiers == 0 || ke->modifiers == Common::KBD_SHIFT) { } else if (ke->modifiers == 0 || ke->modifiers == Common::KBD_SHIFT) {
switch (ke->keycode) { switch (ke->keycode) {
case 'p': case Common::KEYCODE_p:
if (_gamePaused) if (_gamePaused)
unpauseGame(); unpauseGame();
else else
pauseGame(); pauseGame();
break; break;
case 'c': case Common::KEYCODE_c:
if (!_logic->readVar(DEMO) && !_mouse->isChoosing()) { if (!_logic->readVar(DEMO) && !_mouse->isChoosing()) {
ScreenInfo *screenInfo = _screen->getScreenInfo(); ScreenInfo *screenInfo = _screen->getScreenInfo();
_logic->fnPlayCredits(NULL); _logic->fnPlayCredits(NULL);
@ -399,13 +399,13 @@ int Sword2Engine::go() {
} }
break; break;
#ifdef SWORD2_DEBUG #ifdef SWORD2_DEBUG
case ' ': case Common::KEYCODE_SPACE:
if (_gamePaused) { if (_gamePaused) {
_stepOneCycle = true; _stepOneCycle = true;
unpauseGame(); unpauseGame();
} }
break; break;
case 's': case Common::KEYCODE_s:
_renderSkip = !_renderSkip; _renderSkip = !_renderSkip;
break; break;
#endif #endif