[Scummvm-git-logs] scummvm master -> 5cf9ac007c2988d45d4274369f029f1e150b29b5

neuromancer noreply at scummvm.org
Wed Aug 19 13:43:04 UTC 2026


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

Summary:
5cf9ac007c SCUMM: RA2: make sure flipped controls are correct when using gamepad


Commit: 5cf9ac007c2988d45d4274369f029f1e150b29b5
    https://github.com/scummvm/scummvm/commit/5cf9ac007c2988d45d4274369f029f1e150b29b5
Author: neuromancer (gustavo.grieco at gmail.com)
Date: 2026-08-19T15:42:52+02:00

Commit Message:
SCUMM: RA2: make sure flipped controls are correct when using gamepad

Changed paths:
    engines/scumm/insane/rebel2/rebel.cpp
    engines/scumm/insane/rebel2/rebel.h


diff --git a/engines/scumm/insane/rebel2/rebel.cpp b/engines/scumm/insane/rebel2/rebel.cpp
index 9fa468e983f..7fb5fabbb94 100644
--- a/engines/scumm/insane/rebel2/rebel.cpp
+++ b/engines/scumm/insane/rebel2/rebel.cpp
@@ -808,7 +808,7 @@ bool InsaneRebel2::notifyEvent(const Common::Event &event) {
 					event.mouse.y >= kRA2GameplayMouseMaxY * mouseScale - kRA2Handler7MouseSettleEdgeMargin * mouseScale;
 
 				if (largeAbsoluteJump && smallRelativeMove && nearWindowEdge) {
-					const Common::Point recenter = getGameplayAimPoint();
+					const Common::Point recenter = getGameplayPointerPos();
 					_gameplayMouseSettleUntil = now + kRA2Handler7MouseSettleExtendMs;
 					warpGameplayMouseNow(recenter.x, recenter.y);
 
@@ -1867,6 +1867,18 @@ Common::Point InsaneRebel2::getRebelAutoPlayAimPoint() {
 	return target;
 }
 
+// Raw pointer space, what _vm->_mouse stores and warpGameplayMouseNow() expects.
+// getGameplayAimPoint() mirrors Y on top of this when the controls are flipped.
+Common::Point InsaneRebel2::getGameplayPointerPos() {
+	int x = _vm->_mouse.x;
+	int y = _vm->_mouse.y;
+	if (isHiRes()) {
+		x /= 2;
+		y /= 2;
+	}
+	return Common::Point(CLIP<int>(x, 0, 319), CLIP<int>(y, 0, 199));
+}
+
 Common::Point InsaneRebel2::getGameplayAimPoint() {
 	if (_rebelAutoPlay && _gameState == kStateGameplay && !_menuInputActive)
 		return getRebelAutoPlayAimPoint();
@@ -1925,7 +1937,7 @@ void InsaneRebel2::updateGameplayAimFromGamepad() {
 			return;
 
 		if (axisX || axisY || _gamepadAimActive) {
-			const Common::Point aimPos = getGameplayAimPoint();
+			const Common::Point aimPos = getGameplayPointerPos();
 			const int centerX = 160;
 			const int centerY = 100;
 			int targetX;
@@ -1985,10 +1997,11 @@ void InsaneRebel2::updateGameplayAimFromGamepad() {
 
 	_gamepadAimActive = true;
 
-	Common::Point aimPos = getGameplayAimPoint();
+	// Must read the space it writes, or a flipped Y oscillates every frame.
+	Common::Point pointerPos = getGameplayPointerPos();
 	const int scale = isHiRes() ? 2 : 1;
-	_vm->_mouse.x = (int16)(CLIP<int>(aimPos.x + deltaX, 0, 319) * scale);
-	_vm->_mouse.y = (int16)(CLIP<int>(aimPos.y + deltaY, 0, 199) * scale);
+	_vm->_mouse.x = (int16)(CLIP<int>(pointerPos.x + deltaX, 0, 319) * scale);
+	_vm->_mouse.y = (int16)(CLIP<int>(pointerPos.y + deltaY, 0, 199) * scale);
 }
 
 bool InsaneRebel2::isBitSet(int n) {
diff --git a/engines/scumm/insane/rebel2/rebel.h b/engines/scumm/insane/rebel2/rebel.h
index 2871a346007..f274136b946 100644
--- a/engines/scumm/insane/rebel2/rebel.h
+++ b/engines/scumm/insane/rebel2/rebel.h
@@ -393,6 +393,7 @@ public:
 
 	int32 processMouse() override;
 	Common::Point getGameplayAimPoint();
+	Common::Point getGameplayPointerPos();
 	Common::Point getRebelAutoPlayAimPoint();
 	void resetMenuGamepadAxis();
 	bool handleMenuGamepadAxisEvent(const Common::Event &event);




More information about the Scummvm-git-logs mailing list