From 0dabe4cb01e0c55fdb3a625094a26fa768750ddb Mon Sep 17 00:00:00 2001 From: Bit-Crust <166267954+Bit-Crust@users.noreply.github.com> Date: Fri, 11 Oct 2024 14:37:50 -0500 Subject: [PATCH 1/2] Fix mouse position being reset incorrectly at some inappropriate times, but in it's own branch this time. --- Source/Activities/GameActivity.cpp | 6 +++--- Source/Managers/ActivityMan.cpp | 2 +- Source/Managers/UInputMan.cpp | 6 ++++-- Source/System/Controller.cpp | 2 +- 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/Source/Activities/GameActivity.cpp b/Source/Activities/GameActivity.cpp index e7887a07ec..aaa72af61c 100644 --- a/Source/Activities/GameActivity.cpp +++ b/Source/Activities/GameActivity.cpp @@ -1055,7 +1055,7 @@ void GameActivity::UpdateEditing() { DisableAIs(false); InitAIs(); // Reset the mouse value and pathfinding so it'll know about the newly placed stuff - g_UInputMan.SetMouseValueMagnitude(0); + g_UInputMan.SetMouseValueMagnitude(0, g_UInputMan.MouseUsedByPlayer()); g_SceneMan.GetScene()->ResetPathFinding(); // Start the in-game track // g_AudioMan.ClearMusicQueue(); @@ -1235,7 +1235,7 @@ void GameActivity::Update() { if (m_PlayerController[player].IsState(PRESS_SECONDARY)) { // Reset the mouse so the actor doesn't change aim because mouse has been moved if (m_PlayerController[player].IsMouseControlled()) { - g_UInputMan.SetMouseValueMagnitude(0); + g_UInputMan.SetMouseValueMagnitude(0, player); } m_ViewState[player] = ViewState::Normal; @@ -1254,7 +1254,7 @@ void GameActivity::Update() { else if (m_PlayerController[player].IsState(ACTOR_NEXT) || m_PlayerController[player].IsState(ACTOR_PREV) || m_PlayerController[player].IsState(PRESS_FACEBUTTON) || m_PlayerController[player].IsState(PRESS_PRIMARY)) { // Reset the mouse so the actor doesn't change aim because mouse has been moved if (m_PlayerController[player].IsMouseControlled()) { - g_UInputMan.SetMouseValueMagnitude(0); + g_UInputMan.SetMouseValueMagnitude(0, player); } if (pMarkedActor) { diff --git a/Source/Managers/ActivityMan.cpp b/Source/Managers/ActivityMan.cpp index 259a26be49..945012e8c3 100644 --- a/Source/Managers/ActivityMan.cpp +++ b/Source/Managers/ActivityMan.cpp @@ -314,7 +314,7 @@ int ActivityMan::StartActivity(Activity* activity) { g_FrameMan.ClearScreenText(); // Reset the mouse input to the center - g_UInputMan.SetMouseValueMagnitude(0.05F); + g_UInputMan.SetMouseValueMagnitude(0, g_UInputMan.MouseUsedByPlayer()); g_AudioMan.PauseIngameSounds(false); diff --git a/Source/Managers/UInputMan.cpp b/Source/Managers/UInputMan.cpp index 00e011f760..c7f69bf76d 100644 --- a/Source/Managers/UInputMan.cpp +++ b/Source/Managers/UInputMan.cpp @@ -324,15 +324,17 @@ Vector UInputMan::GetMouseMovement(int whichPlayer) const { void UInputMan::SetMouseValueMagnitude(float magCap, int whichPlayer) { if (IsInMultiplayerMode() && whichPlayer >= Players::PlayerOne && whichPlayer < Players::MaxPlayerCount) { m_NetworkAnalogMoveData[whichPlayer].CapMagnitude(m_MouseTrapRadius * magCap); + } else if (whichPlayer != Players::NoPlayer && m_ControlScheme.at(whichPlayer).GetDevice() == InputDevice::DEVICE_MOUSE_KEYB) { + m_AnalogMouseData.SetMagnitude(m_MouseTrapRadius * magCap); } - m_AnalogMouseData.SetMagnitude(m_MouseTrapRadius * magCap); } void UInputMan::SetMouseValueAngle(float angle, int whichPlayer) { if (IsInMultiplayerMode() && whichPlayer >= Players::PlayerOne && whichPlayer < Players::MaxPlayerCount) { m_NetworkAnalogMoveData[whichPlayer].SetAbsRadAngle(angle); + } else if (whichPlayer != Players::NoPlayer && m_ControlScheme.at(whichPlayer).GetDevice() == InputDevice::DEVICE_MOUSE_KEYB) { + m_AnalogMouseData.SetAbsRadAngle(angle); } - m_AnalogMouseData.SetAbsRadAngle(angle); } void UInputMan::SetMousePos(const Vector& newPos, int whichPlayer) const { diff --git a/Source/System/Controller.cpp b/Source/System/Controller.cpp index c751a75772..489ae7ea29 100644 --- a/Source/System/Controller.cpp +++ b/Source/System/Controller.cpp @@ -419,7 +419,7 @@ void Controller::UpdatePlayerAnalogInput() { // Disable sharp aim while moving - this also helps with keyboard vs mouse fighting when moving and aiming in opposite directions if (m_ControlStates[ControlState::BODY_JUMP] && !pieMenuActive) { if (IsMouseControlled()) { - g_UInputMan.SetMouseValueMagnitude(0.3F); + g_UInputMan.SetMouseValueMagnitude(0.3F, m_Player); } m_ControlStates[ControlState::AIM_SHARP] = false; } From 83557ee03167bef9b566f2e1bfb8b27f78b283ef Mon Sep 17 00:00:00 2001 From: Bit-Crust <166267954+Bit-Crust@users.noreply.github.com> Date: Fri, 11 Oct 2024 14:54:37 -0500 Subject: [PATCH 2/2] Hopefully prevent piemenu from not showing up when player two uses a controller --- Source/Entities/Actor.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/Entities/Actor.cpp b/Source/Entities/Actor.cpp index 161f07b55d..5bff51c6ea 100644 --- a/Source/Entities/Actor.cpp +++ b/Source/Entities/Actor.cpp @@ -1347,8 +1347,8 @@ void Actor::DrawHUD(BITMAP* pTargetBitmap, const Vector& targetPos, int whichScr } int actorScreen = g_ActivityMan.GetActivity() ? g_ActivityMan.GetActivity()->ScreenOfPlayer(m_Controller.GetPlayer()) : -1; - bool screenTeamIsSameAsActorTeam = g_ActivityMan.GetActivity() ? g_ActivityMan.GetActivity()->GetTeamOfPlayer(whichScreen) == m_Team : true; - if (m_PieMenu->IsVisible() && screenTeamIsSameAsActorTeam && (!m_PieMenu->IsInNormalAnimationMode() || (m_Controller.IsPlayerControlled() && actorScreen == whichScreen))) { + bool screenTeamIsSameAsActorTeam = g_ActivityMan.GetActivity() ? g_ActivityMan.GetActivity()->GetTeamOfPlayer(g_ActivityMan.GetActivity()->PlayerOfScreen(whichScreen)) == m_Team : true; + if (m_PieMenu->IsVisible() && screenTeamIsSameAsActorTeam && (!m_PieMenu->IsInNormalAnimationMode() || (actorScreen == whichScreen))) { m_PieMenu->Draw(pTargetBitmap, targetPos); }