aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicola Mettifogo2008-07-23 07:31:35 +0000
committerNicola Mettifogo2008-07-23 07:31:35 +0000
commit78ccedf8985151c594ef384fda95de295d39bb5c (patch)
treed4a5391ccb93bdd1f483ce46de0a3efa4eb73308
parent8932619ee273967821c3c5fc93ae162f75f7d6c8 (diff)
downloadscummvm-rg350-78ccedf8985151c594ef384fda95de295d39bb5c.tar.gz
scummvm-rg350-78ccedf8985151c594ef384fda95de295d39bb5c.tar.bz2
scummvm-rg350-78ccedf8985151c594ef384fda95de295d39bb5c.zip
Removed useless event management code and made readInput() more general.
svn-id: r33225
-rw-r--r--engines/parallaction/input.cpp38
-rw-r--r--engines/parallaction/input.h8
-rw-r--r--engines/parallaction/parallaction.cpp11
-rw-r--r--engines/parallaction/parallaction.h6
4 files changed, 26 insertions, 37 deletions
diff --git a/engines/parallaction/input.cpp b/engines/parallaction/input.cpp
index 518c165155..4de5ff711b 100644
--- a/engines/parallaction/input.cpp
+++ b/engines/parallaction/input.cpp
@@ -36,25 +36,23 @@ namespace Parallaction {
// loops which could possibly be merged into this one with some effort in changing
// caller code, i.e. adding condition checks.
//
-uint16 Input::readInput() {
+void Input::readInput() {
Common::Event e;
- uint16 KeyDown = 0;
_mouseButtons = kMouseNone;
- _lastKeyDownAscii = -1;
+ _hasKeyPressEvent = false;
Common::EventManager *eventMan = _vm->_system->getEventManager();
while (eventMan->pollEvent(e)) {
switch (e.type) {
case Common::EVENT_KEYDOWN:
- _lastKeyDownAscii = e.kbd.ascii;
+ _hasKeyPressEvent = true;
+ _keyPressed = e.kbd;
+
if (e.kbd.flags == Common::KBD_CTRL && e.kbd.keycode == 'd')
_vm->_debugger->attach();
- if (_vm->getFeatures() & GF_DEMO) break;
- if (e.kbd.keycode == Common::KEYCODE_l) KeyDown = kEvLoadGame;
- if (e.kbd.keycode == Common::KEYCODE_s) KeyDown = kEvSaveGame;
break;
case Common::EVENT_LBUTTONDOWN:
@@ -83,7 +81,7 @@ uint16 Input::readInput() {
case Common::EVENT_QUIT:
_engineFlags |= kEngineQuit;
- return KeyDown;
+ return;
default:
break;
@@ -95,13 +93,13 @@ uint16 Input::readInput() {
if (_vm->_debugger->isAttached())
_vm->_debugger->onFrame();
- return KeyDown;
+ return;
}
bool Input::getLastKeyDown(uint16 &ascii) {
- ascii = _lastKeyDownAscii;
- return (_lastKeyDownAscii != -1);
+ ascii = _keyPressed.ascii;
+ return (_hasKeyPressEvent);
}
// FIXME: see comment for readInput()
@@ -143,7 +141,7 @@ void Input::waitUntilLeftClick() {
void Input::updateGameInput() {
- int16 keyDown = readInput();
+ readInput();
debugC(3, kDebugInput, "translateInput: input flags (%i, %i, %i, %i)",
!_mouseHidden,
@@ -160,17 +158,13 @@ void Input::updateGameInput() {
return;
}
- if (keyDown == kEvQuitGame) {
- _inputData._event = kEvQuitGame;
- } else
- if (keyDown == kEvSaveGame) {
- _inputData._event = kEvSaveGame;
- } else
- if (keyDown == kEvLoadGame) {
- _inputData._event = kEvLoadGame;
- } else {
+ if (_hasKeyPressEvent && (_vm->getFeatures() & GF_DEMO) == 0) {
+ if (_keyPressed.keycode == Common::KEYCODE_l) _inputData._event = kEvLoadGame;
+ if (_keyPressed.keycode == Common::KEYCODE_s) _inputData._event = kEvSaveGame;
+ }
+
+ if (_inputData._event == kEvNone) {
_inputData._mousePos = _mousePos;
- _inputData._event = kEvNone;
translateGameInput();
}
diff --git a/engines/parallaction/input.h b/engines/parallaction/input.h
index 4d22d7b59b..679417c0e5 100644
--- a/engines/parallaction/input.h
+++ b/engines/parallaction/input.h
@@ -26,6 +26,8 @@
#ifndef PARALLACTION_INPUT_H
#define PARALLACTION_INPUT_H
+#include "common/keyboard.h"
+
#include "parallaction/objects.h"
#include "parallaction/inventory.h"
@@ -53,6 +55,9 @@ class Input {
// input-only
InputData _inputData;
+ bool _hasKeyPressEvent;
+ Common::KeyState _keyPressed;
+
bool _hasDelayedAction; // actived when the character needs to move before taking an action
ZonePtr _delayedActionZone;
@@ -68,7 +73,6 @@ class Input {
Common::Point _mousePos;
uint16 _mouseButtons;
- int32 _lastKeyDownAscii;
bool _mouseHidden;
ZonePtr _hoverZone;
@@ -106,7 +110,7 @@ public:
int _inputMode;
InventoryItem _activeItem;
- uint16 readInput();
+ void readInput();
InputData* updateInput();
void trackMouse(ZonePtr z);
void waitUntilLeftClick();
diff --git a/engines/parallaction/parallaction.cpp b/engines/parallaction/parallaction.cpp
index 20f6129d78..59a97d1dd4 100644
--- a/engines/parallaction/parallaction.cpp
+++ b/engines/parallaction/parallaction.cpp
@@ -297,6 +297,9 @@ void Parallaction::showLocationComment(const char *text, bool end) {
void Parallaction::processInput(InputData *data) {
+ if (!data) {
+ return;
+ }
switch (data->_event) {
case kEvSaveGame:
@@ -326,13 +329,7 @@ void Parallaction::runGame() {
runCommentFrame();
if (_input->_inputMode == Input::kInputModeGame) {
- if (data->_event != kEvNone) {
- processInput(data);
- }
-
- if (_engineFlags & kEngineQuit)
- return;
-
+ processInput(data);
runPendingZones();
if (_engineFlags & kEngineQuit)
diff --git a/engines/parallaction/parallaction.h b/engines/parallaction/parallaction.h
index 387fa43c09..d8ab93e257 100644
--- a/engines/parallaction/parallaction.h
+++ b/engines/parallaction/parallaction.h
@@ -114,12 +114,6 @@ enum EngineFlags {
enum {
kEvNone = 0,
- kEvAction = 3,
- kEvOpenInventory = 4,
- kEvCloseInventory = 5,
- kEvHoverInventory = 6,
- kEvWalk = 7,
- kEvQuitGame = 1000,
kEvSaveGame = 2000,
kEvLoadGame = 4000
};