mirror of
https://github.com/zeldaret/ss
synced 2026-09-05 10:27:51 -04:00
d_pad_nav OK
This commit is contained in:
+6
-9
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
+2
-2
@@ -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() {
|
||||
|
||||
@@ -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
|
||||
+2
-2
@@ -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) {
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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() {}
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user