From d8eccdec323dfc1126b87624b73e7effcb2f50bb Mon Sep 17 00:00:00 2001 From: Colin Snover Date: Sun, 16 Jul 2017 14:19:27 -0500 Subject: SCI: Clarify Tab character & modifier workarounds in GfxMenu --- engines/sci/graphics/menu.cpp | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/engines/sci/graphics/menu.cpp b/engines/sci/graphics/menu.cpp index 2caad6f8ce..b7030bbea5 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++; -- cgit v1.2.3