aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/lilliput/lilliput.cpp23
-rw-r--r--engines/lilliput/lilliput.h6
-rw-r--r--engines/lilliput/script.cpp9
3 files changed, 29 insertions, 9 deletions
diff --git a/engines/lilliput/lilliput.cpp b/engines/lilliput/lilliput.cpp
index 3af5fdde8f..6f15d022b7 100644
--- a/engines/lilliput/lilliput.cpp
+++ b/engines/lilliput/lilliput.cpp
@@ -2332,7 +2332,18 @@ void LilliputEngine::pollEvent() {
case Common::EVENT_QUIT:
_shouldQuit = true;
break;
- // TODO: handle keyboard
+ case Common::EVENT_KEYDOWN: {
+ if (event.kbd == _lastKeyPressed)
+ break;
+
+ _lastKeyPressed = event.kbd;
+ int nextIndex = (_keyboard_nextIndex + 1) % 8;
+ if (_keyboard_oldIndex != nextIndex) {
+ _keyboard_buffer[_keyboard_nextIndex] = event.kbd;
+ _keyboard_nextIndex = nextIndex;
+ }
+ }
+ break;
default:
break;
}
@@ -2808,9 +2819,15 @@ Common::String LilliputEngine::getSavegameFilename(int slot) {
return _targetName + Common::String::format("-%02d.SAV", slot);
}
-byte LilliputEngine::_keyboard_getch() {
+Common::KeyState LilliputEngine::_keyboard_getch() {
warning("getch()");
- return ' ';
+ while(_keyboard_nextIndex == _keyboard_oldIndex)
+ pollEvent();
+
+ Common::KeyState tmpEvent = _keyboard_buffer[_keyboard_oldIndex];
+ _keyboard_oldIndex = (_keyboard_oldIndex + 1) % 8;
+
+ return tmpEvent;
}
} // End of namespace Lilliput
diff --git a/engines/lilliput/lilliput.h b/engines/lilliput/lilliput.h
index 1006c34a1b..2aa952b863 100644
--- a/engines/lilliput/lilliput.h
+++ b/engines/lilliput/lilliput.h
@@ -30,6 +30,7 @@
#include "common/file.h"
#include "common/rect.h"
+#include "common/events.h"
#include "engines/engine.h"
#include "graphics/palette.h"
@@ -104,9 +105,10 @@ public:
byte _animationTick;
Common::Point _nextDisplayCharacterPos;
byte _sound_byte16F06;
- byte _lastKeyPressed;
+ Common::KeyState _lastKeyPressed;
byte _keyboard_nextIndex;
byte _keyboard_oldIndex;
+ Common::KeyState _keyboard_buffer[8];
byte _byte12A05;
byte _byte12A06;
byte _byte12A07;
@@ -359,7 +361,7 @@ public:
byte *getCharacterVariablesPtr(int16 index);
// Temporary stubs
- byte _keyboard_getch();
+ Common::KeyState _keyboard_getch();
protected:
Common::EventManager *_eventMan;
diff --git a/engines/lilliput/script.cpp b/engines/lilliput/script.cpp
index f88587495a..71396fb170 100644
--- a/engines/lilliput/script.cpp
+++ b/engines/lilliput/script.cpp
@@ -2059,7 +2059,7 @@ byte LilliputScript::OC_checkKeyPressed() {
int8 index = (_currScript->readUint16LE() & 0xFF) - 0x30;
- if (specialKeys[index] == _vm->_lastKeyPressed)
+ if (specialKeys[index] == _vm->_lastKeyPressed.keycode)
return 1;
return 0;
@@ -2292,7 +2292,7 @@ void LilliputScript::OC_DisableCharacter() {
void LilliputScript::OC_saveAndQuit() {
warning("OC_saveAndQuit");
- _vm->_shouldQuit = true;
+ _vm->_shouldQuit = true;
}
void LilliputScript::OC_sub17B93() {
@@ -2322,7 +2322,7 @@ void LilliputScript::OC_resetByte1714E() {
void LilliputScript::OC_deleteSavegameAndQuit() {
warning("OC_deleteSavegameAndQuit");
- _vm->_shouldQuit = true;
+ _vm->_shouldQuit = true;
}
void LilliputScript::OC_incByte16F04() {
@@ -3156,11 +3156,12 @@ void LilliputScript::OC_displayTitleScreen() {
_vm->_keyboard_oldIndex = 0;
//
_vm->_mouseButton = 0;
- _vm->_lastKeyPressed = 0;
+// _vm->_lastKeyPressed = 0;
while (!_vm->_shouldQuit) {
_vm->displaySmallAnims();
_vm->update();
+ _vm->pollEvent();
if (_vm->_keyboard_nextIndex != _vm->_keyboard_oldIndex) {
_vm->_lastKeyPressed = _vm->_keyboard_getch();
_vm->_keyboard_getch();