aboutsummaryrefslogtreecommitdiff
path: root/engines/sci
diff options
context:
space:
mode:
authorColin Snover2017-07-16 12:30:54 -0500
committerColin Snover2017-07-16 14:26:30 -0500
commit63794983033189135746bfd2fc2bc0cbf4e474cb (patch)
treef9229facbbcca5ba61d76a2a6cb99f2da611f38c /engines/sci
parent6c44b5762e6fa009c548f5dacdb422ccde958724 (diff)
downloadscummvm-rg350-63794983033189135746bfd2fc2bc0cbf4e474cb.tar.gz
scummvm-rg350-63794983033189135746bfd2fc2bc0cbf4e474cb.tar.bz2
scummvm-rg350-63794983033189135746bfd2fc2bc0cbf4e474cb.zip
SCI: Fix kMenuSelect to understand control characters
In b4c0be8b42d63cbf3c808be1a94839483f674ce9 keyboard events were adjusted to send control characters to game scripts, which matches how keyboard input works in SSCI. Unfortunately this broke games using kMenuSelect because that kernel code was not expecting to receive control characters. Here is an amended list of known types of keyboard shortcuts, for future reference: * All games with text inputs (Ctrl+C clears text boxes) * Most games using MenuBar, like QFG1EGA (Ctrl+P pauses the game, Tab or Ctrl+I show inventory) * QFG1VGA (Ctrl+S shows stats) * Torin (Ctrl+N, Ctrl+O, Ctrl+S, etc. activate menu commands) * LSL1VGA & LSL3 (Ctrl+Alt+X to bypass age check) * Most in-game debuggers (Alt+T for teleport) The shortcut handling code is still not 100% accurate since there are some edge cases that are not implemented (e.g. in DOS/SSCI, Shift+Ctrl+<key> usually sends the same key information as Ctrl+<key>, but not if <key> is Tab), but it should now be working in a consistent and rational manner for end-users.
Diffstat (limited to 'engines/sci')
-rw-r--r--engines/sci/event.h1
-rw-r--r--engines/sci/graphics/menu.cpp9
2 files changed, 10 insertions, 0 deletions
diff --git a/engines/sci/event.h b/engines/sci/event.h
index 23b59f964a..3b18db2f92 100644
--- a/engines/sci/event.h
+++ b/engines/sci/event.h
@@ -127,6 +127,7 @@ struct SciEvent {
#define SCI_KEYMOD_CAPSLOCK (1 << 6)
#define SCI_KEYMOD_INSERT (1 << 7)
+#define SCI_KEYMOD_NON_STICKY (SCI_KEYMOD_RSHIFT | SCI_KEYMOD_LSHIFT | SCI_KEYMOD_CTRL | SCI_KEYMOD_ALT)
#define SCI_KEYMOD_NO_FOOLOCK (~(SCI_KEYMOD_SCRLOCK | SCI_KEYMOD_NUMLOCK | SCI_KEYMOD_CAPSLOCK | SCI_KEYMOD_INSERT))
#define SCI_KEYMOD_ALL 0xFF
diff --git a/engines/sci/graphics/menu.cpp b/engines/sci/graphics/menu.cpp
index eb3f5888c7..2caad6f8ce 100644
--- a/engines/sci/graphics/menu.cpp
+++ b/engines/sci/graphics/menu.cpp
@@ -406,6 +406,15 @@ reg_t GfxMenu::kernelSelect(reg_t eventObject, bool pauseSound) {
case SCI_EVENT_KEYBOARD:
keyPress = readSelectorValue(_segMan, eventObject, SELECTOR(message));
keyModifier = readSelectorValue(_segMan, eventObject, SELECTOR(modifiers));
+
+ // ASCII control characters are put in the `message` field when
+ // Ctrl+<key> is pressed, but this kMenuSelect implementation matches
+ // on modifier + printable character, so we must convert the control
+ // characters to their lower-case latin printed equivalents
+ if ((keyModifier & SCI_KEYMOD_NON_STICKY) == SCI_KEYMOD_CTRL && keyPress > 0 && keyPress < 27) {
+ keyPress += 96;
+ }
+
// If tab got pressed, handle it here as if it was Ctrl-I - at least
// sci0 also did it that way
if (keyPress == SCI_KEY_TAB) {