[Scummvm-git-logs] scummvm master -> d8eccdec323dfc1126b87624b73e7effcb2f50bb

csnover csnover at users.noreply.github.com
Sun Jul 16 21:26:57 CEST 2017


This automated email contains information about 2 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
6379498303 SCI: Fix kMenuSelect to understand control characters
d8eccdec32 SCI: Clarify Tab character & modifier workarounds in GfxMenu


Commit: 63794983033189135746bfd2fc2bc0cbf4e474cb
    https://github.com/scummvm/scummvm/commit/63794983033189135746bfd2fc2bc0cbf4e474cb
Author: Colin Snover (github.com at zetafleet.com)
Date: 2017-07-16T14:26:30-05:00

Commit Message:
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.

Changed paths:
    engines/sci/event.h
    engines/sci/graphics/menu.cpp


diff --git a/engines/sci/event.h b/engines/sci/event.h
index 23b59f9..3b18db2 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 eb3f588..2caad6f 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) {


Commit: d8eccdec323dfc1126b87624b73e7effcb2f50bb
    https://github.com/scummvm/scummvm/commit/d8eccdec323dfc1126b87624b73e7effcb2f50bb
Author: Colin Snover (github.com at zetafleet.com)
Date: 2017-07-16T14:26:30-05:00

Commit Message:
SCI: Clarify Tab character & modifier workarounds in GfxMenu

Changed paths:
    engines/sci/graphics/menu.cpp


diff --git a/engines/sci/graphics/menu.cpp b/engines/sci/graphics/menu.cpp
index 2caad6f..b7030bb 100644
--- a/engines/sci/graphics/menu.cpp
+++ b/engines/sci/graphics/menu.cpp
@@ -415,12 +415,6 @@ reg_t GfxMenu::kernelSelect(reg_t eventObject, bool pauseSound) {
 			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) {
-			keyModifier = SCI_KEYMOD_CTRL;
-			keyPress = 'i';
-		}
 		switch (keyPress) {
 		case 0:
 			break;
@@ -433,12 +427,25 @@ reg_t GfxMenu::kernelSelect(reg_t eventObject, bool pauseSound) {
 		default:
 			while (itemIterator != itemEnd) {
 				itemEntry = *itemIterator;
-				// Sierra actually did not check the modifier, they only checked the ascii code
-				// Which is why for example pressing Ctrl-I and Shift-Ctrl-I both brought up the inventory in QfG1
-				// We still check the modifier, but we need to isolate the lower byte, because of a keyboard
-				// driver bug (see engine/kevent.cpp / kGetEvent)
+
+				// Tab and Ctrl+I share the same ASCII character, but this
+				// method also checks the modifier (whereas SSCI looked only at
+				// the character), so a Tab keypress must be converted here
+				// to Ctrl+I or the modifier check will fail and the Tab key
+				// won't do anything. (This is also why Ctrl+I and Ctrl+Shift+I
+				// would both bring up the inventory in SSCI QFG1EGA)
+				if (keyPress == SCI_KEY_TAB) {
+					keyModifier = SCI_KEYMOD_CTRL;
+					keyPress = 'i';
+				}
+
+				// We need to isolate the lower byte when checking modifiers
+				// because of a keyboard driver bug (see engine/kevent.cpp /
+				// kGetEvent)
+				keyModifier &= 0xFF;
+
 				if (itemEntry->keyPress == keyPress &&
-					itemEntry->keyModifier == (keyModifier & 0xFF) &&
+					itemEntry->keyModifier == keyModifier &&
 					itemEntry->enabled)
 					break;
 				itemIterator++;





More information about the Scummvm-git-logs mailing list