From 5a872f85e1ecd16645517b8eaa9827ecb9b9d3a7 Mon Sep 17 00:00:00 2001 From: Josh Bodner <30329717+jbodner09@users.noreply.github.com> Date: Sat, 18 Jun 2022 21:09:31 -0700 Subject: [PATCH] Add checkbox to make holding the D-pad act like holding the joystick on the file and pause screens (#454) * Add checkbox to make holding the D-pad act like holding the joystick on the file and pause screens. Also fix unguarded debug camera action. * Removed new cvar from UI, made it enabled by default and control the D-pad hold behavior with the existing cvar instead, changed cvar for debug check too --- soh/src/code/z_camera.c | 2 +- .../ovl_file_choose/z_file_choose.c | 50 +++++++++++++++++- .../ovl_kaleido_scope/z_kaleido_scope_PAL.c | 51 ++++++++++++++++++- 3 files changed, 98 insertions(+), 5 deletions(-) diff --git a/soh/src/code/z_camera.c b/soh/src/code/z_camera.c index 00f3f70f0..e29cf2bf6 100644 --- a/soh/src/code/z_camera.c +++ b/soh/src/code/z_camera.c @@ -7532,7 +7532,7 @@ Vec3s Camera_Update(Camera* camera) { BINANG_TO_DEGF(camera->camDir.x), camera->camDir.y, BINANG_TO_DEGF(camera->camDir.y)); } - if (camera->timer != -1 && CHECK_BTN_ALL(D_8015BD7C->state.input[0].press.button, BTN_DRIGHT)) { + if (camera->timer != -1 && CHECK_BTN_ALL(D_8015BD7C->state.input[0].press.button, BTN_DRIGHT) && CVar_GetS32("gDebugCamera", 0)) { camera->timer = 0; } diff --git a/soh/src/overlays/gamestates/ovl_file_choose/z_file_choose.c b/soh/src/overlays/gamestates/ovl_file_choose/z_file_choose.c index 2dd441de3..63a0e2a81 100644 --- a/soh/src/overlays/gamestates/ovl_file_choose/z_file_choose.c +++ b/soh/src/overlays/gamestates/ovl_file_choose/z_file_choose.c @@ -1698,6 +1698,52 @@ void FileChoose_Main(GameState* thisx) { this->stickRelX = input->rel.stick_x; this->stickRelY = input->rel.stick_y; + if (CVar_GetS32("gDpadHoldChange", 1) && CVar_GetS32("gDpadPauseName", 0)) { + if (CHECK_BTN_ALL(input->cur.button, BTN_DLEFT)) { + if (CHECK_BTN_ALL(input->press.button, BTN_DLEFT)) { + this->inputTimerX = 10; + this->stickXDir = -1; + } else if (--(this->inputTimerX) < 0) { + this->inputTimerX = XREG(6); + input->press.button |= BTN_DLEFT; + } + } else if (CHECK_BTN_ALL(input->rel.button, BTN_DLEFT)) { + this->stickXDir = 0; + } else if (CHECK_BTN_ALL(input->cur.button, BTN_DRIGHT)) { + if (CHECK_BTN_ALL(input->press.button, BTN_DRIGHT)) { + this->inputTimerX = 10; + this->stickXDir = 1; + } else if (--(this->inputTimerX) < 0) { + this->inputTimerX = XREG(6); + input->press.button |= BTN_DRIGHT; + } + } else if (CHECK_BTN_ALL(input->rel.button, BTN_DRIGHT)) { + this->stickXDir = 0; + } + + if (CHECK_BTN_ALL(input->cur.button, BTN_DDOWN)) { + if (CHECK_BTN_ALL(input->press.button, BTN_DDOWN)) { + this->inputTimerY = 10; + this->stickYDir = -1; + } else if (--(this->inputTimerY) < 0) { + this->inputTimerY = XREG(6); + input->press.button |= BTN_DDOWN; + } + } else if (CHECK_BTN_ALL(input->rel.button, BTN_DDOWN)) { + this->stickYDir = 0; + } else if (CHECK_BTN_ALL(input->cur.button, BTN_DUP)) { + if (CHECK_BTN_ALL(input->press.button, BTN_DUP)) { + this->inputTimerY = 10; + this->stickYDir = -1; + } else if (--(this->inputTimerY) < 0) { + this->inputTimerY = XREG(6); + input->press.button |= BTN_DUP; + } + } else if (CHECK_BTN_ALL(input->rel.button, BTN_DUP)) { + this->stickYDir = 0; + } + } + if (this->stickRelX < -30) { if (this->stickXDir == -1) { this->inputTimerX--; @@ -1728,7 +1774,7 @@ void FileChoose_Main(GameState* thisx) { if (this->stickRelY < -30) { if (this->stickYDir == -1) { - this->inputTimerY -= 1; + this->inputTimerY--; if (this->inputTimerY < 0) { this->inputTimerY = 2; } else { @@ -1740,7 +1786,7 @@ void FileChoose_Main(GameState* thisx) { } } else if (this->stickRelY > 30) { if (this->stickYDir == 1) { - this->inputTimerY -= 1; + this->inputTimerY--; if (this->inputTimerY < 0) { this->inputTimerY = 2; } else { diff --git a/soh/src/overlays/misc/ovl_kaleido_scope/z_kaleido_scope_PAL.c b/soh/src/overlays/misc/ovl_kaleido_scope/z_kaleido_scope_PAL.c index 3df68da7c..1b2109d2e 100644 --- a/soh/src/overlays/misc/ovl_kaleido_scope/z_kaleido_scope_PAL.c +++ b/soh/src/overlays/misc/ovl_kaleido_scope/z_kaleido_scope_PAL.c @@ -954,7 +954,7 @@ void KaleidoScope_HandlePageToggles(PauseContext* pauseCtx, Input* input) { bool dpad = CVar_GetS32("gDpadPauseName", 0); if (pauseCtx->cursorSpecialPos == PAUSE_CURSOR_PAGE_LEFT) { - if ((pauseCtx->stickRelX < -30) || (dpad && CHECK_BTN_ALL(input->press.button, BTN_DLEFT))) { + if ((pauseCtx->stickRelX < -30) || (dpad && CHECK_BTN_ALL(input->cur.button, BTN_DLEFT))) { pauseCtx->pageSwitchTimer++; if ((pauseCtx->pageSwitchTimer >= 10) || (pauseCtx->pageSwitchTimer == 0)) { KaleidoScope_SwitchPage(pauseCtx, 0); @@ -963,7 +963,7 @@ void KaleidoScope_HandlePageToggles(PauseContext* pauseCtx, Input* input) { pauseCtx->pageSwitchTimer = -1; } } else if (pauseCtx->cursorSpecialPos == PAUSE_CURSOR_PAGE_RIGHT) { - if ((pauseCtx->stickRelX > 30) || (dpad && CHECK_BTN_ALL(input->press.button, BTN_DRIGHT))) { + if ((pauseCtx->stickRelX > 30) || (dpad && CHECK_BTN_ALL(input->cur.button, BTN_DRIGHT))) { pauseCtx->pageSwitchTimer++; if ((pauseCtx->pageSwitchTimer >= 10) || (pauseCtx->pageSwitchTimer == 0)) { KaleidoScope_SwitchPage(pauseCtx, 2); @@ -1122,6 +1122,7 @@ void KaleidoScope_DrawPages(GlobalContext* globalCtx, GraphicsContext* gfxCtx) { static s16 D_8082AD4C = 0; static s16 D_8082AD50 = 0; PauseContext* pauseCtx = &globalCtx->pauseCtx; + Input* input = &globalCtx->state.input[0]; s16 stepR; s16 stepG; s16 stepB; @@ -1162,6 +1163,52 @@ void KaleidoScope_DrawPages(GlobalContext* globalCtx, GraphicsContext* gfxCtx) { } } + if (CVar_GetS32("gDpadHoldChange", 1) && CVar_GetS32("gDpadPauseName", 0)) { + if (CHECK_BTN_ALL(input->cur.button, BTN_DLEFT)) { + if (CHECK_BTN_ALL(input->press.button, BTN_DLEFT)) { + D_8082AD44 = XREG(8); + D_8082AD4C = -1; + } else if (--D_8082AD44 < 0) { + D_8082AD44 = XREG(6); + input->press.button |= BTN_DLEFT; + } + } else if (CHECK_BTN_ALL(input->rel.button, BTN_DLEFT)) { + D_8082AD4C = 0; + } else if (CHECK_BTN_ALL(input->cur.button, BTN_DRIGHT)) { + if (CHECK_BTN_ALL(input->press.button, BTN_DRIGHT)) { + D_8082AD44 = XREG(8); + D_8082AD4C = 1; + } else if (--D_8082AD44 < 0) { + D_8082AD44 = XREG(6); + input->press.button |= BTN_DRIGHT; + } + } else if (CHECK_BTN_ALL(input->rel.button, BTN_DRIGHT)) { + D_8082AD4C = 0; + } + + if (CHECK_BTN_ALL(input->cur.button, BTN_DDOWN)) { + if (CHECK_BTN_ALL(input->press.button, BTN_DDOWN)) { + D_8082AD48 = XREG(8); + D_8082AD50 = -1; + } else if (--D_8082AD48 < 0) { + D_8082AD48 = XREG(6); + input->press.button |= BTN_DDOWN; + } + } else if (CHECK_BTN_ALL(input->rel.button, BTN_DDOWN)) { + D_8082AD50 = 0; + } else if (CHECK_BTN_ALL(input->cur.button, BTN_DUP)) { + if (CHECK_BTN_ALL(input->press.button, BTN_DUP)) { + D_8082AD48 = XREG(8); + D_8082AD50 = 1; + } else if (--D_8082AD48 < 0) { + D_8082AD48 = XREG(6); + input->press.button |= BTN_DUP; + } + } else if (CHECK_BTN_ALL(input->rel.button, BTN_DUP)) { + D_8082AD50 = 0; + } + } + if (pauseCtx->stickRelX < -30) { if (D_8082AD4C == -1) { if (--D_8082AD44 < 0) {