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

AndywinXp noreply at scummvm.org
Mon Nov 13 11:11:57 UTC 2023


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

Summary:
e8ea447c90 SCUMM: Fix remapping of numpad keys on EVENT_KEYUP


Commit: e8ea447c908c443889d2fc9a7121781dad65ab0f
    https://github.com/scummvm/scummvm/commit/e8ea447c908c443889d2fc9a7121781dad65ab0f
Author: Lars Sundström (l.sundstrom at gmail.com)
Date: 2023-11-13T12:11:53+01:00

Commit Message:
SCUMM: Fix remapping of numpad keys on EVENT_KEYUP

Dpad buttons are by default remapped to numpad keys. Up/Down are
KEYCODE_KP8/KEYCODE_KP2 and Left/right are KEYCODE_KP4/KEYCODE_KP6.

The numpad keys are remapped to have a corresponding ASCII value
since the state of the keys are stored in the _keyDownMap array,
indexed by the ASCII value.

It was found that the ASCII values were calculated incorrectly for
EVENT_KEYUP events but correctly for EVENT_KEY DOWN events. In the
latter cases the keyboard event was stored to the _keyPressed member
variable. The keycode was checked and if being a numpad key the
corresponding ASCII value was calculated. The key state was then
stored in the _keyDownMap array using the calculated ASCII value.

For the EVENT_KEYUP events the keyboard event was not stored to the
_keyPressed member variable. The keycode was still checked using the
_keyPressed variable. However the _keyPressed could have been reset
causing the ASCII calculation to fail for the numpad key. The raw
ASCII value of the keyboard event was instead being used to reset
the key state in the _keyDownMap array causing the numpad key to be
left in a pressed state.

This was found when plaing the Lunar Lander mini game in "The Dig"
using the virtual gamepad controller in iOS.

Fix it by writing the keyboard event to the _keyPressed variable
and use the corresponding ASCII value when reseting the key state
in the _keyDownMap array.

Changed paths:
    engines/scumm/input.cpp


diff --git a/engines/scumm/input.cpp b/engines/scumm/input.cpp
index 64858bbf9d3..3a07854ef12 100644
--- a/engines/scumm/input.cpp
+++ b/engines/scumm/input.cpp
@@ -186,14 +186,16 @@ void ScummEngine::parseEvent(Common::Event event) {
 		// remap keypad keys to always have a corresponding ASCII value.
 		// Normally, keypad keys would only have an ASCII value when
 		// NumLock is enabled. This fixes fighting in Indy 3 (Trac #11227)
+
+		_keyPressed = event.kbd;
 		if (_keyPressed.keycode >= Common::KEYCODE_KP0 && _keyPressed.keycode <= Common::KEYCODE_KP9) {
 			_keyPressed.ascii = (_keyPressed.keycode - Common::KEYCODE_KP0) + '0';
 		}
 
-		if (event.kbd.ascii >= 512) {
+		if (_keyPressed.ascii >= 512) {
 			debugC(DEBUG_GENERAL, "keyPressed > 512 (%d)", event.kbd.ascii);
 		} else {
-			_keyDownMap[event.kbd.ascii] = false;
+			_keyDownMap[_keyPressed.ascii] = false;
 
 			// Due to some weird bug with capslock key pressed
 			// generated keydown event is for lower letter but




More information about the Scummvm-git-logs mailing list