From 874097614a50e61db70060e83599ed9582a0599d Mon Sep 17 00:00:00 2001 From: Kiloku Date: Sat, 28 Dec 2024 08:55:11 -0300 Subject: [PATCH 1/5] Add option to invert Y axis --- src/engine/fox_play.c | 8 ++++++-- src/engine/fox_tank.c | 7 +++++-- src/overlays/ovl_i3/fox_aq.c | 7 +++++-- src/port/ui/ImguiUI.cpp | 3 +++ 4 files changed, 19 insertions(+), 6 deletions(-) diff --git a/src/engine/fox_play.c b/src/engine/fox_play.c index d6ccfe82..4f842e51 100644 --- a/src/engine/fox_play.c +++ b/src/engine/fox_play.c @@ -3699,7 +3699,9 @@ void Player_MoveArwing360(Player* player) { gPlayerTurnStickMod = 0.68f; sp7C = -gInputPress->stick_x; - sp78 = gInputPress->stick_y; + + s8 YAxisMult = CVarGetInteger("gInvertYAxis", 0) ? -1 : 1; + sp78 = gInputPress->stick_y * YAxisMult; Math_SmoothStepToAngle(&player->aerobaticPitch, 0.0f, 0.1f, 5.0f, 0.01f); Matrix_RotateZ(gCalcMatrix, -player->zRotBank * M_DTOR, MTXF_NEW); @@ -3945,7 +3947,9 @@ void Player_MoveArwingOnRails(Player* player) { } stickX = -gInputPress->stick_x; - stickY = +gInputPress->stick_y; + + s8 YAxisMult = CVarGetInteger("gInvertYAxis", 0) ? -1 : 1; + stickY = gInputPress->stick_y * YAxisMult; Math_SmoothStepToAngle(&player->aerobaticPitch, 0.0f, 0.1f, 5.0f, 0.01f); diff --git a/src/engine/fox_tank.c b/src/engine/fox_tank.c index 7e34633b..b1db8f68 100644 --- a/src/engine/fox_tank.c +++ b/src/engine/fox_tank.c @@ -380,7 +380,8 @@ void func_tank_80044868(Player* player) { f32 stickTilt; f32 sp2C; - stickTilt = (gInputPress->stick_y * 0.7f) - 8.0f; + s8 YAxisMult = CVarGetInteger("gInvertYAxis", 0) ? -1 : 1; + stickTilt = (gInputPress->stick_y * 0.7f * YAxisMult) - 8.0f; if (stickTilt < -40.0f) { stickTilt = -40.0f; } @@ -664,7 +665,9 @@ void func_tank_80045678(Player* player) { AUDIO_PLAY_SFX(NA_SE_TANK_GO_UP, player->sfxSource, 0); } player->zRotBank += ((__cosf(gGameFrameCount * M_DTOR * 8.0f) * 10.0f) - player->zRotBank) * 0.1f; - temp = -gInputPress->stick_y; + + s8 YAxisMult = CVarGetInteger("gInvertYAxis", 0) ? -1 : 1; + temp = -gInputPress->stick_y * YAxisMult; Math_SmoothStepToF(&player->rot.x, temp * 0.3f, 0.05f, 5.0f, 0.00001f); Math_SmoothStepToF(&player->boostSpeed, 15.0f, 0.5f, 5.0f, 0.0f); Math_SmoothStepToF(&player->rot.z, 0.0f, 0.1f, 5.0f, 0.00001f); diff --git a/src/overlays/ovl_i3/fox_aq.c b/src/overlays/ovl_i3/fox_aq.c index 9e4738ef..41f76614 100644 --- a/src/overlays/ovl_i3/fox_aq.c +++ b/src/overlays/ovl_i3/fox_aq.c @@ -803,7 +803,8 @@ void Aquas_801AA4BC(Player* player) { void Aquas_UpdateCamera(Player* player) { f32 stickX = +gInputPress->stick_x; - f32 stickY = -gInputPress->stick_y; + s8 YAxisMult = CVarGetInteger("gInvertYAxis", 0) ? -1 : 1; + f32 stickY = -gInputPress->stick_y * YAxisMult; f32 zRot; if (player->state != PLAYERSTATE_ACTIVE) { @@ -877,7 +878,9 @@ void Aquas_BlueMarineMove(Player* player) { Aquas_801A8E30(); stickX = -gInputPress->stick_x; - stickY = +gInputPress->stick_y; + + s8 YAxisMult = CVarGetInteger("gInvertYAxis", 0) ? -1 : 1; + stickY = +gInputPress->stick_y * YAxisMult; gPlayerTurnStickMod = 0.68f; diff --git a/src/port/ui/ImguiUI.cpp b/src/port/ui/ImguiUI.cpp index 99dd148d..c05d5078 100644 --- a/src/port/ui/ImguiUI.cpp +++ b/src/port/ui/ImguiUI.cpp @@ -186,6 +186,9 @@ void DrawSettingsMenu(){ .format = "%.1fx", }); } + UIWidgets::CVarCheckbox("Invert Y Axis", "gInvertYAxis",{ + .tooltip = "Inverts the Y axis for controlling vehicles" + }); ImGui::EndMenu(); } From 4c2129a1e5b08a22da107cc5422f7ddf89b1ccc4 Mon Sep 17 00:00:00 2001 From: Kiloku Date: Sat, 28 Dec 2024 22:27:44 -0300 Subject: [PATCH 2/5] Add CVar == validation and remove extraneous variable --- src/engine/fox_play.c | 7 ++----- src/engine/fox_tank.c | 6 ++---- src/overlays/ovl_i3/fox_aq.c | 6 ++---- 3 files changed, 6 insertions(+), 13 deletions(-) diff --git a/src/engine/fox_play.c b/src/engine/fox_play.c index 4f842e51..b67774af 100644 --- a/src/engine/fox_play.c +++ b/src/engine/fox_play.c @@ -3700,8 +3700,7 @@ void Player_MoveArwing360(Player* player) { sp7C = -gInputPress->stick_x; - s8 YAxisMult = CVarGetInteger("gInvertYAxis", 0) ? -1 : 1; - sp78 = gInputPress->stick_y * YAxisMult; + sp78 = gInputPress->stick_y * (CVarGetInteger("gInvertYAxis", 0) == 0 ? 1 : -1); Math_SmoothStepToAngle(&player->aerobaticPitch, 0.0f, 0.1f, 5.0f, 0.01f); Matrix_RotateZ(gCalcMatrix, -player->zRotBank * M_DTOR, MTXF_NEW); @@ -3947,9 +3946,7 @@ void Player_MoveArwingOnRails(Player* player) { } stickX = -gInputPress->stick_x; - - s8 YAxisMult = CVarGetInteger("gInvertYAxis", 0) ? -1 : 1; - stickY = gInputPress->stick_y * YAxisMult; + stickY = gInputPress->stick_y * (CVarGetInteger("gInvertYAxis", 0) == 0 ? 1 : -1); Math_SmoothStepToAngle(&player->aerobaticPitch, 0.0f, 0.1f, 5.0f, 0.01f); diff --git a/src/engine/fox_tank.c b/src/engine/fox_tank.c index b1db8f68..51378543 100644 --- a/src/engine/fox_tank.c +++ b/src/engine/fox_tank.c @@ -380,8 +380,7 @@ void func_tank_80044868(Player* player) { f32 stickTilt; f32 sp2C; - s8 YAxisMult = CVarGetInteger("gInvertYAxis", 0) ? -1 : 1; - stickTilt = (gInputPress->stick_y * 0.7f * YAxisMult) - 8.0f; + stickTilt = (gInputPress->stick_y * 0.7f * (CVarGetInteger("gInvertYAxis", 0) == 0 ? 1 : -1)) - 8.0f; if (stickTilt < -40.0f) { stickTilt = -40.0f; } @@ -666,8 +665,7 @@ void func_tank_80045678(Player* player) { } player->zRotBank += ((__cosf(gGameFrameCount * M_DTOR * 8.0f) * 10.0f) - player->zRotBank) * 0.1f; - s8 YAxisMult = CVarGetInteger("gInvertYAxis", 0) ? -1 : 1; - temp = -gInputPress->stick_y * YAxisMult; + temp = -gInputPress->stick_y * (CVarGetInteger("gInvertYAxis", 0) == 0 ? 1 : -1); Math_SmoothStepToF(&player->rot.x, temp * 0.3f, 0.05f, 5.0f, 0.00001f); Math_SmoothStepToF(&player->boostSpeed, 15.0f, 0.5f, 5.0f, 0.0f); Math_SmoothStepToF(&player->rot.z, 0.0f, 0.1f, 5.0f, 0.00001f); diff --git a/src/overlays/ovl_i3/fox_aq.c b/src/overlays/ovl_i3/fox_aq.c index 41f76614..cb5153f1 100644 --- a/src/overlays/ovl_i3/fox_aq.c +++ b/src/overlays/ovl_i3/fox_aq.c @@ -803,8 +803,7 @@ void Aquas_801AA4BC(Player* player) { void Aquas_UpdateCamera(Player* player) { f32 stickX = +gInputPress->stick_x; - s8 YAxisMult = CVarGetInteger("gInvertYAxis", 0) ? -1 : 1; - f32 stickY = -gInputPress->stick_y * YAxisMult; + f32 stickY = -gInputPress->stick_y * (CVarGetInteger("gInvertYAxis", 0) == 0 ? 1 : -1); f32 zRot; if (player->state != PLAYERSTATE_ACTIVE) { @@ -879,8 +878,7 @@ void Aquas_BlueMarineMove(Player* player) { stickX = -gInputPress->stick_x; - s8 YAxisMult = CVarGetInteger("gInvertYAxis", 0) ? -1 : 1; - stickY = +gInputPress->stick_y * YAxisMult; + stickY = +gInputPress->stick_y * (CVarGetInteger("gInvertYAxis", 0) == 0 ? 1 : -1); gPlayerTurnStickMod = 0.68f; From ca3593e1609740ed2f2c42d4c8825b25044de07a Mon Sep 17 00:00:00 2001 From: Kiloku Date: Sat, 28 Dec 2024 23:00:54 -0300 Subject: [PATCH 3/5] Flip the equality check --- src/engine/fox_play.c | 4 ++-- src/engine/fox_tank.c | 4 ++-- src/overlays/ovl_i3/fox_aq.c | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/engine/fox_play.c b/src/engine/fox_play.c index b67774af..a0f50a41 100644 --- a/src/engine/fox_play.c +++ b/src/engine/fox_play.c @@ -3700,7 +3700,7 @@ void Player_MoveArwing360(Player* player) { sp7C = -gInputPress->stick_x; - sp78 = gInputPress->stick_y * (CVarGetInteger("gInvertYAxis", 0) == 0 ? 1 : -1); + sp78 = gInputPress->stick_y * (CVarGetInteger("gInvertYAxis", 0) == 1 ? -1 : 1); Math_SmoothStepToAngle(&player->aerobaticPitch, 0.0f, 0.1f, 5.0f, 0.01f); Matrix_RotateZ(gCalcMatrix, -player->zRotBank * M_DTOR, MTXF_NEW); @@ -3946,7 +3946,7 @@ void Player_MoveArwingOnRails(Player* player) { } stickX = -gInputPress->stick_x; - stickY = gInputPress->stick_y * (CVarGetInteger("gInvertYAxis", 0) == 0 ? 1 : -1); + stickY = gInputPress->stick_y * (CVarGetInteger("gInvertYAxis", 0) == 1 ? -1 : 1); Math_SmoothStepToAngle(&player->aerobaticPitch, 0.0f, 0.1f, 5.0f, 0.01f); diff --git a/src/engine/fox_tank.c b/src/engine/fox_tank.c index 51378543..2f7df198 100644 --- a/src/engine/fox_tank.c +++ b/src/engine/fox_tank.c @@ -380,7 +380,7 @@ void func_tank_80044868(Player* player) { f32 stickTilt; f32 sp2C; - stickTilt = (gInputPress->stick_y * 0.7f * (CVarGetInteger("gInvertYAxis", 0) == 0 ? 1 : -1)) - 8.0f; + stickTilt = (gInputPress->stick_y * 0.7f * (CVarGetInteger("gInvertYAxis", 0) == 1 ? -1 : 1)) - 8.0f; if (stickTilt < -40.0f) { stickTilt = -40.0f; } @@ -665,7 +665,7 @@ void func_tank_80045678(Player* player) { } player->zRotBank += ((__cosf(gGameFrameCount * M_DTOR * 8.0f) * 10.0f) - player->zRotBank) * 0.1f; - temp = -gInputPress->stick_y * (CVarGetInteger("gInvertYAxis", 0) == 0 ? 1 : -1); + temp = -gInputPress->stick_y * (CVarGetInteger("gInvertYAxis", 0) == 1 ? -1 : 1); Math_SmoothStepToF(&player->rot.x, temp * 0.3f, 0.05f, 5.0f, 0.00001f); Math_SmoothStepToF(&player->boostSpeed, 15.0f, 0.5f, 5.0f, 0.0f); Math_SmoothStepToF(&player->rot.z, 0.0f, 0.1f, 5.0f, 0.00001f); diff --git a/src/overlays/ovl_i3/fox_aq.c b/src/overlays/ovl_i3/fox_aq.c index cb5153f1..b5934d5c 100644 --- a/src/overlays/ovl_i3/fox_aq.c +++ b/src/overlays/ovl_i3/fox_aq.c @@ -803,7 +803,7 @@ void Aquas_801AA4BC(Player* player) { void Aquas_UpdateCamera(Player* player) { f32 stickX = +gInputPress->stick_x; - f32 stickY = -gInputPress->stick_y * (CVarGetInteger("gInvertYAxis", 0) == 0 ? 1 : -1); + f32 stickY = -gInputPress->stick_y * (CVarGetInteger("gInvertYAxis", 0) == 1 ? -1 : 1); f32 zRot; if (player->state != PLAYERSTATE_ACTIVE) { @@ -878,7 +878,7 @@ void Aquas_BlueMarineMove(Player* player) { stickX = -gInputPress->stick_x; - stickY = +gInputPress->stick_y * (CVarGetInteger("gInvertYAxis", 0) == 0 ? 1 : -1); + stickY = +gInputPress->stick_y * (CVarGetInteger("gInvertYAxis", 0) == 1 ? -1 : 1); gPlayerTurnStickMod = 0.68f; From 9862f6b5cae5544a3e9e04ad80a20e56d78eae94 Mon Sep 17 00:00:00 2001 From: Sarge-117 Date: Mon, 30 Dec 2024 00:44:28 -0800 Subject: [PATCH 4/5] Align ring count to right edge --- src/overlays/ovl_i1/fox_tr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/overlays/ovl_i1/fox_tr.c b/src/overlays/ovl_i1/fox_tr.c index 343566da..4d006b5d 100644 --- a/src/overlays/ovl_i1/fox_tr.c +++ b/src/overlays/ovl_i1/fox_tr.c @@ -11,7 +11,7 @@ void Training_RingPassCount_Draw(void) { if (gRingPassCount != 0) { RCP_SetupDL(&gMasterDisp, SETUPDL_83); gDPSetPrimColor(gMasterDisp++, 0, 0, 255, 255, 255, 255); - HUD_Number_Draw(250.0f, 50.0f, gRingPassCount, 1.0f, 0, 999); + HUD_Number_Draw(OTRGetDimensionFromRightEdge(250.0f), 50.0f, gRingPassCount, 1.0f, 0, 999); } } From e5ec8fa1fdbc5954e4372a11109415644a860538 Mon Sep 17 00:00:00 2001 From: Sarge-117 Date: Mon, 30 Dec 2024 12:28:44 -0800 Subject: [PATCH 5/5] feedback --- src/overlays/ovl_i1/fox_tr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/overlays/ovl_i1/fox_tr.c b/src/overlays/ovl_i1/fox_tr.c index 4d006b5d..1a8f5c03 100644 --- a/src/overlays/ovl_i1/fox_tr.c +++ b/src/overlays/ovl_i1/fox_tr.c @@ -9,7 +9,7 @@ void Training_RingPassCount_Draw(void) { if (gRingPassCount != 0) { - RCP_SetupDL(&gMasterDisp, SETUPDL_83); + RCP_SetupDL(&gMasterDisp, SETUPDL_83_POINT); gDPSetPrimColor(gMasterDisp++, 0, 0, 255, 255, 255, 255); HUD_Number_Draw(OTRGetDimensionFromRightEdge(250.0f), 50.0f, gRingPassCount, 1.0f, 0, 999); }