From c914bd20b8d769ce7acc4f4ca560aa55d65d92f4 Mon Sep 17 00:00:00 2001 From: Ada <60364512+GreatArgorath@users.noreply.github.com> Date: Fri, 21 Oct 2022 05:39:42 +0100 Subject: [PATCH] Adds camera sensitivity option back (#1817) * Adds camera sensitivity option * Fixes default values * Fixes default values (for real this time) --- .../controls/GameControlEditor.cpp | 1 + soh/src/code/z_camera.c | 4 ++-- .../actors/ovl_player_actor/z_player.c | 20 +++++++++---------- 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/soh/soh/Enhancements/controls/GameControlEditor.cpp b/soh/soh/Enhancements/controls/GameControlEditor.cpp index e37d395d7..016fc4794 100644 --- a/soh/soh/Enhancements/controls/GameControlEditor.cpp +++ b/soh/soh/Enhancements/controls/GameControlEditor.cpp @@ -242,6 +242,7 @@ namespace GameControlEditor { ImGui::SetCursorPosX(ImGui::GetCursorPosX() + 5); UIWidgets::PaddedEnhancementCheckbox("Disable Auto-Centering in First Person View", "gDisableAutoCenterView"); DrawHelpIcon("Prevents the C-Up view from auto-centering, allowing for Gyro Aiming"); + UIWidgets::EnhancementSliderFloat("Camera Sensitivity: %d %%", "##Sensitivity", "gCameraSensitivity", 0.01f, 5.0f, "", 1.0f, true, true); } void DrawUI(bool& open) { diff --git a/soh/src/code/z_camera.c b/soh/src/code/z_camera.c index 2c8f7378c..c1003c6dd 100644 --- a/soh/src/code/z_camera.c +++ b/soh/src/code/z_camera.c @@ -1485,8 +1485,8 @@ s32 Camera_Free(Camera* camera) { camera->animState = 1; - f32 newCamX = -D_8015BD7C->state.input[0].cur.right_stick_x * 10.0f; - f32 newCamY = D_8015BD7C->state.input[0].cur.right_stick_y * 10.0f; + f32 newCamX = -D_8015BD7C->state.input[0].cur.right_stick_x * 10.0f * (CVar_GetFloat("gCameraSensitivity", 1.0f)); + f32 newCamY = D_8015BD7C->state.input[0].cur.right_stick_y * 10.0f * (CVar_GetFloat("gCameraSensitivity", 1.0f)); camera->globalCtx->camX += newCamX * (CVar_GetS32("gInvertXAxis", 0) ? -1 : 1); camera->globalCtx->camY += newCamY * (CVar_GetS32("gInvertYAxis", 1) ? 1 : -1); diff --git a/soh/src/overlays/actors/ovl_player_actor/z_player.c b/soh/src/overlays/actors/ovl_player_actor/z_player.c index 21d43654e..c9b1bd79d 100644 --- a/soh/src/overlays/actors/ovl_player_actor/z_player.c +++ b/soh/src/overlays/actors/ovl_player_actor/z_player.c @@ -11230,17 +11230,17 @@ s16 func_8084ABD8(GlobalContext* globalCtx, Player* this, s32 arg2, s16 arg3) { if (!func_8002DD78(this) && !func_808334B4(this) && (arg2 == 0)) { if (!CVar_GetS32("gDisableAutoCenterView", 0)) { - temp2 = sControlInput->rel.stick_y * 240.0f * (CVar_GetS32("gInvertYAxis", 1) ? 1 : -1); + temp2 = sControlInput->rel.stick_y * 240.0f * (CVar_GetS32("gInvertYAxis", 1) ? 1 : -1); // Sensitivity not applied here because higher than default sensitivies will allow the camera to escape the autocentering, and glitch out massively Math_SmoothStepToS(&this->actor.focus.rot.x, temp2, 14, 4000, 30); - temp2 = sControlInput->rel.stick_x * -16.0f * (CVar_GetS32("gInvertXAxis", 0) ? -1 : 1); + temp2 = sControlInput->rel.stick_x * -16.0f * (CVar_GetS32("gInvertXAxis", 0) ? -1 : 1) * (CVar_GetFloat("gCameraSensitivity", 1.0f)); temp2 = CLAMP(temp2, -3000, 3000); this->actor.focus.rot.y += temp2; } else { temp1 = (this->stateFlags1 & PLAYER_STATE1_23) ? 3500 : 14000; temp3 = ((sControlInput->rel.stick_y >= 0) ? 1 : -1) * (s32)((1.0f - Math_CosS(sControlInput->rel.stick_y * 200)) * 1500.0f * - (CVar_GetS32("gInvertYAxis", 1) ? 1 : -1)); + (CVar_GetS32("gInvertYAxis", 1) ? 1 : -1)) * (CVar_GetFloat("gCameraSensitivity", 1.0f)); this->actor.focus.rot.x += temp3; if (fabsf(sControlInput->cur.gyro_x) > 0.01f) { @@ -11249,7 +11249,7 @@ s16 func_8084ABD8(GlobalContext* globalCtx, Player* this, s32 arg2, s16 arg3) { if (fabsf(sControlInput->cur.right_stick_y) > 15.0f && CVar_GetS32("gRightStickAiming", 0) != 0) { this->actor.focus.rot.x -= - (sControlInput->cur.right_stick_y) * 10.0f * (CVar_GetS32("gInvertYAxis", 1) ? -1 : 1); + (sControlInput->cur.right_stick_y) * 10.0f * (CVar_GetS32("gInvertYAxis", 1) ? -1 : 1) * (CVar_GetFloat("gCameraSensitivity", 1.0f)); } this->actor.focus.rot.x = CLAMP(this->actor.focus.rot.x, -temp1, temp1); @@ -11258,7 +11258,7 @@ s16 func_8084ABD8(GlobalContext* globalCtx, Player* this, s32 arg2, s16 arg3) { temp2 = this->actor.focus.rot.y - this->actor.shape.rot.y; temp3 = ((sControlInput->rel.stick_x >= 0) ? 1 : -1) * (s32)((1.0f - Math_CosS(sControlInput->rel.stick_x * 200)) * -1500.0f * - (CVar_GetS32("gInvertXAxis", 0) ? -1 : 1)); + (CVar_GetS32("gInvertXAxis", 0) ? -1 : 1)) * (CVar_GetFloat("gCameraSensitivity", 1.0f)); temp2 += temp3; this->actor.focus.rot.y = CLAMP(temp2, -temp1, temp1) + this->actor.shape.rot.y; @@ -11269,14 +11269,14 @@ s16 func_8084ABD8(GlobalContext* globalCtx, Player* this, s32 arg2, s16 arg3) { if (fabsf(sControlInput->cur.right_stick_x) > 15.0f && CVar_GetS32("gRightStickAiming", 0) != 0) { this->actor.focus.rot.y += - (sControlInput->cur.right_stick_x) * 10.0f * (CVar_GetS32("gInvertXAxis", 0) ? 1 : -1); + (sControlInput->cur.right_stick_x) * 10.0f * (CVar_GetS32("gInvertXAxis", 0) ? 1 : -1) * (CVar_GetFloat("gCameraSensitivity", 1.0f)); } } } else { temp1 = (this->stateFlags1 & PLAYER_STATE1_23) ? 3500 : 14000; temp3 = ((sControlInput->rel.stick_y >= 0) ? 1 : -1) * (s32)((1.0f - Math_CosS(sControlInput->rel.stick_y * 200)) * - 1500.0f * (CVar_GetS32("gInvertYAxis", 1) ? 1 : -1)); + 1500.0f * (CVar_GetS32("gInvertYAxis", 1) ? 1 : -1)) * (CVar_GetFloat("gCameraSensitivity", 1.0f)); this->actor.focus.rot.x += temp3; if (fabsf(sControlInput->cur.gyro_x) > 0.01f) { @@ -11285,7 +11285,7 @@ s16 func_8084ABD8(GlobalContext* globalCtx, Player* this, s32 arg2, s16 arg3) { if (fabsf(sControlInput->cur.right_stick_y) > 15.0f && CVar_GetS32("gRightStickAiming", 0) != 0) { this->actor.focus.rot.x -= - (sControlInput->cur.right_stick_y) * 10.0f * (CVar_GetS32("gInvertYAxis", 1) ? -1 : 1); + (sControlInput->cur.right_stick_y) * 10.0f * (CVar_GetS32("gInvertYAxis", 1) ? -1 : 1) * (CVar_GetFloat("gCameraSensitivity", 1.0f)); } this->actor.focus.rot.x = CLAMP(this->actor.focus.rot.x, -temp1, temp1); @@ -11294,7 +11294,7 @@ s16 func_8084ABD8(GlobalContext* globalCtx, Player* this, s32 arg2, s16 arg3) { temp2 = this->actor.focus.rot.y - this->actor.shape.rot.y; temp3 = ((sControlInput->rel.stick_x >= 0) ? 1 : -1) * (s32)((1.0f - Math_CosS(sControlInput->rel.stick_x * 200)) * - -1500.0f * (CVar_GetS32("gInvertXAxis", 0) ? -1 : 1)); + -1500.0f * (CVar_GetS32("gInvertXAxis", 0) ? -1 : 1)) * (CVar_GetFloat("gCameraSensitivity", 1.0f)); temp2 += temp3; this->actor.focus.rot.y = CLAMP(temp2, -temp1, temp1) + this->actor.shape.rot.y; @@ -11305,7 +11305,7 @@ s16 func_8084ABD8(GlobalContext* globalCtx, Player* this, s32 arg2, s16 arg3) { if (fabsf(sControlInput->cur.right_stick_x) > 15.0f && CVar_GetS32("gRightStickAiming", 0) != 0) { this->actor.focus.rot.y += - (sControlInput->cur.right_stick_x) * 10.0f * (CVar_GetS32("gInvertXAxis", 0) ? 1 : -1); + (sControlInput->cur.right_stick_x) * 10.0f * (CVar_GetS32("gInvertXAxis", 0) ? 1 : -1) * (CVar_GetFloat("gCameraSensitivity", 1.0f)); } }