LILLIPUT: Start implementing keyboard handling
This commit is contained in:
parent
8ce9bac02a
commit
f625b60117
3 changed files with 29 additions and 9 deletions
|
@ -2332,7 +2332,18 @@ void LilliputEngine::pollEvent() {
|
||||||
case Common::EVENT_QUIT:
|
case Common::EVENT_QUIT:
|
||||||
_shouldQuit = true;
|
_shouldQuit = true;
|
||||||
break;
|
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:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -2808,9 +2819,15 @@ Common::String LilliputEngine::getSavegameFilename(int slot) {
|
||||||
return _targetName + Common::String::format("-%02d.SAV", slot);
|
return _targetName + Common::String::format("-%02d.SAV", slot);
|
||||||
}
|
}
|
||||||
|
|
||||||
byte LilliputEngine::_keyboard_getch() {
|
Common::KeyState LilliputEngine::_keyboard_getch() {
|
||||||
warning("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
|
} // End of namespace Lilliput
|
||||||
|
|
|
@ -30,6 +30,7 @@
|
||||||
|
|
||||||
#include "common/file.h"
|
#include "common/file.h"
|
||||||
#include "common/rect.h"
|
#include "common/rect.h"
|
||||||
|
#include "common/events.h"
|
||||||
|
|
||||||
#include "engines/engine.h"
|
#include "engines/engine.h"
|
||||||
#include "graphics/palette.h"
|
#include "graphics/palette.h"
|
||||||
|
@ -104,9 +105,10 @@ public:
|
||||||
byte _animationTick;
|
byte _animationTick;
|
||||||
Common::Point _nextDisplayCharacterPos;
|
Common::Point _nextDisplayCharacterPos;
|
||||||
byte _sound_byte16F06;
|
byte _sound_byte16F06;
|
||||||
byte _lastKeyPressed;
|
Common::KeyState _lastKeyPressed;
|
||||||
byte _keyboard_nextIndex;
|
byte _keyboard_nextIndex;
|
||||||
byte _keyboard_oldIndex;
|
byte _keyboard_oldIndex;
|
||||||
|
Common::KeyState _keyboard_buffer[8];
|
||||||
byte _byte12A05;
|
byte _byte12A05;
|
||||||
byte _byte12A06;
|
byte _byte12A06;
|
||||||
byte _byte12A07;
|
byte _byte12A07;
|
||||||
|
@ -359,7 +361,7 @@ public:
|
||||||
byte *getCharacterVariablesPtr(int16 index);
|
byte *getCharacterVariablesPtr(int16 index);
|
||||||
|
|
||||||
// Temporary stubs
|
// Temporary stubs
|
||||||
byte _keyboard_getch();
|
Common::KeyState _keyboard_getch();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
Common::EventManager *_eventMan;
|
Common::EventManager *_eventMan;
|
||||||
|
|
|
@ -2059,7 +2059,7 @@ byte LilliputScript::OC_checkKeyPressed() {
|
||||||
|
|
||||||
int8 index = (_currScript->readUint16LE() & 0xFF) - 0x30;
|
int8 index = (_currScript->readUint16LE() & 0xFF) - 0x30;
|
||||||
|
|
||||||
if (specialKeys[index] == _vm->_lastKeyPressed)
|
if (specialKeys[index] == _vm->_lastKeyPressed.keycode)
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -2292,7 +2292,7 @@ void LilliputScript::OC_DisableCharacter() {
|
||||||
|
|
||||||
void LilliputScript::OC_saveAndQuit() {
|
void LilliputScript::OC_saveAndQuit() {
|
||||||
warning("OC_saveAndQuit");
|
warning("OC_saveAndQuit");
|
||||||
_vm->_shouldQuit = true;
|
_vm->_shouldQuit = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void LilliputScript::OC_sub17B93() {
|
void LilliputScript::OC_sub17B93() {
|
||||||
|
@ -2322,7 +2322,7 @@ void LilliputScript::OC_resetByte1714E() {
|
||||||
|
|
||||||
void LilliputScript::OC_deleteSavegameAndQuit() {
|
void LilliputScript::OC_deleteSavegameAndQuit() {
|
||||||
warning("OC_deleteSavegameAndQuit");
|
warning("OC_deleteSavegameAndQuit");
|
||||||
_vm->_shouldQuit = true;
|
_vm->_shouldQuit = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void LilliputScript::OC_incByte16F04() {
|
void LilliputScript::OC_incByte16F04() {
|
||||||
|
@ -3156,11 +3156,12 @@ void LilliputScript::OC_displayTitleScreen() {
|
||||||
_vm->_keyboard_oldIndex = 0;
|
_vm->_keyboard_oldIndex = 0;
|
||||||
//
|
//
|
||||||
_vm->_mouseButton = 0;
|
_vm->_mouseButton = 0;
|
||||||
_vm->_lastKeyPressed = 0;
|
// _vm->_lastKeyPressed = 0;
|
||||||
|
|
||||||
while (!_vm->_shouldQuit) {
|
while (!_vm->_shouldQuit) {
|
||||||
_vm->displaySmallAnims();
|
_vm->displaySmallAnims();
|
||||||
_vm->update();
|
_vm->update();
|
||||||
|
_vm->pollEvent();
|
||||||
if (_vm->_keyboard_nextIndex != _vm->_keyboard_oldIndex) {
|
if (_vm->_keyboard_nextIndex != _vm->_keyboard_oldIndex) {
|
||||||
_vm->_lastKeyPressed = _vm->_keyboard_getch();
|
_vm->_lastKeyPressed = _vm->_keyboard_getch();
|
||||||
_vm->_keyboard_getch();
|
_vm->_keyboard_getch();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue