aboutsummaryrefslogtreecommitdiff
path: root/engines/dreamweb/dreamweb.cpp
diff options
context:
space:
mode:
authoreriktorbjorn2011-06-14 22:23:37 +0200
committerAlyssa Milburn2011-06-15 17:35:03 +0200
commit1cafd2de983210fec07267cbb4d261affd4a33f4 (patch)
tree936587858372c77cf1b0919c7ddcf6bc29ecf9b7 /engines/dreamweb/dreamweb.cpp
parent9c7c46bfde46f9b6994822a9ea8db6f5b68dd607 (diff)
downloadscummvm-rg350-1cafd2de983210fec07267cbb4d261affd4a33f4.tar.gz
scummvm-rg350-1cafd2de983210fec07267cbb4d261affd4a33f4.tar.bz2
scummvm-rg350-1cafd2de983210fec07267cbb4d261affd4a33f4.zip
DREAMWEB: Reinstate some "hardware key" handling that got lost
It's still not quite as the original. In the original, Ctrl-<letter> would be treated as <letter>. Is that worth fixing? Probably not.
Diffstat (limited to 'engines/dreamweb/dreamweb.cpp')
-rw-r--r--engines/dreamweb/dreamweb.cpp51
1 files changed, 29 insertions, 22 deletions
diff --git a/engines/dreamweb/dreamweb.cpp b/engines/dreamweb/dreamweb.cpp
index 7d035c916d..19bb6b09cb 100644
--- a/engines/dreamweb/dreamweb.cpp
+++ b/engines/dreamweb/dreamweb.cpp
@@ -120,7 +120,7 @@ void DreamWebEngine::processEvents() {
}
soundHandler();
Common::Event event;
- int key = 0;
+ int softKey, hardKey;
while (event_manager->pollEvent(event)) {
switch(event.type) {
case Common::EVENT_KEYDOWN:
@@ -152,48 +152,55 @@ void DreamWebEngine::processEvents() {
return; //do not pass ctrl + key to the engine
}
- // As far as I can see, the only keys checked
- // for in 'lasthardkey' are 1 (ESC) and 57
- // (space) so add special cases for them and
- // treat everything else as 0.
- switch(event.kbd.keycode) {
+ // Some parts of the ASM code uses the hardware key
+ // code directly. We don't have that code, so we fake
+ // it for the keys where it's needed and assume it's
+ // 0 (which is actually an invalid value, as far as I
+ // know) otherwise.
+
+ hardKey = 0;
+
+ switch (event.kbd.keycode) {
case Common::KEYCODE_ESCAPE:
- _context.data.byte(dreamgen::kLasthardkey) = 1;
+ hardKey = 1;
break;
case Common::KEYCODE_SPACE:
- _context.data.byte(dreamgen::kLasthardkey) = 57;
+ hardKey = 57;
break;
default:
- _context.data.byte(dreamgen::kLasthardkey) = 0;
+ hardKey = 0;
break;
}
- // This is pretty much the equivalent of convertkey(),
- // but we can't use that one because we don't get the
- // same key codes as input. Eventually, we may want to
- // be a bit more permissive than the original, but for
- // now let's be conservative.
+ _context.data.byte(dreamgen::kLasthardkey) = hardKey;
+
+ // The rest of the keys are converted to ASCII. This
+ // is fairly restrictive, and eventually we may want
+ // to let through more keys. I think this is mostly to
+ // keep weird glyphs out of savegame names.
+
+ softKey = 0;
if (event.kbd.keycode >= Common::KEYCODE_a && event.kbd.keycode <= Common::KEYCODE_z) {
- key = event.kbd.ascii & ~0x20;
+ softKey = event.kbd.ascii & ~0x20;
} else if (event.kbd.keycode == Common::KEYCODE_MINUS ||
event.kbd.keycode == Common::KEYCODE_SPACE ||
(event.kbd.keycode >= Common::KEYCODE_0 && event.kbd.keycode <= Common::KEYCODE_9)) {
- key = event.kbd.ascii;
+ softKey = event.kbd.ascii;
} else if (event.kbd.keycode >= Common::KEYCODE_KP0 && event.kbd.keycode <= Common::KEYCODE_KP9) {
- key = event.kbd.keycode - Common::KEYCODE_KP0 + '0';
+ softKey = event.kbd.keycode - Common::KEYCODE_KP0 + '0';
} else if (event.kbd.keycode == Common::KEYCODE_KP_MINUS) {
- key = '-';
+ softKey = '-';
} else if (event.kbd.keycode == Common::KEYCODE_BACKSPACE ||
event.kbd.keycode == Common::KEYCODE_DELETE) {
- key = 8;
+ softKey = 8;
} else if (event.kbd.keycode == Common::KEYCODE_RETURN
|| event.kbd.keycode == Common::KEYCODE_KP_ENTER) {
- key = 13;
+ softKey = 13;
}
- if (key)
- keyPressed(key);
+ if (softKey)
+ keyPressed(softKey);
break;
default:
break;