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

m-kiewitz m_kiewitz at users.sourceforge.net
Sat Feb 11 10:35:20 CET 2017


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:
e64e388816 AGI: Hold-key-mode fix


Commit: e64e3888163b6f5cce0a8e298eb4379b66426bff
    https://github.com/scummvm/scummvm/commit/e64e3888163b6f5cce0a8e298eb4379b66426bff
Author: Martin Kiewitz (m_kiewitz at users.sourceforge.net)
Date: 2017-02-11T10:35:10+01:00

Commit Message:
AGI: Hold-key-mode fix

Original AGI only created a stationary event, when the last
pressed direction key was released. We do that now as well.
Makes cursor in MH1 behave properly.
Thanks to waltervn for pointing this out.

Changed paths:
    engines/agi/agi.cpp
    engines/agi/agi.h
    engines/agi/keyboard.cpp


diff --git a/engines/agi/agi.cpp b/engines/agi/agi.cpp
index 60c8d1f..b293a8e 100644
--- a/engines/agi/agi.cpp
+++ b/engines/agi/agi.cpp
@@ -173,6 +173,7 @@ int AgiEngine::agiInit() {
 #endif
 
 	_keyHoldMode = false;
+	_keyHoldModeLastKey = Common::KEYCODE_INVALID;
 
 	_game.mouseFence.setWidth(0); // Reset
 
@@ -423,6 +424,7 @@ AgiEngine::AgiEngine(OSystem *syst, const AGIGameDescription *gameDesc) : AgiBas
 	_inventory = nullptr;
 
 	_keyHoldMode = false;
+	_keyHoldModeLastKey = Common::KEYCODE_INVALID;
 
 	_artificialDelayCurrentRoom = 0;
 	_artificialDelayCurrentPicture = 0;
diff --git a/engines/agi/agi.h b/engines/agi/agi.h
index b8c30e9..2b62f97 100644
--- a/engines/agi/agi.h
+++ b/engines/agi/agi.h
@@ -27,6 +27,7 @@
 #include "common/error.h"
 #include "common/util.h"
 #include "common/file.h"
+#include "common/keyboard.h"
 #include "common/rect.h"
 #include "common/rendermode.h"
 #include "common/stack.h"
@@ -936,6 +937,7 @@ public:
 	int getDirection(int16 objX, int16 objY, int16 destX, int16 destY, int16 stepSize);
 
 	bool _keyHoldMode;
+	Common::KeyCode _keyHoldModeLastKey;
 
 	// Keyboard
 	int doPollKeyboard();
diff --git a/engines/agi/keyboard.cpp b/engines/agi/keyboard.cpp
index 7ed6794..8fb49fd 100644
--- a/engines/agi/keyboard.cpp
+++ b/engines/agi/keyboard.cpp
@@ -247,6 +247,29 @@ void AgiEngine::processScummVMEvents() {
 				default:
 					break;
 				}
+
+				switch (event.kbd.keycode) {
+				case Common::KEYCODE_LEFT:
+				case Common::KEYCODE_RIGHT:
+				case Common::KEYCODE_UP:
+				case Common::KEYCODE_DOWN:
+				case Common::KEYCODE_HOME:
+				case Common::KEYCODE_END:
+				case Common::KEYCODE_PAGEUP:
+				case Common::KEYCODE_PAGEDOWN:
+				case Common::KEYCODE_KP4:
+				case Common::KEYCODE_KP6:
+				case Common::KEYCODE_KP8:
+				case Common::KEYCODE_KP2:
+				case Common::KEYCODE_KP9:
+				case Common::KEYCODE_KP3:
+				case Common::KEYCODE_KP7:
+				case Common::KEYCODE_KP1:
+					_keyHoldModeLastKey = event.kbd.keycode;
+					break;
+				default:
+					break;
+				}
 			}
 			if (key)
 				keyEnqueue(key);
@@ -255,8 +278,12 @@ void AgiEngine::processScummVMEvents() {
 		case Common::EVENT_KEYUP:
 			if (_keyHoldMode) {
 				// Original AGI actually created direction events in here
-				// We don't do that, that's why we create a stationary event instead, which will
-				// result in a direction change to 0 in handleController().
+				// but only in case the last pressed cursor key was released, in other cases it did nothing.
+				// So when you pressed and held down left and then pressed up, and then released left,
+				// direction wouldn't be changed at all.
+				//
+				// We don't create direction events in here, that's why we create a stationary event instead,
+				// which will result in a direction change to 0 in handleController().
 				switch (event.kbd.keycode) {
 				case Common::KEYCODE_LEFT:
 				case Common::KEYCODE_RIGHT:
@@ -274,7 +301,9 @@ void AgiEngine::processScummVMEvents() {
 				case Common::KEYCODE_KP3:
 				case Common::KEYCODE_KP7:
 				case Common::KEYCODE_KP1:
-					keyEnqueue(AGI_KEY_STATIONARY);
+					if (_keyHoldModeLastKey == event.kbd.keycode) {
+						keyEnqueue(AGI_KEY_STATIONARY);
+					}
 					break;
 				default:
 					break;





More information about the Scummvm-git-logs mailing list