Skip to content

Commit

Permalink
Merge pull request #3 from rnconrad/accessibility-dpadlook
Browse files Browse the repository at this point in the history
Add DPad directional look controls in C-up mode
  • Loading branch information
MelonSpeedruns authored Apr 14, 2022
2 parents 6f60652 + 7090a5b commit 3856018
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
1 change: 1 addition & 0 deletions soh/soh/Enhancements/bootcommands.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ void BootCommands_Init()
CVar_RegisterS32("gDisableLOD", 0);
CVar_RegisterS32("gDebugEnabled", 0);
CVar_RegisterS32("gPauseLiveLink", 0);
CVar_RegisterS32("gDPadLook", 0);
CVar_RegisterS32("gAccessibleInteraction", 0);
CVar_RegisterS32("gMoreTargets", 0);
CVar_RegisterS32("gAimAudioCues", 0);
Expand Down
25 changes: 25 additions & 0 deletions soh/src/overlays/actors/ovl_player_actor/z_player.c
Original file line number Diff line number Diff line change
Expand Up @@ -11019,6 +11019,14 @@ void Player_Destroy(Actor* thisx, GlobalContext* globalCtx) {
gSaveContext.linkAge = globalCtx->linkAgeOnLoad;
}

static s16 sDPadRotationLUT[3][3] = {
{ -8000, 0, 8000 },
{ -16000, 0, 16000 },
{ -24000, 32000, 24000 }
};
static Vec3f sRelativeNorthPos;
static f32 sLookNoisePitch;

s16 func_8084ABD8(GlobalContext* globalCtx, Player* this, s32 arg2, s16 arg3) {
s32 temp1;
s16 temp2;
Expand All @@ -11031,6 +11039,23 @@ s16 func_8084ABD8(GlobalContext* globalCtx, Player* this, s32 arg2, s16 arg3) {
temp2 = sControlInput->rel.stick_x * -16.0f;
temp2 = CLAMP(temp2, -3000, 3000);
this->actor.focus.rot.y += temp2;

if (CVar_GetS32("gDPadLook", 0) && (sControlInput->press.button & (BTN_DUP | BTN_DRIGHT | BTN_DDOWN | BTN_DLEFT))) {
s16 x = !!(sControlInput->cur.button & BTN_DRIGHT) - !!(sControlInput->cur.button & BTN_DLEFT);
s16 y = !!(sControlInput->cur.button & BTN_DUP) - !!(sControlInput->cur.button & BTN_DDOWN);
s16 rot = sDPadRotationLUT[y + 1][x + 1];

this->actor.shape.rot.y = rot;
this->actor.focus.rot.y = rot;

sRelativeNorthPos.x = Math_SinS(rot) * -100.0f;
sRelativeNorthPos.y = 0;
sRelativeNorthPos.z = Math_CosS(rot) * 100.0f;

sLookNoisePitch = 1.5f;

Audio_PlaySoundGeneral(NA_SE_OC_REVENGE, &sRelativeNorthPos, 4, &sLookNoisePitch, &D_801333E0, &D_801333E8);
}
}
else {
temp1 = (this->stateFlags1 & PLAYER_STATE1_23) ? 3500 : 14000;
Expand Down

0 comments on commit 3856018

Please sign in to comment.