From 4b683021c7af7148961d819f69e4096e384fd5d7 Mon Sep 17 00:00:00 2001 From: opencode Date: Tue, 1 Dec 2026 19:53:17 +0000 Subject: [PATCH] fix: radio wheel input rework, weapon-apply guard, control-lock/close fixes (issue #31 review) --- src/audio/MusicManager.cpp | 6 +++++- src/core/Game.cpp | 11 +++++++++++ src/core/Pad.cpp | 18 ++++++++++++++++++ src/core/config.h | 8 +++++--- src/core/re3.cpp | 2 +- src/extras/weaponwheel.h | 8 +++++--- src/renderer/Hud.cpp | 7 ------- 7 files changed, 45 insertions(+), 15 deletions(-) diff --git a/src/audio/MusicManager.cpp b/src/audio/MusicManager.cpp index ad33ad34..1cb12456 100644 --- a/src/audio/MusicManager.cpp +++ b/src/audio/MusicManager.cpp @@ -538,7 +538,11 @@ cMusicManager::ServiceGameMode() #endif } #ifdef RADIO_SCROLL_TO_PREV_STATION - else if(!CPad::GetPad(0)->ArePlayerControlsDisabled() && (CPad::GetPad(0)->GetMouseWheelDownJustDown() || CPad::GetPad(0)->GetMouseWheelUpJustDown())) { + else if(!CPad::GetPad(0)->ArePlayerControlsDisabled() +#ifdef IMPROVED_WEAPON_WHEEL + && !Wheel_IsRadioWheelOpen() // the radio wheel owns the mouse wheel +#endif + && (CPad::GetPad(0)->GetMouseWheelDownJustDown() || CPad::GetPad(0)->GetMouseWheelUpJustDown())) { int scrollNext = ControlsManager.GetControllerKeyAssociatedWithAction(VEHICLE_CHANGE_RADIO_STATION, MOUSE); int scrollPrev = scrollNext == rsMOUSEWHEELUPBUTTON ? rsMOUSEWHEELDOWNBUTTON : scrollNext == rsMOUSEWHEELDOWNBUTTON ? rsMOUSEWHEELUPBUTTON : -1; diff --git a/src/core/Game.cpp b/src/core/Game.cpp index b3dd1eda..9b5b56b4 100644 --- a/src/core/Game.cpp +++ b/src/core/Game.cpp @@ -38,6 +38,10 @@ #include "Hud.h" #include "IniFile.h" #include "Lights.h" + +#ifdef IMPROVED_WEAPON_WHEEL +#include "weaponwheel.h" +#endif #include "MBlur.h" #include "Messages.h" #include "MemoryCard.h" @@ -1028,6 +1032,13 @@ void CGame::Process(void) FrontEndMenuManager.Process(); POP_MEMID(); +#ifdef IMPROVED_WEAPON_WHEEL + // Wheel state must advance even when CHud::Draw is skipped (frontend menu, + // FADE_2, scene edit, death), otherwise an open wheel could leave + // PLAYERCONTROL_CAMERA set. CGame::Process runs every game frame from Idle. + Wheel_Process(); +#endif + CStreaming::Update(); if (!CTimer::GetIsPaused()) { diff --git a/src/core/Pad.cpp b/src/core/Pad.cpp index 19e72b80..f9b21af5 100644 --- a/src/core/Pad.cpp +++ b/src/core/Pad.cpp @@ -35,6 +35,10 @@ #include "Wanted.h" #include "General.h" +#ifdef IMPROVED_WEAPON_WHEEL +#include "weaponwheel.h" +#endif + #ifdef GTA_PS2 #include "eetypes.h" #include "libpad.h" @@ -1532,7 +1536,14 @@ int16 CPad::GetSteeringLeftRight(void) case 2: { int16 axis = NewState.LeftStickX; +#ifdef IMPROVED_WEAPON_WHEEL + // D-pad left/right (and the arrow keys mapped to it) select radio + // stations while the radio wheel is open; the left stick still + // steers, so driving is not frozen. + int16 dpad = Wheel_IsRadioWheelOpen() ? 0 : (NewState.DPadRight - NewState.DPadLeft) / 2; +#else int16 dpad = (NewState.DPadRight - NewState.DPadLeft) / 2; +#endif if ( Abs(axis) > Abs(dpad) ) return axis; @@ -1652,7 +1663,14 @@ int16 CPad::GetPedWalkLeftRight(void) case 2: { int16 axis = NewState.LeftStickX; +#ifdef IMPROVED_WEAPON_WHEEL + // D-pad left/right (and the arrow keys mapped to it) select radio + // stations while the radio wheel is open; the left stick still + // steers, so driving is not frozen. + int16 dpad = Wheel_IsRadioWheelOpen() ? 0 : (NewState.DPadRight - NewState.DPadLeft) / 2; +#else int16 dpad = (NewState.DPadRight - NewState.DPadLeft) / 2; +#endif if ( Abs(axis) > Abs(dpad) ) return axis; diff --git a/src/core/config.h b/src/core/config.h index cf496946..e677ac31 100644 --- a/src/core/config.h +++ b/src/core/config.h @@ -347,9 +347,11 @@ enum Config { // GTA V-style wheels (issue #31): a hold-to-open radial weapon wheel that replaces // the icon + D-pad weapon cycling, and a radio station wheel that replaces the -// radio-switch station-name HUD. Entirely custom UI, so it lives behind this guard -// and in src/extras/weaponwheel.cpp; no reversed code is changed outside a few -// guarded seams in Pad.cpp, Hud.cpp and MusicManager.cpp. +// radio-switch station-name HUD. The weapon wheel is on-foot and freezes the +// player while held; the radio wheel is vehicle-only and leaves driving controls +// alive. Entirely custom UI, so it lives behind this guard and in +// src/extras/weaponwheel.cpp; no reversed code is changed outside a few guarded +// seams in Pad.cpp, Game.cpp, Hud.cpp and MusicManager.cpp. // Off by default: guard-off builds are byte-identical to vanilla. //#define IMPROVED_WEAPON_WHEEL #ifdef IMPROVED_WEAPON_WHEEL diff --git a/src/core/re3.cpp b/src/core/re3.cpp index e3e069a0..960714c6 100644 --- a/src/core/re3.cpp +++ b/src/core/re3.cpp @@ -974,7 +974,7 @@ DebugMenuPopulate(void) #else false; #endif - DebugMenuAddVarBool8ReadOnly("Gameplay", "Radio wheel (R/L2)", &bRadioWheel); + DebugMenuAddVarBool8ReadOnly("Gameplay", "Radio wheel (R/R3)", &bRadioWheel); static int spawnCarId = MI_LANDSTAL; e = DebugMenuAddVar("Spawn", "Spawn Car ID", &spawnCarId, nil, 1, MI_LANDSTAL, MI_GHOST, carnames); diff --git a/src/extras/weaponwheel.h b/src/extras/weaponwheel.h index 1a4e886b..5aedf957 100644 --- a/src/extras/weaponwheel.h +++ b/src/extras/weaponwheel.h @@ -6,9 +6,11 @@ // Custom UI: this is not reversed code and only exists when IMPROVED_WEAPON_WHEEL // is defined in src/core/config.h. // -// The wheel is processed from CHud::Draw so it never runs outside the render/HUD -// path. Optional art (weapon_wheel/*.png next to the executable) is loaded at -// runtime and every piece falls back to the procedural wheel if it is absent. +// Wheel_Process() runs from CGame::Process (every game frame, including while +// the frontend menu, fades, scene edit or death skip CHud::Draw, so an open +// wheel is always closed promptly). Wheel_Draw() runs at the end of CHud::Draw. +// Optional art (weapon_wheel/*.png next to the executable) is loaded at runtime +// and every piece falls back to the procedural wheel if it is absent. void Wheel_Process(void); void Wheel_Draw(void); diff --git a/src/renderer/Hud.cpp b/src/renderer/Hud.cpp index 7ab4c07c..869897b3 100644 --- a/src/renderer/Hud.cpp +++ b/src/renderer/Hud.cpp @@ -459,13 +459,6 @@ void CHud::SetVehicleName(wchar *name) void CHud::Draw() { -#ifdef IMPROVED_WEAPON_WHEEL - // Custom UI (issue #31). Runs before the replay early-out so an open wheel - // can always release PLAYERCONTROL_CAMERA. Drawing itself happens at the - // end of the function so it sits above the rest of the HUD. - Wheel_Process(); -#endif - // disable hud via second controller if (CPad::GetPad(1)->GetStartJustDown()) m_Wants_To_Draw_Hud = !m_Wants_To_Draw_Hud;