Slightly updated key handling in BS2, Kyra, and Touche
svn-id: r27637
This commit is contained in:
parent
d0ee1b3c8f
commit
a041ef2317
7 changed files with 26 additions and 26 deletions
|
@ -596,7 +596,7 @@ int KyraEngine::buttonMenuCallback(Button *caller) {
|
|||
calcCoords(_menu[i]);
|
||||
|
||||
_menuRestoreScreen = true;
|
||||
_keyPressed = 0;
|
||||
_keyPressed.reset();
|
||||
_mousePressFlag = false;
|
||||
|
||||
_toplevelMenu = 0;
|
||||
|
@ -826,7 +826,7 @@ void KyraEngine::gui_getInput() {
|
|||
_mouseWheel = 1;
|
||||
break;
|
||||
case Common::EVENT_KEYDOWN:
|
||||
_keyPressed = event.kbd.ascii;
|
||||
_keyPressed = event.kbd;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
@ -1002,26 +1002,28 @@ void KyraEngine::gui_redrawTextfield() {
|
|||
void KyraEngine::gui_updateSavegameString() {
|
||||
int length;
|
||||
|
||||
if (_keyPressed) {
|
||||
if (_keyPressed.keycode) {
|
||||
length = strlen(_savegameName);
|
||||
|
||||
if (_keyPressed > 31 && _keyPressed < 127) {
|
||||
if (_keyPressed.ascii > 31 && _keyPressed.ascii < 127) {
|
||||
if (length < 31) {
|
||||
_savegameName[length] = _keyPressed;
|
||||
_savegameName[length] = _keyPressed.ascii;
|
||||
_savegameName[length+1] = 0;
|
||||
gui_redrawTextfield();
|
||||
}
|
||||
} else if (_keyPressed == 8 ||_keyPressed == 127) {
|
||||
} else if (_keyPressed.keycode == Common::KEYCODE_BACKSPACE ||
|
||||
_keyPressed.keycode == Common::KEYCODE_DELETE) {
|
||||
if (length > 0) {
|
||||
_savegameName[length-1] = 0;
|
||||
gui_redrawTextfield();
|
||||
}
|
||||
} else if (_keyPressed == 13) {
|
||||
} else if (_keyPressed.keycode == Common::KEYCODE_RETURN ||
|
||||
_keyPressed.keycode == Common::KEYCODE_KP_ENTER) {
|
||||
_displaySubMenu = false;
|
||||
}
|
||||
}
|
||||
|
||||
_keyPressed = 0;
|
||||
_keyPressed.reset();
|
||||
}
|
||||
|
||||
int KyraEngine::gui_saveGame(Button *button) {
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
#include "engines/engine.h"
|
||||
#include "common/rect.h"
|
||||
#include "common/array.h"
|
||||
#include "common/events.h"
|
||||
|
||||
namespace Kyra {
|
||||
|
||||
|
@ -744,7 +745,7 @@ protected:
|
|||
int _gameToLoad;
|
||||
char _savegameName[31];
|
||||
const char *_specialSavegameString;
|
||||
uint8 _keyPressed;
|
||||
Common::KeyState _keyPressed;
|
||||
|
||||
struct KyragemState {
|
||||
uint16 nextOperation;
|
||||
|
|
|
@ -318,9 +318,9 @@ int Dialog::runModal() {
|
|||
KeyboardEvent *ke = _vm->keyboardEvent();
|
||||
|
||||
if (ke) {
|
||||
if (ke->keycode == Common::KEYCODE_ESCAPE)
|
||||
if (ke->kbd.keycode == Common::KEYCODE_ESCAPE)
|
||||
setResult(0);
|
||||
else if (ke->keycode == Common::KEYCODE_RETURN || ke->keycode == Common::KEYCODE_KP_ENTER)
|
||||
else if (ke->kbd.keycode == Common::KEYCODE_RETURN || ke->kbd.keycode == Common::KEYCODE_KP_ENTER)
|
||||
setResult(1);
|
||||
}
|
||||
|
||||
|
@ -1131,13 +1131,13 @@ public:
|
|||
|
||||
virtual void onKey(KeyboardEvent *ke) {
|
||||
if (_editable) {
|
||||
if (ke->keycode == Common::KEYCODE_BACKSPACE)
|
||||
if (ke->kbd.keycode == Common::KEYCODE_BACKSPACE)
|
||||
_parent->onAction(this, Common::KEYCODE_BACKSPACE);
|
||||
else if (ke->ascii >= ' ' && ke->ascii <= 255) {
|
||||
else if (ke->kbd.ascii >= ' ' && ke->kbd.ascii <= 255) {
|
||||
// Accept the character if the font renderer
|
||||
// has what looks like a valid glyph for it.
|
||||
if (_fr->getCharWidth(ke->ascii))
|
||||
_parent->onAction(this, ke->ascii);
|
||||
if (_fr->getCharWidth(ke->kbd.ascii))
|
||||
_parent->onAction(this, ke->kbd.ascii);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1092,7 +1092,7 @@ void Screen::rollCredits() {
|
|||
|
||||
KeyboardEvent *ke = _vm->keyboardEvent();
|
||||
|
||||
if (ke && ke->keycode == Common::KEYCODE_ESCAPE) {
|
||||
if (ke && ke->kbd.keycode == Common::KEYCODE_ESCAPE) {
|
||||
if (!abortCredits) {
|
||||
abortCredits = true;
|
||||
fadeDown();
|
||||
|
|
|
@ -381,10 +381,10 @@ int Sword2Engine::go() {
|
|||
KeyboardEvent *ke = keyboardEvent();
|
||||
|
||||
if (ke) {
|
||||
if ((ke->modifiers == Common::KBD_CTRL && ke->keycode == Common::KEYCODE_d) || ke->ascii == '#' || ke->ascii == '~') {
|
||||
if ((ke->kbd.flags == Common::KBD_CTRL && ke->kbd.keycode == Common::KEYCODE_d) || ke->kbd.ascii == '#' || ke->kbd.ascii == '~') {
|
||||
_debugger->attach();
|
||||
} else if (ke->modifiers == 0 || ke->modifiers == Common::KBD_SHIFT) {
|
||||
switch (ke->keycode) {
|
||||
} else if (ke->kbd.flags == 0 || ke->kbd.flags == Common::KBD_SHIFT) {
|
||||
switch (ke->kbd.keycode) {
|
||||
case Common::KEYCODE_p:
|
||||
if (_gamePaused)
|
||||
unpauseGame();
|
||||
|
@ -553,9 +553,7 @@ void Sword2Engine::parseInputEvents() {
|
|||
}
|
||||
if (!(_inputEventFilter & RD_KEYDOWN)) {
|
||||
_keyboardEvent.pending = true;
|
||||
_keyboardEvent.ascii = event.kbd.ascii;
|
||||
_keyboardEvent.keycode = event.kbd.keycode;
|
||||
_keyboardEvent.modifiers = event.kbd.flags;
|
||||
_keyboardEvent.kbd = event.kbd;
|
||||
}
|
||||
break;
|
||||
case Common::EVENT_LBUTTONDOWN:
|
||||
|
|
|
@ -39,6 +39,7 @@
|
|||
|
||||
#include "engines/engine.h"
|
||||
|
||||
#include "common/events.h"
|
||||
#include "common/util.h"
|
||||
|
||||
#define MAX_starts 100
|
||||
|
@ -79,9 +80,7 @@ struct MouseEvent {
|
|||
|
||||
struct KeyboardEvent {
|
||||
bool pending;
|
||||
uint16 ascii;
|
||||
int keycode;
|
||||
int modifiers;
|
||||
Common::KeyState kbd;
|
||||
};
|
||||
|
||||
struct StartUp {
|
||||
|
|
|
@ -399,7 +399,7 @@ void ToucheEngine::handleOptions(int forceDisplay) {
|
|||
break;
|
||||
case Common::EVENT_KEYDOWN:
|
||||
if (menuData.mode == kMenuSaveStateMode) {
|
||||
if (event.kbd.keycode == 8) {
|
||||
if (event.kbd.keycode == Common::KEYCODE_BACKSPACE) {
|
||||
menuData.removeLastCharFromDescription(_saveLoadCurrentSlot);
|
||||
} else {
|
||||
menuData.addCharToDescription(_saveLoadCurrentSlot, (char)event.kbd.ascii);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue