diff options
author | eriktorbjorn | 2011-06-14 21:53:48 +0200 |
---|---|---|
committer | Alyssa Milburn | 2011-06-15 17:35:02 +0200 |
commit | dfaa1e32b770257b43348ac042a2d7aa5a28bcfd (patch) | |
tree | 8718165a5948182d7a5246127dd8989e4aaf0330 /engines | |
parent | cde28452f793858878fac66d20e7f9caf5f3e974 (diff) | |
download | scummvm-rg350-dfaa1e32b770257b43348ac042a2d7aa5a28bcfd.tar.gz scummvm-rg350-dfaa1e32b770257b43348ac042a2d7aa5a28bcfd.tar.bz2 scummvm-rg350-dfaa1e32b770257b43348ac042a2d7aa5a28bcfd.zip |
DREAMWEB: Filter out "illegal" characters
This is fairly restrictive (just like the original) so we may went
to let through a few more characters eventually. For now, let's be
conservative. It was possible to enter characters that would show
up in the save dialog as weird or underlined characters.
Diffstat (limited to 'engines')
-rw-r--r-- | engines/dreamweb/dreamweb.cpp | 30 |
1 files changed, 28 insertions, 2 deletions
diff --git a/engines/dreamweb/dreamweb.cpp b/engines/dreamweb/dreamweb.cpp index 478e13491f..789db03615 100644 --- a/engines/dreamweb/dreamweb.cpp +++ b/engines/dreamweb/dreamweb.cpp @@ -120,6 +120,7 @@ void DreamWebEngine::processEvents() { } soundHandler(); Common::Event event; + int key = 0; while (event_manager->pollEvent(event)) { switch(event.type) { case Common::EVENT_KEYDOWN: @@ -166,6 +167,33 @@ void DreamWebEngine::processEvents() { _context.data.byte(dreamgen::kLasthardkey) = 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. + + if (event.kbd.keycode >= Common::KEYCODE_a && event.kbd.keycode <= Common::KEYCODE_z) { + key = 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; + } else if (event.kbd.keycode >= Common::KEYCODE_KP0 && event.kbd.keycode <= Common::KEYCODE_KP9) { + key = event.kbd.keycode - Common::KEYCODE_KP0 + '0'; + } else if (event.kbd.keycode == Common::KEYCODE_KP_MINUS) { + key = '-'; + } else if (event.kbd.keycode == Common::KEYCODE_BACKSPACE || + event.kbd.keycode == Common::KEYCODE_DELETE) { + key = 8; + } else if (event.kbd.keycode == Common::KEYCODE_RETURN + || event.kbd.keycode == Common::KEYCODE_KP_ENTER) { + key = 13; + } + + if (key) + keyPressed(key); break; default: break; @@ -259,8 +287,6 @@ uint DreamWebEngine::readFromSaveFile(uint8 *data, uint size) { void DreamWebEngine::keyPressed(uint16 ascii) { - if (ascii >= 'a' && ascii <= 'z') - ascii = (ascii - 'a') + 'A'; debug(2, "key pressed = %04x", ascii); uint8* keybuf = _context.data.ptr(5912, 16); //fixme: some hardcoded offsets are not added as consts uint16 in = (_context.data.word(dreamgen::kBufferin) + 1) & 0x0f; |