From 58866f517f5cb0c2eb138d334a43b8e3da4f9b76 Mon Sep 17 00:00:00 2001 From: robojumper Date: Sat, 26 Jul 2025 18:08:58 +0200 Subject: [PATCH] d_pad_nav OK --- config/SOUE01/splits.txt | 4 +- config/SOUE01/symbols.txt | 52 ++-- configure.py | 2 +- include/d/d_pad.h | 12 + include/d/d_pad_nav.h | 66 +++++ include/m/m_vec.h | 3 + src/d/d_cs_base.cpp | 15 +- src/d/d_cursor_hit_check.cpp | 4 +- src/d/d_pad.cpp | 4 +- src/d/d_pad_nav.cpp | 241 ++++++++++++++++++ src/d/d_scene.cpp | 4 +- src/d/lyt/d_lyt_common_arrow.cpp | 5 +- src/d/lyt/d_lyt_map.cpp | 4 +- .../d_lyt_msg_window_select_btn.cpp | 5 +- 14 files changed, 370 insertions(+), 51 deletions(-) create mode 100644 include/d/d_pad_nav.h create mode 100644 src/d/d_pad_nav.cpp diff --git a/config/SOUE01/splits.txt b/config/SOUE01/splits.txt index 92ad6b69..fd559e4b 100644 --- a/config/SOUE01/splits.txt +++ b/config/SOUE01/splits.txt @@ -1256,9 +1256,11 @@ d/a/d_a_salbage_npc.cpp: .data start:0x8052B078 end:0x8052B618 .bss start:0x805B22E8 end:0x805B2428 -toBeSorted/d_unk_pad.cpp: +d/d_pad_nav.cpp: .text start:0x80194080 end:0x801946F4 align:16 + .sdata start:0x80572D10 end:0x80572D18 .sbss start:0x80575690 end:0x805756A8 + .sdata2 start:0x8057AE80 end:0x8057AE88 toBeSorted/goddess_chest_counter.cpp: .text start:0x80194700 end:0x8019486C align:16 diff --git a/config/SOUE01/symbols.txt b/config/SOUE01/symbols.txt index bb544b36..88f5b12e 100644 --- a/config/SOUE01/symbols.txt +++ b/config/SOUE01/symbols.txt @@ -10397,18 +10397,18 @@ fn_80193F60 = .text:0x80193F60; // type:function size:0x88 fn_80193FF0 = .text:0x80193FF0; // type:function size:0x30 fn_80194020 = .text:0x80194020; // type:function size:0x30 fn_80194050 = .text:0x80194050; // type:function size:0x30 -fn_80194080 = .text:0x80194080; // type:function size:0x38 -fn_801940C0 = .text:0x801940C0; // type:function size:0x228 -fn_801942F0 = .text:0x801942F0; // type:function size:0x54 -fn_80194350 = .text:0x80194350; // type:function size:0x16C -fn_801944C0 = .text:0x801944C0; // type:function size:0xB0 -fn_80194570 = .text:0x80194570; // type:function size:0x14 -fn_80194590 = .text:0x80194590; // type:function size:0xC -fn_801945A0 = .text:0x801945A0; // type:function size:0xC -fn_801945B0 = .text:0x801945B0; // type:function size:0xC -fn_801945C0 = .text:0x801945C0; // type:function size:0x84 -fn_80194650 = .text:0x80194650; // type:function size:0x84 -fn_801946E0 = .text:0x801946E0; // type:function size:0x14 +init__7dPadNavFv = .text:0x80194080; // type:function size:0x38 +calc__7dPadNavFv = .text:0x801940C0; // type:function size:0x228 +setNavEnabled__7dPadNavFbb = .text:0x801942F0; // type:function size:0x54 +getFSStickDirectionTrig__7dPadNavFv = .text:0x80194350; // type:function size:0x16C +getFSStickDirection__7dPadNavFv = .text:0x801944C0; // type:function size:0xB0 +stopFSStickNav__7dPadNavFv = .text:0x80194570; // type:function size:0x14 +hidePointer__7dPadNavFv = .text:0x80194590; // type:function size:0xC +offUnkCursorRelated__7dPadNavFv = .text:0x801945A0; // type:function size:0xC +onUnkCursorRelated__7dPadNavFv = .text:0x801945B0; // type:function size:0xC +checkForNavLeftGesture__7dPadNavFv = .text:0x801945C0; // type:function size:0x84 +checkForNavRightGesture__7dPadNavFv = .text:0x80194650; // type:function size:0x84 +scrollRelated__7dPadNavFv = .text:0x801946E0; // type:function size:0x14 fn_80194700 = .text:0x80194700; // type:function size:0x40 GoddessChestsOpenedCounter__getCommittedValue = .text:0x80194740; // type:function size:0x1C GoddessChestsOpenedCounter__getUncommittedValue = .text:0x80194760; // type:function size:0x1C @@ -39890,9 +39890,9 @@ lbl_80572CFC = .sdata:0x80572CFC; // type:object size:0x4 lbl_80572D00 = .sdata:0x80572D00; // type:object size:0x8 lbl_80572D08 = .sdata:0x80572D08; // type:object size:0x4 data:4byte lbl_80572D0C = .sdata:0x80572D0C; // type:object size:0x4 data:4byte -lbl_80572D10 = .sdata:0x80572D10; // type:object size:0x1 data:byte -lbl_80572D11 = .sdata:0x80572D11; // type:object size:0x1 data:byte -lbl_80572D12 = .sdata:0x80572D12; // type:object size:0x6 data:byte +sIsPointerVisible__7dPadNav = .sdata:0x80572D10; // type:object size:0x1 data:byte +sPrevIsPointerVisible__7dPadNav = .sdata:0x80572D11; // type:object size:0x1 data:byte +sUnkCursorRelated__7dPadNav = .sdata:0x80572D12; // type:object size:0x1 data:byte lbl_80572D18 = .sdata:0x80572D18; // type:object size:0x8 lbl_80572D20 = .sdata:0x80572D20; // type:object size:0x8 lbl_80572D28 = .sdata:0x80572D28; // type:object size:0x8 @@ -41603,15 +41603,15 @@ lbl_80575670 = .sbss:0x80575670; // type:object size:0x8 data:byte lbl_80575678 = .sbss:0x80575678; // type:object size:0x8 data:4byte lbl_80575680 = .sbss:0x80575680; // type:object size:0x8 data:4byte sInstance__15SaveTimeRelated = .sbss:0x80575688; // type:object size:0x8 data:4byte -lbl_80575690 = .sbss:0x80575690; // type:object size:0x1 data:byte -lbl_80575691 = .sbss:0x80575691; // type:object size:0x1 data:byte -lbl_80575692 = .sbss:0x80575692; // type:object size:0x1 data:byte -lbl_80575693 = .sbss:0x80575693; // type:object size:0x1 data:byte -lbl_80575694 = .sbss:0x80575694; // type:object size:0x4 data:4byte -lbl_80575698 = .sbss:0x80575698; // type:object size:0x4 data:4byte -lbl_8057569C = .sbss:0x8057569C; // type:object size:0x4 data:4byte -lbl_805756A0 = .sbss:0x805756A0; // type:object size:0x4 data:4byte -lbl_805756A4 = .sbss:0x805756A4; // type:object size:0x4 data:4byte +sIsNavEnabled__7dPadNav = .sbss:0x80575690; // type:object size:0x1 data:byte +sIsMplsNavLeftGesture__7dPadNav = .sbss:0x80575691; // type:object size:0x1 data:byte +sIsMplsNavRightGesture__7dPadNav = .sbss:0x80575692; // type:object size:0x1 data:byte +sDisableAutoReturnToPointerNav__7dPadNav = .sbss:0x80575693; // type:object size:0x1 scope:local data:byte +sFSStickDirection__7dPadNav = .sbss:0x80575694; // type:object size:0x4 data:4byte +sFSStickNavDirection__7dPadNav = .sbss:0x80575698; // type:object size:0x4 data:4byte +sFSStickNavActiveTimer__7dPadNav = .sbss:0x8057569C; // type:object size:0x4 scope:local data:4byte +sFSStickDirectionStableTimer__7dPadNav = .sbss:0x805756A0; // type:object size:0x4 scope:local data:4byte +sMPLSNavGestureTimer__7dPadNav = .sbss:0x805756A4; // type:object size:0x4 scope:local data:4byte sInstance__19GoddessChestCounter = .sbss:0x805756A8; // type:object size:0x8 data:4byte sInstance__9dScBoot_c = .sbss:0x805756B0; // type:object size:0x4 data:4byte sInstance__11dTitleMgr_c = .sbss:0x805756B4; // type:object size:0x4 data:4byte @@ -46330,8 +46330,8 @@ lbl_8057AE70 = .sdata2:0x8057AE70; // type:object size:0x4 align:4 data:float lbl_8057AE74 = .sdata2:0x8057AE74; // type:object size:0x4 align:4 data:float lbl_8057AE78 = .sdata2:0x8057AE78; // type:object size:0x4 align:4 data:float lbl_8057AE7C = .sdata2:0x8057AE7C; // type:object size:0x4 align:4 data:float -lbl_8057AE80 = .sdata2:0x8057AE80; // type:object size:0x4 align:4 data:float -lbl_8057AE84 = .sdata2:0x8057AE84; // type:object size:0x4 align:4 data:float +@3537 = .sdata2:0x8057AE80; // type:object size:0x4 scope:local align:4 data:float +@3648 = .sdata2:0x8057AE84; // type:object size:0x4 scope:local align:4 data:float lbl_8057AE88 = .sdata2:0x8057AE88; // type:object size:0x8 align:8 data:double lbl_8057AE90 = .sdata2:0x8057AE90; // type:object size:0x4 align:4 data:float lbl_8057AE94 = .sdata2:0x8057AE94; // type:object size:0x4 align:4 data:float diff --git a/configure.py b/configure.py index 48379a83..f815d500 100644 --- a/configure.py +++ b/configure.py @@ -564,7 +564,7 @@ config.libs = [ Object(NonMatching, "toBeSorted/unk_save_time.cpp"), Object(NonMatching, "d/a/d_a_salbage_obj.cpp"), Object(NonMatching, "d/a/d_a_salbage_npc.cpp"), - Object(NonMatching, "toBeSorted/d_unk_pad.cpp"), + Object(Matching, "d/d_pad_nav.cpp"), Object(NonMatching, "toBeSorted/goddess_chest_counter.cpp"), Object(NonMatching, "toBeSorted/misc_actor.cpp"), Object(NonMatching, "d/d_hbm.cpp"), diff --git a/include/d/d_pad.h b/include/d/d_pad.h index fbfca801..b5ee5956 100644 --- a/include/d/d_pad.h +++ b/include/d/d_pad.h @@ -177,6 +177,18 @@ public: return m_current_ex; } + bool getFSStickTrig(u32 mask) const { + return mFSStickMaskChanged && mFSStickMask == mask; + } + + bool getFSStickTrig() const { + return mFSStickMaskChanged && (mFSStickMask & 0xFF) != 0; + } + + const mVec3_c& getMPLSVelocity() const { + return mMPLSVelocity; + } + enum ExState_e { EX_STATE_WAITING_FOR_CONNECT = 0, EX_STATE_POST_CONNECT = 1, diff --git a/include/d/d_pad_nav.h b/include/d/d_pad_nav.h new file mode 100644 index 00000000..c74f5d53 --- /dev/null +++ b/include/d/d_pad_nav.h @@ -0,0 +1,66 @@ +#ifndef D_PAD_NAV_H +#define D_PAD_NAV_H + +/** + * Navigation with Wiimote and Nunchuk - seamlessly switching + * between pointer (dpd) and Nunchuk stick (FSStick). + */ +#include "common.h" + +namespace dPadNav { + +enum FSStickDirection_e { + FS_STICK_NONE = 0, + FS_STICK_UP = 1, + FS_STICK_UP_RIGHT = 2, + FS_STICK_RIGHT = 3, + FS_STICK_DOWN_RIGHT = 4, + FS_STICK_DOWN = 5, + FS_STICK_DOWN_LEFT = 6, + FS_STICK_LEFT = 7, + FS_STICK_UP_LEFT = 8, +}; + +extern bool sIsNavEnabled; +// WARNING: Swinging the Wiimote to the right -> navigate left. +// This naming refers to the latter (where the navigation goes). +extern bool sIsMplsNavLeftGesture; +extern bool sIsMplsNavRightGesture; + +extern bool sIsPointerVisible; +extern bool sPrevIsPointerVisible; +extern bool sUnkCursorRelated; + +extern s32 sFSStickDirection; +extern s32 sFSStickNavDirection; + +inline bool isPointerVisible() { + return sIsPointerVisible; +} + + +void init(); +void calc(); +void setNavEnabled(bool navEnabled, bool autoReturnToPointerNav); + +// I really wish these returned enums but the codegen requires not-enums +s32 getFSStickDirection(); +s32 getFSStickDirectionTrig(); + +void stopFSStickNav(); +void hidePointer(); + +void offUnkCursorRelated(); +void onUnkCursorRelated(); + +// Not sure what this does. Related to Deposit +// and Seeker Stone scrolling +void scrollRelated(); + +// detail: +void checkForNavRightGesture(); +void checkForNavLeftGesture(); + +} // namespace dPadNav + +#endif diff --git a/include/m/m_vec.h b/include/m/m_vec.h index c540f470..8f1f5c29 100644 --- a/include/m/m_vec.h +++ b/include/m/m_vec.h @@ -235,6 +235,9 @@ public: f32 squareMagXZ() const { return x * x + z * z; } + f32 squareMagXY() const { + return x * x + y * y; + } f32 squareDistanceToXZ(const mVec3_c &other) const { return (*this - other).squareMagXZ(); } diff --git a/src/d/d_cs_base.cpp b/src/d/d_cs_base.cpp index 1326c80c..e95a73c5 100644 --- a/src/d/d_cs_base.cpp +++ b/src/d/d_cs_base.cpp @@ -1,6 +1,8 @@ #include "d/d_cs_base.h" #include "common.h" +#include "d/d_pad_nav.h" +#include "d/lyt/d_lyt_cursor_stick.h" #include "f/f_base.h" #include "f/f_profile_name.h" #include "nw4r/math/math_types.h" @@ -26,11 +28,6 @@ dCsBase_c::~dCsBase_c() { sInstance = nullptr; } -extern "C" void fn_8016B2B0(); -extern "C" void fn_8016B2E0(); -extern "C" bool lbl_80572D10; -extern "C" int lbl_80573438; - static const char *sLytNames[] = { "P1_Def.brlyt", "P1_Cat.brlyt", @@ -49,7 +46,7 @@ int dCsBase_c::create() { setCurrentLyt(0); mCursorIf.setCursorMask(1); dCsMgr_c::GetInstance()->registCursor(&mCursorIf); - fn_8016B2B0(); + dLytCursorStick_c::build(); field_0x6F0 = 0.0f; field_0x6F4 = 0.0f; field_0x6F8 = 0.0f; @@ -64,7 +61,7 @@ int dCsBase_c::create() { int dCsBase_c::doDelete() { dCsMgr_c::GetInstance()->unregistCursor(&mCursorIf); - fn_8016B2E0(); + dLytCursorStick_c::remove(); mResAcc.detach(); return SUCCEEDED; } @@ -80,7 +77,7 @@ int dCsBase_c::draw() { return SUCCEEDED; } - if (field_0x703 && lbl_80572D10 && field_0x702) { + if (field_0x703 && dPadNav::isPointerVisible() && field_0x702) { nw4r::lyt::Pane *p = mpCurrLyt->getLayout()->GetRootPane(); nw4r::math::VEC3 pos; pos.x = field_0x6F0; @@ -108,7 +105,7 @@ bool dCsBase_c::drawDirectly() { return true; } - if (field_0x703 && lbl_80572D10 && field_0x702) { + if (field_0x703 && dPadNav::isPointerVisible() && field_0x702) { nw4r::lyt::Pane *p = mpCurrLyt->getLayout()->GetRootPane(); nw4r::math::VEC3 pos; pos.x = field_0x6F0; diff --git a/src/d/d_cursor_hit_check.cpp b/src/d/d_cursor_hit_check.cpp index 47535182..61fe1108 100644 --- a/src/d/d_cursor_hit_check.cpp +++ b/src/d/d_cursor_hit_check.cpp @@ -6,6 +6,7 @@ #include "d/col/cc/d_cc_s.h" #include "d/d_gfx.h" #include "d/d_pad.h" +#include "d/d_pad_nav.h" #include "d/d_stage_mgr.h" #include "m/m_mtx.h" #include "m/m_vec.h" @@ -21,10 +22,9 @@ dCsMgr_c::dCsMgr_c() { sInstance = this; } -extern "C" bool lbl_80572D10; void dCsMgr_c::execute() { // NONMATCHING - TList - if (field_0x18 == 0 && lbl_80572D10 == 0) { + if (field_0x18 == 0 && !dPadNav::isPointerVisible()) { for (CursorList::Iterator it = mList1.GetBeginIter(); it != mList1.GetEndIter(); ++it) { it->mpHit = nullptr; } diff --git a/src/d/d_pad.cpp b/src/d/d_pad.cpp index f90c09d3..57cded2c 100644 --- a/src/d/d_pad.cpp +++ b/src/d/d_pad.cpp @@ -7,6 +7,7 @@ #include "d/d_cs_game.h" #include "d/d_gfx.h" #include "d/d_hbm.h" +#include "d/d_pad_nav.h" #include "d/d_pause.h" #include "d/d_reset.h" #include "d/d_sc_game.h" @@ -134,7 +135,6 @@ void convertDpdPosToScreenPos(mVec2_c &in, mVec2_c &out) { out.y = dGfx_c::getCurrentScreenHeightF() * -0.5f * (1.f + in.y) + dGfx_c::getCurrentScreenTopF(); } -extern "C" void fn_801940C0(); void beginPad_BR() { mPad::beginPad(); @@ -291,7 +291,7 @@ void beginPad_BR() { core->getCoreStatus()->release &= EGG::cCORE_BUTTON_HOME; } } - fn_801940C0(); + dPadNav::calc(); } void endPad_BR() { diff --git a/src/d/d_pad_nav.cpp b/src/d/d_pad_nav.cpp new file mode 100644 index 00000000..62f28216 --- /dev/null +++ b/src/d/d_pad_nav.cpp @@ -0,0 +1,241 @@ +#include "d/d_pad_nav.h" + +#include "d/d_pad.h" +#include "m/m_vec.h" + +namespace dPadNav { + +bool sIsNavEnabled = false; +bool sIsMplsNavLeftGesture = false; +bool sIsMplsNavRightGesture = false; +static bool sDisableAutoReturnToPointerNav = false; + +bool sIsPointerVisible = true; +bool sPrevIsPointerVisible = true; +bool sUnkCursorRelated = true; + +s32 sFSStickDirection; +s32 sFSStickNavDirection; + +static s32 sFSStickNavActiveTimer = 0; +static s32 sFSStickDirectionStableTimer = 0; +static s32 sMPLSNavGestureTimer = 0; + +void init() { + sIsNavEnabled = false; + sIsPointerVisible = true; + sIsMplsNavLeftGesture = false; + sIsMplsNavRightGesture = false; + sDisableAutoReturnToPointerNav = false; + sPrevIsPointerVisible = true; + sFSStickDirection = FS_STICK_NONE; + sFSStickNavDirection = FS_STICK_NONE; + sFSStickNavActiveTimer = 0; + sFSStickDirectionStableTimer = 0; + sMPLSNavGestureTimer = 0; + offUnkCursorRelated(); +} + +void calc() { + sPrevIsPointerVisible = sIsPointerVisible; + sFSStickNavDirection = FS_STICK_NONE; + + if (!sIsNavEnabled) { + return; + } + + mVec3_c vel = dPad::ex_c::getInstance()->getMPLSVelocity(); + if (sMPLSNavGestureTimer != 0) { + sMPLSNavGestureTimer--; + sIsMplsNavLeftGesture = false; + sIsMplsNavRightGesture = false; + } else { + checkForNavLeftGesture(); + checkForNavRightGesture(); + } + + if (vel.squareMagXY() > 1.5f) { + // Large MPLS movement - stop FS stick navigation + stopFSStickNav(); + return; + } + + if (sIsPointerVisible) { + if (dPad::ex_c::getInstance()->getFSStickTrig()) { + // starting FS stick navigation - immediate nav event, with delay of + // 8 frames (267ms) for repeat nav event + sFSStickDirection = getFSStickDirectionTrig(); + sFSStickNavDirection = sFSStickDirection; + sFSStickNavActiveTimer = 120; + sFSStickDirectionStableTimer = 8; + sIsPointerVisible = false; + } + } else { + s32 direction = getFSStickDirection(); + if (sFSStickDirection != FS_STICK_NONE && direction == sFSStickDirection) { + // no change in FS stick direction + sFSStickNavActiveTimer = 120; + if (sFSStickDirectionStableTimer == 0) { + // repeat event - now with a delay of 3 frames (100ms) + sFSStickNavDirection = sFSStickDirection; + sFSStickDirectionStableTimer = 3; + } else { + sFSStickDirectionStableTimer--; + } + } else { + if (dPad::ex_c::getInstance()->getFSStickTrig()) { + // change in FS stick direction - same as if started navigation + direction = getFSStickDirectionTrig(); + sFSStickDirectionStableTimer = 8; + sFSStickDirection = direction; + sFSStickNavDirection = direction; + sFSStickNavActiveTimer = 120; + } else { + // let go of FS stick + sFSStickDirection = FS_STICK_NONE; + sFSStickDirectionStableTimer = 0; + } + } + + if (!sDisableAutoReturnToPointerNav) { + if (sFSStickNavActiveTimer == 0) { + // FS stick nav timer expired (or was set to 0 via explicit call), + // check if we need to return to pointer nav + if (direction != FS_STICK_NONE && sFSStickDirection == direction) { + sFSStickNavActiveTimer = 120; + } else { + if (direction == FS_STICK_NONE) { + // No direction, return to pointer nav + sFSStickDirection = FS_STICK_NONE; + sIsPointerVisible = true; + } else { + sFSStickDirectionStableTimer = 8; + // Note: Redundant check + if (!sDisableAutoReturnToPointerNav) { + sFSStickDirection = direction; + } + sFSStickNavDirection = sFSStickDirection; + sFSStickNavActiveTimer = 120; + } + } + } else { + sFSStickNavActiveTimer--; + } + } + } +} + +void setNavEnabled(bool navEnabled, bool disableAutoReturnToPointerNav) { + sIsNavEnabled = navEnabled; + sIsPointerVisible = true; + if (navEnabled) { + onUnkCursorRelated(); + sDisableAutoReturnToPointerNav = disableAutoReturnToPointerNav; + } else { + offUnkCursorRelated(); + sDisableAutoReturnToPointerNav = false; + } +} + +s32 getFSStickDirectionTrig() { + if (dPad::ex_c::getInstance()->getFSStickTrig(0x1)) { + return FS_STICK_UP; + } + + if (dPad::ex_c::getInstance()->getFSStickTrig(0x80)) { + return FS_STICK_UP_RIGHT; + } + + if (dPad::ex_c::getInstance()->getFSStickTrig(0x40)) { + return FS_STICK_RIGHT; + } + + if (dPad::ex_c::getInstance()->getFSStickTrig(0x20)) { + return FS_STICK_DOWN_RIGHT; + } + + if (dPad::ex_c::getInstance()->getFSStickTrig(0x10)) { + return FS_STICK_DOWN; + } + + if (dPad::ex_c::getInstance()->getFSStickTrig(0x8)) { + return FS_STICK_DOWN_LEFT; + } + + if (dPad::ex_c::getInstance()->getFSStickTrig(0x4)) { + return FS_STICK_LEFT; + } + + if (dPad::ex_c::getInstance()->getFSStickTrig(0x2)) { + return FS_STICK_UP_LEFT; + } + + return FS_STICK_NONE; +} + +s32 getFSStickDirection() { + switch (dPad::ex_c::getInstance()->mFSStickMask) { + case 0x1: return FS_STICK_UP; + case 0x80: return FS_STICK_UP_RIGHT; + case 0x40: return FS_STICK_RIGHT; + case 0x20: return FS_STICK_DOWN_RIGHT; + case 0x10: return FS_STICK_DOWN; + case 0x8: return FS_STICK_DOWN_LEFT; + case 0x4: return FS_STICK_LEFT; + case 0x2: return FS_STICK_UP_LEFT; + } + + return FS_STICK_NONE; +} + +void stopFSStickNav() { + sFSStickNavActiveTimer = 0; + sIsPointerVisible = true; +} + +void hidePointer() { + sIsPointerVisible = false; +} + +void offUnkCursorRelated() { + sUnkCursorRelated = false; +} + +void onUnkCursorRelated() { + sUnkCursorRelated = true; +} + +void checkForNavLeftGesture() { + mVec3_c vel = dPad::ex_c::getInstance()->getMPLSVelocity(); + if (vel.y <= 0.0f && vel.squareMagXY() > 1.5f) { + if (!sIsPointerVisible) { + sMPLSNavGestureTimer = 10; + sIsMplsNavLeftGesture = false; + } else { + sIsMplsNavLeftGesture = true; + } + } else { + sIsMplsNavLeftGesture = false; + } +} + +void checkForNavRightGesture() { + mVec3_c vel = dPad::ex_c::getInstance()->getMPLSVelocity(); + if (vel.y >= 0.0f && vel.squareMagXY() > 1.5f) { + if (!sIsPointerVisible) { + sMPLSNavGestureTimer = 10; + sIsMplsNavRightGesture = false; + } else { + sIsMplsNavRightGesture = true; + } + } else { + sIsMplsNavRightGesture = false; + } +} + +void scrollRelated() { + sFSStickDirectionStableTimer = 3; + sFSStickNavActiveTimer = 120; +} + +} // namespace dPadNav diff --git a/src/d/d_scene.cpp b/src/d/d_scene.cpp index 0a8fa4a4..59f59f7a 100644 --- a/src/d/d_scene.cpp +++ b/src/d/d_scene.cpp @@ -2,6 +2,7 @@ #include "common.h" #include "d/d_base.h" +#include "d/d_pad_nav.h" #include "d/d_reset.h" #include "d/d_rumble.h" #include "f/f_base.h" @@ -14,7 +15,6 @@ static bool gameStateIsActive = true; extern "C" u32 lbl_80574FA0; extern "C" u32 lbl_80574FA4; -extern "C" void fn_801942F0(int, int); dFader_c dScene_c::sFader; @@ -22,7 +22,7 @@ dScene_c::dScene_c() { lbl_80574FA0 = 0; lbl_80574FA4 = 0; setProcControlFlag(ROOT_DISABLE_DRAW | ROOT_DISABLE_EXECUTE); - fn_801942F0(0, 0); + dPadNav::setNavEnabled(false, false); } void dScene_c::postCreate(MAIN_STATE_e state) { diff --git a/src/d/lyt/d_lyt_common_arrow.cpp b/src/d/lyt/d_lyt_common_arrow.cpp index 393f5068..024e81ab 100644 --- a/src/d/lyt/d_lyt_common_arrow.cpp +++ b/src/d/lyt/d_lyt_common_arrow.cpp @@ -2,6 +2,7 @@ #include "d/d_cs_base.h" #include "d/d_cursor_hit_check.h" +#include "d/d_pad_nav.h" #include "d/snd/d_snd_small_effect_mgr.h" #include "rvl/MTX/mtx.h" #include "toBeSorted/arc_managers/layout_arc_manager.h" @@ -144,11 +145,9 @@ void dLytCommonArrow_c::tickDown(d2d::AnmGroup_c *ctrl) { } } -extern "C" u8 lbl_80572D10; - void dLytCommonArrow_c::fn_80168880() { int i = -1; - if (lbl_80572D10 == 0) { + if (!dPadNav::isPointerVisible()) { field_0x6B4 = 2; return; } diff --git a/src/d/lyt/d_lyt_map.cpp b/src/d/lyt/d_lyt_map.cpp index 08a97822..478117d1 100644 --- a/src/d/lyt/d_lyt_map.cpp +++ b/src/d/lyt/d_lyt_map.cpp @@ -1,6 +1,7 @@ #include "d/lyt/d_lyt_map.h" #include "common.h" +#include "d/d_pad_nav.h" #include "d/lyt/d2d.h" #include "d/d_cursor_hit_check.h" #include "egg/core/eggColorFader.h" @@ -395,14 +396,13 @@ void dLytMapFloorBtnMgr_c::initializeState_Wait() {} void dLytMapFloorBtnMgr_c::executeState_Wait() {} void dLytMapFloorBtnMgr_c::finalizeState_Wait() {} -extern "C" void fn_801942F0(int, int); dLytMapFloorBtnMgr_c::~dLytMapFloorBtnMgr_c() { for (int i = 0; i < 4; i++) { if (dCsMgr_c::GetInstance()->isRegist(&mCsHitChecks[i])) { dCsMgr_c::GetInstance()->unregistCursorTarget(&mCsHitChecks[i]); } } - fn_801942F0(0, 0); + dPadNav::setNavEnabled(false, false); } void dLytMapPopupInfo_c::initializeState_Invisible() {} diff --git a/src/d/lyt/msg_window/d_lyt_msg_window_select_btn.cpp b/src/d/lyt/msg_window/d_lyt_msg_window_select_btn.cpp index 5adc3ef8..a837e3e8 100644 --- a/src/d/lyt/msg_window/d_lyt_msg_window_select_btn.cpp +++ b/src/d/lyt/msg_window/d_lyt_msg_window_select_btn.cpp @@ -2,6 +2,7 @@ #include "common.h" #include "d/d_pad.h" +#include "d/d_pad_nav.h" #include "d/lyt/d2d.h" #include "d/snd/d_snd_small_effect_mgr.h" #include "toBeSorted/music_mgrs.h" @@ -524,8 +525,6 @@ bool dLytMsgWindowSelectBtn_c::build(d2d::ResAccIf_c *resAcc) { return true; } -extern "C" void fn_801942F0(int, int); - bool dLytMsgWindowSelectBtn_c::remove() { for (int i = 0; i < SELECT_BTN_NUM_ANIMS; i++) { mAnm[i].unbind(); @@ -534,7 +533,7 @@ bool dLytMsgWindowSelectBtn_c::remove() { if (mBtnHelper.field_0x52 != 0) { mBtnHelper.field_0x52 = 0; - fn_801942F0(0, 0); + dPadNav::setNavEnabled(false, false); } return true;