Maelstrom: Use the X button for thrust instead of thumbstick

From 1b6e0270d83f75b7bd3375dea8eaf333c34e379d Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Wed, 1 Apr 2026 20:42:34 -0700
Subject: [PATCH] Use the X button for thrust instead of thumbstick

We'll also use D-Pad up arrow for thrust unless you're using mobile touch controls.
---
 game/controls.cpp | 19 ++++++++++++-------
 game/steam.cpp    | 26 +++++++++++++++++++++++++-
 game/steam.h      |  1 +
 3 files changed, 38 insertions(+), 8 deletions(-)

diff --git a/game/controls.cpp b/game/controls.cpp
index 66bf872c..84ccb5c4 100644
--- a/game/controls.cpp
+++ b/game/controls.cpp
@@ -437,6 +437,10 @@ static void UpdateControl(Player *player)
 				keys[SHIELD_KEY] = true;
 			}
 
+			if (SDL_GetGamepadButton(gamepad->gamepad, SDL_GAMEPAD_BUTTON_WEST)) {
+				keys[THRUST_KEY] = true;
+			}
+
 			if (SDL_GetGamepadButton(gamepad->gamepad, SDL_GAMEPAD_BUTTON_DPAD_LEFT) ||
 				SDL_GetGamepadAxis(gamepad->gamepad, SDL_GAMEPAD_AXIS_LEFTX) <= -16000 ||
 				SDL_GetGamepadAxis(gamepad->gamepad, SDL_GAMEPAD_AXIS_RIGHTX) <= -16000) {
@@ -449,15 +453,16 @@ static void UpdateControl(Player *player)
 				keys[RIGHT_KEY] = true;
 			}
 
-			if (SDL_GetGamepadButton(gamepad->gamepad, SDL_GAMEPAD_BUTTON_DPAD_UP) ||
-				SDL_GetGamepadAxis(gamepad->gamepad, SDL_GAMEPAD_AXIS_LEFTY) <= -16000 ||
-				SDL_GetGamepadAxis(gamepad->gamepad, SDL_GAMEPAD_AXIS_RIGHTY) <= -16000) {
-				keys[THRUST_KEY] = true;
+			if (SDL_GetGamepadButton(gamepad->gamepad, SDL_GAMEPAD_BUTTON_DPAD_UP)) {
+				// Don't use the D-Pad for thrust on the mobile touch controller
+				if (!GamepadInputFromMobileTouchController(gamepad->gamepad)) {
+					keys[THRUST_KEY] = true;
+				}
 			}
 
-			if (SDL_GetGamepadButton(gamepad->gamepad, SDL_GAMEPAD_BUTTON_DPAD_UP) ||
-				SDL_GetGamepadAxis(gamepad->gamepad, SDL_GAMEPAD_AXIS_LEFTY) <= -16000 ||
-				SDL_GetGamepadAxis(gamepad->gamepad, SDL_GAMEPAD_AXIS_RIGHTY) <= -16000) {
+			if (SDL_GetGamepadButton(gamepad->gamepad, SDL_GAMEPAD_BUTTON_DPAD_DOWN) ||
+				SDL_GetGamepadAxis(gamepad->gamepad, SDL_GAMEPAD_AXIS_LEFTY) >= 16000 ||
+				SDL_GetGamepadAxis(gamepad->gamepad, SDL_GAMEPAD_AXIS_RIGHTY) >= 16000) {
 				keys[BRAKE_KEY] = true;
 			}
 		}
diff --git a/game/steam.cpp b/game/steam.cpp
index 62efa695..e297fff0 100644
--- a/game/steam.cpp
+++ b/game/steam.cpp
@@ -56,6 +56,7 @@ class SteamInterface
 
 	Uint8 GetControlForSession(RemotePlaySessionID_t sessionID);
 
+	bool GamepadInputFromMobileTouchController(SDL_Gamepad *gamepad);
 	RemotePlaySessionID_t GetRemoteSessionForGamepad(SDL_Gamepad *gamepad);
 
 	const char *GetRemotePlayerName(Uint8 controlType);
@@ -373,6 +374,19 @@ void SteamInterface::ProcessInput(const RemotePlayInput_t &input)
 	}
 }
 
+bool SteamInterface::GamepadInputFromMobileTouchController(SDL_Gamepad *gamepad)
+{
+	InputHandle_t handle = SDL_GetGamepadSteamHandle(gamepad);
+	if (!handle) {
+		return false;
+	}
+
+	if (SteamInput()->GetInputTypeForHandle(handle) == k_ESteamInputType_MobileTouch) {
+		return true;
+	}
+	return false;
+}
+
 RemotePlaySessionID_t SteamInterface::GetRemoteSessionForGamepad(SDL_Gamepad *gamepad)
 {
 	InputHandle_t handle = SDL_GetGamepadSteamHandle(gamepad);
@@ -380,7 +394,7 @@ RemotePlaySessionID_t SteamInterface::GetRemoteSessionForGamepad(SDL_Gamepad *ga
 		return 0;
 	}
 
-	RemotePlaySessionID_t sessionID = SteamInput()->GetRemotePlaySessionID( handle );
+	RemotePlaySessionID_t sessionID = SteamInput()->GetRemotePlaySessionID(handle);
 	if (!IsRemotePlayTogether(sessionID)) {
 		return 0;
 	}
@@ -554,6 +568,11 @@ bool SteamStreamingToTablet()
 	return steam.StreamingToTablet();
 }
 
+bool GamepadInputFromMobileTouchController(SDL_Gamepad *gamepad)
+{
+	return steam.GamepadInputFromMobileTouchController(gamepad);
+}
+
 Uint32 GetRemoteSessionForGamepad(SDL_Gamepad *gamepad)
 {
 	return steam.GetRemoteSessionForGamepad(gamepad);
@@ -636,6 +655,11 @@ bool SteamStreamingToTablet()
 	return false;
 }
 
+bool GamepadInputFromMobileTouchController(SDL_Gamepad *gamepad)
+{
+	return false;
+}
+
 RemotePlaySessionID_t GetRemoteSessionForGamepad(SDL_Gamepad* gamepad)
 {
 	return 0;
diff --git a/game/steam.h b/game/steam.h
index 355873fc..46a36605 100644
--- a/game/steam.h
+++ b/game/steam.h
@@ -49,6 +49,7 @@ typedef Uint32 RemotePlaySessionID_t;
 extern bool InitSteam();
 extern bool SteamStreamingToPhone();
 extern bool SteamStreamingToTablet();
+extern bool GamepadInputFromMobileTouchController(SDL_Gamepad *gamepad);
 extern RemotePlaySessionID_t GetRemoteSessionForGamepad(SDL_Gamepad *gamepad);
 extern Uint8 GetRemoteSessionControl(RemotePlaySessionID_t sessionID);
 extern const char *GetRemotePlayerName(Uint8 controlType);