Added DPad support to ocarina and text prompts (#137)

* Added DPad support to ocarina playing and text choice selection.

* Wrap changes in CVar

* Fix mapping not updating if CVar is changed in-game

* Remove unnecessary const_cast

* Fixed transparent texture making framebuffers also transparent in D3D11. (#84)

This happened with the Mirror Shield in the inventory screen preview.

* Add save editor

* Added DPad support to ocarina playing and text choice selection.

* Fixing rebase conflict

* Fix mapping not updating if CVar is changed in-game

* Remove unnecessary const_cast

* Added DPad support to file selection and pause screens (#124)

* Added DPad support to file selection and pause screens

* Wrap changes behind CVar

* Fix merge conflict for real

* Remove unnecessary const_cast

* Fixed transparent texture making framebuffers also transparent in D3D11. (#84)

This happened with the Mirror Shield in the inventory screen preview.

* Add save editor

* Added DPad support to file selection and pause screens

* Fixing rebase conflict

* Remove unnecessary const_cast

Co-authored-by: MaikelChan <maikelchan88@gmail.com>
Co-authored-by: rozlette <Rozelette@users.noreply.github.com>

* Added DPad support to ocarina playing and text choice selection.

* Fixing rebase conflict again

* Fix mapping not updating if CVar is changed in-game

Co-authored-by: MaikelChan <maikelchan88@gmail.com>
Co-authored-by: rozlette <Rozelette@users.noreply.github.com>
This commit is contained in:
Josh Bodner 2022-04-11 14:06:55 -07:00 committed by GitHub
parent beb454d000
commit 03a5c7ed29
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 41 additions and 22 deletions

View File

@ -93,6 +93,9 @@ namespace Game {
Settings.controller.dpad_pause_name = stob(Conf[ControllerSection]["dpad_pause_name"]);
CVar_SetS32("gDpadPauseName", Settings.controller.dpad_pause_name);
Settings.controller.dpad_ocarina_text = stob(Conf[ControllerSection]["dpad_ocarina_text"]);
CVar_SetS32("gDpadOcarinaText", Settings.controller.dpad_ocarina_text);
// Cheats
Settings.cheats.debug_mode = stob(Conf[CheatSection]["debug_mode"]);
CVar_SetS32("gDebugEnabled", Settings.cheats.debug_mode);
@ -153,6 +156,7 @@ namespace Game {
Conf[ControllerSection]["input_scale"] = std::to_string(Settings.controller.input_scale);
Conf[ControllerSection]["input_enabled"] = std::to_string(Settings.controller.input_enabled);
Conf[ControllerSection]["dpad_pause_name"] = std::to_string(Settings.controller.dpad_pause_name);
Conf[ControllerSection]["dpad_ocarina_text"] = std::to_string(Settings.controller.dpad_ocarina_text);
// Cheats
Conf[CheatSection]["debug_mode"] = std::to_string(Settings.cheats.debug_mode);

View File

@ -35,6 +35,7 @@ struct SoHConfigType {
float gyroDriftY = 0.0f;
bool input_enabled = false;
bool dpad_pause_name = false;
bool dpad_ocarina_text = false;
} controller;
// Cheats

View File

@ -360,6 +360,11 @@ namespace SohImGui {
needs_save = true;
}
if (ImGui::Checkbox("DPad Support in Ocarina and Text Choice", &Game::Settings.controller.dpad_ocarina_text)) {
CVar_SetS32("gDpadOcarinaText", Game::Settings.controller.dpad_ocarina_text);
needs_save = true;
}
ImGui::EndMenu();
}

View File

@ -824,10 +824,12 @@ NatureAmbienceDataIO sNatureAmbienceDataIO[20] = {
},
};
u32 sOcarinaAllowedBtnMask = 0x800F;
s32 sOcarinaABtnMap = 0x8000;
s32 sOcarinaCUPBtnMap = 8;
s32 sOcarinaCDownBtnMap = 4;
u32 sOcarinaAllowedBtnMask = (BTN_A | BTN_CUP | BTN_CDOWN | BTN_CLEFT | BTN_CRIGHT);
s32 sOcarinaABtnMap = BTN_A;
s32 sOcarinaCUPBtnMap = BTN_CUP;
s32 sOcarinaCDownBtnMap = BTN_CDOWN;
s32 sOcarinaCLeftBtnMap = BTN_CLEFT;
s32 sOcarinaCRightBtnMap = BTN_CRIGHT;
u8 sOcarinaInpEnabled = 0;
s8 D_80130F10 = 0; // "OCA", ocarina active?
u8 sCurOcarinaBtnVal = 0xFF;
@ -1245,19 +1247,23 @@ void func_800F56A8(void);
void Audio_PlayNatureAmbienceSequence(u8 natureAmbienceId);
s32 Audio_SetGanonDistVol(u8 targetVol);
void func_800EC960(u8 custom) {
if (!custom) {
osSyncPrintf("AUDIO : Ocarina Control Assign Normal\n");
// Function originally not called, so repurposing for DPad input
void func_800EC960(u8 dpad) {
if (dpad) {
sOcarinaAllowedBtnMask =
(BTN_A | BTN_CUP | BTN_CDOWN | BTN_CLEFT | BTN_CRIGHT | BTN_DUP | BTN_DDOWN | BTN_DLEFT | BTN_DRIGHT);
sOcarinaABtnMap = BTN_A;
sOcarinaCUPBtnMap = BTN_CUP | BTN_DUP;
sOcarinaCDownBtnMap = BTN_CDOWN | BTN_DDOWN;
sOcarinaCLeftBtnMap = BTN_CLEFT | BTN_DLEFT;
sOcarinaCRightBtnMap = BTN_CRIGHT | BTN_DRIGHT;
} else {
sOcarinaAllowedBtnMask = (BTN_A | BTN_CUP | BTN_CDOWN | BTN_CLEFT | BTN_CRIGHT);
sOcarinaABtnMap = BTN_A;
sOcarinaCUPBtnMap = BTN_CUP;
sOcarinaCDownBtnMap = BTN_CDOWN;
} else {
osSyncPrintf("AUDIO : Ocarina Control Assign Custom\n");
sOcarinaAllowedBtnMask = (BTN_A | BTN_B | BTN_CDOWN | BTN_CLEFT | BTN_CRIGHT);
sOcarinaABtnMap = BTN_B;
sOcarinaCUPBtnMap = BTN_CDOWN;
sOcarinaCDownBtnMap = BTN_A;
sOcarinaCLeftBtnMap = BTN_CLEFT;
sOcarinaCRightBtnMap = BTN_CRIGHT;
}
}
@ -1542,6 +1548,7 @@ void func_800ED200(void) {
void func_800ED458(s32 arg0) {
u32 phi_v1_2;
bool dpad = CVar_GetS32("gDpadOcarinaText", 0);
if (D_80130F3C != 0 && D_80131880 != 0) {
D_80131880--;
@ -1561,6 +1568,7 @@ void func_800ED458(s32 arg0) {
D_8016BA18 &= phi_v1_2;
}
func_800EC960(dpad);
if (D_8016BA18 & sOcarinaABtnMap) {
osSyncPrintf("Presss NA_KEY_D4 %08x\n", sOcarinaABtnMap);
sCurOcarinaBtnVal = 2;
@ -1569,12 +1577,12 @@ void func_800ED458(s32 arg0) {
osSyncPrintf("Presss NA_KEY_F4 %08x\n", sOcarinaCDownBtnMap);
sCurOcarinaBtnVal = 5;
sCurOcarinaBtnIdx = 1;
} else if (D_8016BA18 & 1) {
osSyncPrintf("Presss NA_KEY_A4 %08x\n", 1);
} else if (D_8016BA18 & sOcarinaCRightBtnMap) {
osSyncPrintf("Presss NA_KEY_A4 %08x\n", sOcarinaCRightBtnMap);
sCurOcarinaBtnVal = 9;
sCurOcarinaBtnIdx = 2;
} else if (D_8016BA18 & 2) {
osSyncPrintf("Presss NA_KEY_B4 %08x\n", 2);
} else if (D_8016BA18 & sOcarinaCLeftBtnMap) {
osSyncPrintf("Presss NA_KEY_B4 %08x\n", sOcarinaCRightBtnMap);
sCurOcarinaBtnVal = 0xB;
sCurOcarinaBtnIdx = 3;
} else if (D_8016BA18 & sOcarinaCUPBtnMap) {
@ -1671,7 +1679,7 @@ void Audio_OcaSetSongPlayback(s8 songIdxPlusOne, s8 playbackState) {
void Audio_OcaPlayback(void) {
u32 noteTimerStep;
u32 nextNoteTimerStep;
u32 nextNoteTimerStep = 0;
if (sPlaybackState != 0) {
if (sStaffPlaybackPos == 0) {
@ -4772,7 +4780,7 @@ void Audio_SetCodeReverb(s8 reverb) {
}
void func_800F6700(s8 arg0) {
s8 sp1F;
s8 sp1F = 0;
switch (arg0) {
case 0:

View File

@ -203,8 +203,9 @@ void Message_HandleChoiceSelection(GlobalContext* globalCtx, u8 numChoices) {
static s16 sAnalogStickHeld = false;
MessageContext* msgCtx = &globalCtx->msgCtx;
Input* input = &globalCtx->state.input[0];
bool dpad = CVar_GetS32("gDpadOcarinaText", 0);
if (input->rel.stick_y >= 30 && !sAnalogStickHeld) {
if ((input->rel.stick_y >= 30 && !sAnalogStickHeld) || (dpad && CHECK_BTN_ALL(input->press.button, BTN_DUP))) {
sAnalogStickHeld = true;
msgCtx->choiceIndex--;
if (msgCtx->choiceIndex > 128) {
@ -212,7 +213,7 @@ void Message_HandleChoiceSelection(GlobalContext* globalCtx, u8 numChoices) {
} else {
Audio_PlaySoundGeneral(NA_SE_SY_CURSOR, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8);
}
} else if (input->rel.stick_y <= -30 && !sAnalogStickHeld) {
} else if ((input->rel.stick_y <= -30 && !sAnalogStickHeld) || (dpad && CHECK_BTN_ALL(input->press.button, BTN_DDOWN))) {
sAnalogStickHeld = true;
msgCtx->choiceIndex++;
if (msgCtx->choiceIndex > numChoices) {
@ -3032,7 +3033,7 @@ void Message_Update(GlobalContext* globalCtx) {
Input* input = &globalCtx->state.input[0];
s16 var;
s16 focusScreenPosX;
s16 averageY;
s16 averageY = 0;
s16 playerFocusScreenPosY;
s16 actorFocusScreenPosY;