aboutsummaryrefslogtreecommitdiff
path: root/engines/agi
diff options
context:
space:
mode:
authorTorbjörn Andersson2007-03-17 16:08:29 +0000
committerTorbjörn Andersson2007-03-17 16:08:29 +0000
commit8a2529b2d6fa83efc0da64e4f7fc003d84b18a59 (patch)
tree91a8d7ac21da95d4f2750b0ea504f155afe7786c /engines/agi
parentcfe7ecd6d914026080698e5c6330a0ee1db6b8a9 (diff)
downloadscummvm-rg350-8a2529b2d6fa83efc0da64e4f7fc003d84b18a59.tar.gz
scummvm-rg350-8a2529b2d6fa83efc0da64e4f7fc003d84b18a59.tar.bz2
scummvm-rg350-8a2529b2d6fa83efc0da64e4f7fc003d84b18a59.zip
Allow synthetic events in dialog windows, e.g. so you can use keyboard repeat
when scrolling the list of savegames. svn-id: r26175
Diffstat (limited to 'engines/agi')
-rw-r--r--engines/agi/agi.cpp22
-rw-r--r--engines/agi/agi.h3
-rw-r--r--engines/agi/keyboard.h16
-rw-r--r--engines/agi/savegame.cpp2
-rw-r--r--engines/agi/text.cpp2
5 files changed, 37 insertions, 8 deletions
diff --git a/engines/agi/agi.cpp b/engines/agi/agi.cpp
index 03b1615e85..5064b437ab 100644
--- a/engines/agi/agi.cpp
+++ b/engines/agi/agi.cpp
@@ -53,6 +53,10 @@ namespace Agi {
static uint32 g_tickTimer;
struct Mouse g_mouse;
+void AgiEngine::allowSynthetic(bool allow) {
+ _allowSynthetic = allow;
+}
+
void AgiEngine::processEvents() {
OSystem::Event event;
int key = 0;
@@ -113,42 +117,42 @@ void AgiEngine::processEvents() {
switch (key = event.kbd.keycode) {
case 256 + 20: // left arrow
case 260: // key pad 4
- if (!event.synthetic)
+ if (_allowSynthetic || !event.synthetic)
key = KEY_LEFT;
break;
case 256 + 19: // right arrow
case 262: // key pad 6
- if (!event.synthetic)
+ if (_allowSynthetic || !event.synthetic)
key = KEY_RIGHT;
break;
case 256 + 17: // up arrow
case 264: // key pad 8
- if (!event.synthetic)
+ if (_allowSynthetic || !event.synthetic)
key = KEY_UP;
break;
case 256 + 18: // down arrow
case 258: // key pad 2
- if (!event.synthetic)
+ if (_allowSynthetic || !event.synthetic)
key = KEY_DOWN;
break;
case 256 + 24: // page up
case 265: // key pad 9
- if (!event.synthetic)
+ if (_allowSynthetic || !event.synthetic)
key = KEY_UP_RIGHT;
break;
case 256 + 25: // page down
case 259: // key pad 3
- if (!event.synthetic)
+ if (_allowSynthetic || !event.synthetic)
key = KEY_DOWN_RIGHT;
break;
case 256 + 22: // home
case 263: // key pad 7
- if (!event.synthetic)
+ if (_allowSynthetic || !event.synthetic)
key = KEY_UP_LEFT;
break;
case 256 + 23: // end
case 257: // key pad 1
- if (!event.synthetic)
+ if (_allowSynthetic || !event.synthetic)
key = KEY_DOWN_LEFT;
break;
case 261: // key pad 5
@@ -552,6 +556,8 @@ AgiEngine::AgiEngine(OSystem *syst) : Engine(syst) {
_keyControl = 0;
_keyAlt = 0;
+ _allowSynthetic = false;
+
g_tickTimer = 0;
_intobj = NULL;
diff --git a/engines/agi/agi.h b/engines/agi/agi.h
index adf9193c4b..5bc577bcca 100644
--- a/engines/agi/agi.h
+++ b/engines/agi/agi.h
@@ -518,6 +518,8 @@ private:
int _keyQueueStart;
int _keyQueueEnd;
+ bool _allowSynthetic;
+
int checkPriority(VtEntry *v);
int checkCollision(VtEntry *v);
int checkPosition(VtEntry *v);
@@ -634,6 +636,7 @@ public:
int showItems();
void selectItems(int n);
+ void allowSynthetic(bool);
void processEvents();
// Objects
diff --git a/engines/agi/keyboard.h b/engines/agi/keyboard.h
index 0220db41c5..67e4679b65 100644
--- a/engines/agi/keyboard.h
+++ b/engines/agi/keyboard.h
@@ -34,6 +34,22 @@ namespace Agi {
#define keyDequeue(k) do { (k) = _keyQueue[_keyQueueStart++]; \
_keyQueueStart %= KEY_QUEUE_SIZE; } while (0)
+// Class to turn on synthetic events temporarily. Usually until the end of the
+// current function.
+
+class AllowSyntheticEvents {
+private:
+ AgiEngine *_vm;
+public:
+ AllowSyntheticEvents(AgiEngine *vm) : _vm(vm) {
+ _vm->allowSynthetic(true);
+ }
+
+ ~AllowSyntheticEvents() {
+ _vm->allowSynthetic(false);
+ }
+};
+
/* QNX4 has a KEY_DOWN defined which we don't need to care about */
#undef KEY_DOWN
diff --git a/engines/agi/savegame.cpp b/engines/agi/savegame.cpp
index a689c6a3ab..8a58d67f58 100644
--- a/engines/agi/savegame.cpp
+++ b/engines/agi/savegame.cpp
@@ -509,6 +509,8 @@ int AgiEngine::selectSlot() {
for (i = 0; i < 2; i++)
_gfx->drawButton(buttonX[i], buttonY, buttonText[i], 0, 0, MSG_BOX_TEXT, MSG_BOX_COLOUR);
+ AllowSyntheticEvents on(this);
+
for (;;) {
char dstr[64];
for (i = 0; i < NUM_VISIBLE_SLOTS; i++) {
diff --git a/engines/agi/text.cpp b/engines/agi/text.cpp
index 8414e47011..7f4cf1fc54 100644
--- a/engines/agi/text.cpp
+++ b/engines/agi/text.cpp
@@ -350,6 +350,8 @@ int AgiEngine::selectionBox(const char *m, const char **b) {
_gfx->getKey();
}
+ AllowSyntheticEvents on(this);
+
debugC(4, kDebugLevelText, "waiting...");
for (;;) {
for (i = 0; b[i]; i++)