[Scummvm-git-logs] scummvm master -> 078bfa70cd777e1d25694b3b758f4e5ac5e10fcf

AndywinXp noreply at scummvm.org
Sun Nov 13 23:16:17 UTC 2022


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:
078bfa70cd SCUMM: FT: Fix mouse button-up events being lost during INSANE sequences


Commit: 078bfa70cd777e1d25694b3b758f4e5ac5e10fcf
    https://github.com/scummvm/scummvm/commit/078bfa70cd777e1d25694b3b758f4e5ac5e10fcf
Author: AndywinXp (andywinxp at gmail.com)
Date: 2022-11-14T00:15:45+01:00

Commit Message:
SCUMM: FT: Fix mouse button-up events being lost during INSANE sequences

Changed paths:
    engines/scumm/input.cpp
    engines/scumm/insane/insane.h
    engines/scumm/scumm.h
    engines/scumm/scumm_v7.h


diff --git a/engines/scumm/input.cpp b/engines/scumm/input.cpp
index 782e4ae5f07..716e56a0ea3 100644
--- a/engines/scumm/input.cpp
+++ b/engines/scumm/input.cpp
@@ -397,6 +397,35 @@ void ScummEngine::processInput() {
 			VAR(VAR_LEFTBTN_DOWN) = (_leftBtnPressed & msClicked) != 0;
 			VAR(VAR_RIGHTBTN_DOWN) = (_rightBtnPressed & msClicked) != 0;
 
+			// Full Throttle in its interpreter has two separate input handlers, in order to handle:
+			// - The SCUMM system;
+			// - The INSANE/SMUSH system.
+			//
+			// We currently fetch all input events in ScummEngine::parseEvents() and then
+			// handle them in this function, and this seems to be working fine nonetheless;
+			// unfortunately there is at least one situation in which a mouse button press
+			// can become "sticky" because of this: the mineroad sequence executed on the INSANE system.
+			//
+			// If we press one of the mouse buttons at the wrong time, we end up losing the corresponding
+			// BUTTONUP event, and said button will remain registered as pressed until we press and release
+			// it again.
+			//
+			// Since the SMUSH input handler in the original interpreter gets the input events right at the
+			// source (i.e. the OS), I guess there is no harm in doing the same thing in our code,
+			// fetching the correct state for the mouse buttons right from the event manager, only when
+			// the INSANE/SMUSH system is active.
+			if (_game.id == GID_FT && isInsaneActive()) {
+				VAR(VAR_LEFTBTN_HOLD) = (getEventManager()->getButtonState() & 0x1) != 0 ? 1 : 0;
+				VAR(VAR_RIGHTBTN_HOLD) = (getEventManager()->getButtonState() & 0x2) != 0 ? 1 : 0;
+
+				// Also, fix the state of these two variables, which might still be out of sync...
+				if ((getEventManager()->getButtonState() & 0x1) != 0)
+					_leftBtnPressed &= ~msDown;
+
+				if ((getEventManager()->getButtonState() & 0x2) != 0)
+					_rightBtnPressed &= ~msDown;
+			}
+
 			// WORKAROUND: In COMI main menu, sometimes clicks are not registered
 			// correctly; in particular there usually a situation in which both
 			// states for a mouse button (msClicked and msDown) are being captured.
diff --git a/engines/scumm/insane/insane.h b/engines/scumm/insane/insane.h
index 4d2ad351295..0ca7f3e05b6 100644
--- a/engines/scumm/insane/insane.h
+++ b/engines/scumm/insane/insane.h
@@ -66,6 +66,8 @@ class Insane {
 	void procSKIP(int32 subSize, Common::SeekableReadStream &b);
 	void escapeKeyHandler();
 
+	bool isInsaneActive() { return _insaneIsRunning; }
+
  private:
 
 	ScummEngine_v7 *_vm;
diff --git a/engines/scumm/scumm.h b/engines/scumm/scumm.h
index 6e9ac524284..48f8db4a622 100644
--- a/engines/scumm/scumm.h
+++ b/engines/scumm/scumm.h
@@ -666,6 +666,7 @@ protected:
 	void drawInternalGUIControl(int id, bool highlightColor);
 	int getInternalGUIControlFromCoordinates(int x, int y);
 	virtual bool isSmushActive() { return false; }
+	virtual bool isInsaneActive() { return false; }
 
 	virtual void queryQuit(bool returnToLauncher);
 	virtual void queryRestart();
diff --git a/engines/scumm/scumm_v7.h b/engines/scumm/scumm_v7.h
index b90752cf80a..56d65fe2a21 100644
--- a/engines/scumm/scumm_v7.h
+++ b/engines/scumm/scumm_v7.h
@@ -26,6 +26,7 @@
 
 #include "scumm/scumm_v6.h"
 #include "scumm/charset_v7.h"
+#include "scumm/insane/insane.h"
 
 namespace Scumm {
 
@@ -100,6 +101,7 @@ public:
 	void clearSubtitleQueue();
 	void CHARSET_1() override;
 	bool isSmushActive() override { return _smushActive; }
+	bool isInsaneActive() override { return _insane ? _insane->isInsaneActive() : false; }
 	void removeBlastTexts() override;
 	void restoreBlastTextsRects();
 




More information about the Scummvm-git-logs mailing list