aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorSven Hesse2012-06-28 21:25:54 +0200
committerSven Hesse2012-07-30 01:44:42 +0200
commit83896dea3edc3bcfb1e414b61644c7ca266e1cce (patch)
treead1417113c51c25b597135f8887abfee8f2874e9 /engines
parent27782700a5631a25129b12779abb540a906f6a96 (diff)
downloadscummvm-rg350-83896dea3edc3bcfb1e414b61644c7ca266e1cce.tar.gz
scummvm-rg350-83896dea3edc3bcfb1e414b61644c7ca266e1cce.tar.bz2
scummvm-rg350-83896dea3edc3bcfb1e414b61644c7ca266e1cce.zip
GOB: Add PreGob input/event utility functions
Diffstat (limited to 'engines')
-rw-r--r--engines/gob/pregob/pregob.cpp44
-rw-r--r--engines/gob/pregob/pregob.h9
2 files changed, 53 insertions, 0 deletions
diff --git a/engines/gob/pregob/pregob.cpp b/engines/gob/pregob/pregob.cpp
index 18aac50352..1c3fb8221c 100644
--- a/engines/gob/pregob/pregob.cpp
+++ b/engines/gob/pregob/pregob.cpp
@@ -137,4 +137,48 @@ bool PreGob::isCursorVisible() const {
return CursorMan.isVisible();
}
+void PreGob::endFrame(bool doInput) {
+ _vm->_draw->blitInvalidated();
+ _vm->_util->waitEndFrame();
+
+ if (doInput)
+ _vm->_util->processInput();
+}
+
+int16 PreGob::checkInput(int16 &mouseX, int16 &mouseY, MouseButtons &mouseButtons) {
+ _vm->_util->getMouseState(&mouseX, &mouseY, &mouseButtons);
+ _vm->_util->forceMouseUp();
+
+ return _vm->_util->checkKey();
+}
+
+int16 PreGob::waitInput(int16 &mouseX, int16 &mouseY, MouseButtons &mouseButtons) {
+ bool finished = false;
+
+ int16 key = 0;
+ while (!_vm->shouldQuit() && !finished) {
+ endFrame(true);
+
+ key = checkInput(mouseX, mouseY, mouseButtons);
+
+ finished = (mouseButtons != kMouseButtonsNone) || (key != 0);
+ }
+
+ return key;
+}
+
+int16 PreGob::waitInput() {
+ int16 mouseX, mouseY;
+ MouseButtons mouseButtons;
+
+ return waitInput(mouseX, mouseY, mouseButtons);
+}
+
+bool PreGob::hasInput() {
+ int16 mouseX, mouseY;
+ MouseButtons mouseButtons;
+
+ return checkInput(mouseX, mouseY, mouseButtons) || (mouseButtons != kMouseButtonsNone);
+}
+
} // End of namespace Gob
diff --git a/engines/gob/pregob/pregob.h b/engines/gob/pregob/pregob.h
index e0f7ca907d..4cf4a39fdb 100644
--- a/engines/gob/pregob/pregob.h
+++ b/engines/gob/pregob/pregob.h
@@ -23,6 +23,8 @@
#ifndef GOB_PREGOB_PREGOB_H
#define GOB_PREGOB_PREGOB_H
+#include "gob/util.h"
+
namespace Gob {
class GobEngine;
@@ -62,6 +64,13 @@ protected:
bool isCursorVisible() const;
+ void endFrame(bool doInput);
+
+ int16 checkInput(int16 &mouseX, int16 &mouseY, MouseButtons &mouseButtons);
+ int16 waitInput (int16 &mouseX, int16 &mouseY, MouseButtons &mouseButtons);
+ int16 waitInput();
+ bool hasInput();
+
GobEngine *_vm;