diff --git a/soh/include/functions.h b/soh/include/functions.h index 6f188a842..3898ea63d 100644 --- a/soh/include/functions.h +++ b/soh/include/functions.h @@ -2210,6 +2210,14 @@ s8 PadUtils_GetRelYImpl(Input* input); s8 PadUtils_GetRelX(Input* input); s8 PadUtils_GetRelY(Input* input); void PadUtils_UpdateRelXY(Input* input); +s8 PadUtils_GetCurRX(Input* input); +s8 PadUtils_GetCurRY(Input* input); +void PadUtils_SetRelRXY(Input* input, s32 x, s32 y); +s8 PadUtils_GetRelRXImpl(Input* input); +s8 PadUtils_GetRelRYImpl(Input* input); +s8 PadUtils_GetRelRX(Input* input); +s8 PadUtils_GetRelRY(Input* input); +void PadUtils_UpdateRelRXY(Input* input); s32 PadSetup_Init(OSMesgQueue* mq, u8* outMask, OSContStatus* status); f32 Math_FTanF(f32 x); f32 Math_FFloorF(f32 x); diff --git a/soh/soh/Enhancements/controls/GameControlEditor.cpp b/soh/soh/Enhancements/controls/GameControlEditor.cpp index 98de43f34..c9cab6ba4 100644 --- a/soh/soh/Enhancements/controls/GameControlEditor.cpp +++ b/soh/soh/Enhancements/controls/GameControlEditor.cpp @@ -240,6 +240,8 @@ namespace GameControlEditor { DrawHelpIcon("Inverts the Shield Aiming Y Axis"); UIWidgets::PaddedEnhancementCheckbox("Invert Shield Aiming X Axis", "gInvertShieldAimingXAxis"); DrawHelpIcon("Inverts the Shield Aiming X Axis"); + UIWidgets::PaddedEnhancementCheckbox("Invert Z-Weapon Aiming Y Axis", "gInvertZAimingYAxis", true, true, false, "", UIWidgets::CheckboxGraphics::Cross, true); + DrawHelpIcon("Inverts the Camera Y Axis in:\n-Z-Weapon Aiming"); UIWidgets::PaddedEnhancementCheckbox("Disable Auto-Centering in First-Person View", "gDisableAutoCenterViewFirstPerson"); DrawHelpIcon("Prevents the C-Up view from auto-centering, allowing for Gyro Aiming"); if (UIWidgets::PaddedEnhancementCheckbox("Enable Custom Aiming/First-Person sensitivity", "gEnableFirstPersonSensitivity", true, false)) { diff --git a/soh/src/code/padmgr.c b/soh/src/code/padmgr.c index 4735a259c..3315a9fe8 100644 --- a/soh/src/code/padmgr.c +++ b/soh/src/code/padmgr.c @@ -297,6 +297,11 @@ void PadMgr_ProcessInputs(PadMgr* padMgr) { PadUtils_UpdateRelXY(input); input->press.stick_x += (s8)(input->cur.stick_x - input->prev.stick_x); input->press.stick_y += (s8)(input->cur.stick_y - input->prev.stick_y); + // #region SOH [Enhancement] + PadUtils_UpdateRelRXY(input); + input->press.right_stick_x += (s8)(input->cur.right_stick_x - input->prev.right_stick_x); + input->press.right_stick_y += (s8)(input->cur.right_stick_y - input->prev.right_stick_y); + // #endregion } uint8_t rumble = (padMgr->rumbleEnable[0] > 0); @@ -389,6 +394,11 @@ void PadMgr_RequestPadData(PadMgr* padMgr, Input* inputs, s32 mode) { PadUtils_UpdateRelXY(newInput); newInput->press.stick_x += (s8)(newInput->cur.stick_x - newInput->prev.stick_x); newInput->press.stick_y += (s8)(newInput->cur.stick_y - newInput->prev.stick_y); + // #region SOH [Enhancement] + PadUtils_UpdateRelRXY(newInput); + newInput->press.right_stick_x += (s8)(newInput->cur.right_stick_x - newInput->prev.right_stick_x); + newInput->press.right_stick_y += (s8)(newInput->cur.right_stick_y - newInput->prev.right_stick_y); + // #endregion } ogInput++; newInput++; diff --git a/soh/src/code/padutils.c b/soh/src/code/padutils.c index 6a58b14f6..c4548ae32 100644 --- a/soh/src/code/padutils.c +++ b/soh/src/code/padutils.c @@ -92,3 +92,60 @@ void PadUtils_UpdateRelXY(Input* input) { PadUtils_SetRelXY(input, relX, relY); } + +// #region SOH [Enhancement] +s8 PadUtils_GetCurRX(Input* input) { + return input->cur.right_stick_x; +} + +s8 PadUtils_GetCurRY(Input* input) { + return input->cur.right_stick_y; +} + +void PadUtils_SetRelRXY(Input* input, s32 x, s32 y) { + input->rel.right_stick_x = x; + input->rel.right_stick_y = y; +} + +s8 PadUtils_GetRelRXImpl(Input* input) { + return input->rel.right_stick_x; +} + +s8 PadUtils_GetRelRYImpl(Input* input) { + return input->rel.right_stick_y; +} + +s8 PadUtils_GetRelRX(Input* input) { + return PadUtils_GetRelRXImpl(input); +} + +s8 PadUtils_GetRelRY(Input* input) { + return PadUtils_GetRelRYImpl(input); +} + +void PadUtils_UpdateRelRXY(Input* input) { + s32 curX = PadUtils_GetCurRX(input); + s32 curY = PadUtils_GetCurRY(input); + s32 relX; + s32 relY; + + if (curX > 7) { + relX = (curX < 0x43) ? curX - 7 : 0x43 - 7; + } else if (curX < -7) { + relX = (curX > -0x43) ? curX + 7 : -0x43 + 7; + } else { + relX = 0; + } + + if (curY > 7) { + relY = (curY < 0x43) ? curY - 7 : 0x43 - 7; + + } else if (curY < -7) { + relY = (curY > -0x43) ? curY + 7 : -0x43 + 7; + } else { + relY = 0; + } + + PadUtils_SetRelRXY(input, relX, relY); +} +// #endregion 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 82a600bee..523e7cf11 100644 --- a/soh/src/overlays/actors/ovl_player_actor/z_player.c +++ b/soh/src/overlays/actors/ovl_player_actor/z_player.c @@ -7235,11 +7235,41 @@ s32 func_8083FD78(Player* this, f32* arg1, s16* arg2, PlayState* play) { *arg2 = this->actor.shape.rot.y; } - if (this->unk_664 != NULL) { - func_8083DB98(this, 1); + // #region SOH [Enhancement] + if (CVarGetInteger("gRightStickAiming", 0) || !CVarGetInteger("gInvertZAimingYAxis", 1)) { + + if (this->unk_664 != NULL) { + func_8083DB98(this, 1); + } else { + int8_t relStickY; + + // preserves simultaneous left/right-stick aiming + if (CVarGetInteger("gRightStickAiming", 0)) { + if ((sControlInput->rel.stick_y + sControlInput->rel.right_stick_y) >= 0) { + relStickY = (((sControlInput->rel.stick_y) > (sControlInput->rel.right_stick_y)) + ? (sControlInput->rel.stick_y) + : (sControlInput->rel.right_stick_y)); + } else { + relStickY = (((sControlInput->rel.stick_y) < (sControlInput->rel.right_stick_y)) + ? (sControlInput->rel.stick_y) + : (sControlInput->rel.right_stick_y)); + } + } else { + relStickY = sControlInput->rel.stick_y; + } + + Math_SmoothStepToS(&this->actor.focus.rot.x, + relStickY * (CVarGetInteger("gInvertZAimingYAxis", 1) ? 1 : -1) * 240.0f, 14, 4000, 30); + func_80836AB8(this, 1); + } + // #endregion } else { - Math_SmoothStepToS(&this->actor.focus.rot.x, sControlInput->rel.stick_y * 240.0f, 14, 4000, 30); - func_80836AB8(this, 1); + if (this->unk_664 != NULL) { + func_8083DB98(this, 1); + } else { + Math_SmoothStepToS(&this->actor.focus.rot.x, sControlInput->rel.stick_y * 240.0f, 14, 4000, 30); + func_80836AB8(this, 1); + } } } else { if (this->unk_664 != NULL) {