Wrap changes in CVar

This commit is contained in:
Josh Bodner 2022-04-03 16:15:41 -07:00
commit ca2c8b8348
5 changed files with 22 additions and 17 deletions

View file

@ -90,6 +90,9 @@ namespace Game {
Settings.controller.input_enabled = stob(Conf[ControllerSection]["input_enabled"]); Settings.controller.input_enabled = stob(Conf[ControllerSection]["input_enabled"]);
CVar_SetS32(const_cast<char*>("gInputEnabled"), Settings.controller.input_enabled); CVar_SetS32(const_cast<char*>("gInputEnabled"), Settings.controller.input_enabled);
Settings.controller.dpad_ocarina_text = stob(Conf[ControllerSection]["dpad_ocarina_text"]);
CVar_SetS32(const_cast<char*>("gDpadOcarinaText"), Settings.controller.dpad_ocarina_text);
// Cheats // Cheats
Settings.cheats.debug_mode = stob(Conf[CheatSection]["debug_mode"]); Settings.cheats.debug_mode = stob(Conf[CheatSection]["debug_mode"]);
CVar_SetS32(const_cast<char*>("gDebugEnabled"), Settings.cheats.debug_mode); CVar_SetS32(const_cast<char*>("gDebugEnabled"), Settings.cheats.debug_mode);
@ -149,6 +152,7 @@ namespace Game {
Conf[ControllerSection]["rumble_strength"] = std::to_string(Settings.controller.rumble_strength); Conf[ControllerSection]["rumble_strength"] = std::to_string(Settings.controller.rumble_strength);
Conf[ControllerSection]["input_scale"] = std::to_string(Settings.controller.input_scale); Conf[ControllerSection]["input_scale"] = std::to_string(Settings.controller.input_scale);
Conf[ControllerSection]["input_enabled"] = std::to_string(Settings.controller.input_enabled); Conf[ControllerSection]["input_enabled"] = std::to_string(Settings.controller.input_enabled);
Conf[ControllerSection]["dpad_ocarina_text"] = std::to_string(Settings.controller.dpad_ocarina_text);
// Cheats // Cheats
Conf[CheatSection]["debug_mode"] = std::to_string(Settings.cheats.debug_mode); Conf[CheatSection]["debug_mode"] = std::to_string(Settings.cheats.debug_mode);

View file

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

View file

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

View file

@ -824,13 +824,12 @@ NatureAmbienceDataIO sNatureAmbienceDataIO[20] = {
}, },
}; };
u32 sOcarinaAllowedBtnMask = u32 sOcarinaAllowedBtnMask = (BTN_A | BTN_CUP | BTN_CDOWN | BTN_CLEFT | BTN_CRIGHT);
(BTN_A | BTN_CUP | BTN_CDOWN | BTN_CLEFT | BTN_CRIGHT | BTN_DUP | BTN_DDOWN | BTN_DLEFT | BTN_DRIGHT);
s32 sOcarinaABtnMap = BTN_A; s32 sOcarinaABtnMap = BTN_A;
s32 sOcarinaCUPBtnMap = BTN_CUP | BTN_DUP; s32 sOcarinaCUPBtnMap = BTN_CUP;
s32 sOcarinaCDownBtnMap = BTN_CDOWN | BTN_DDOWN; s32 sOcarinaCDownBtnMap = BTN_CDOWN;
s32 sOcarinaCLeftBtnMap = BTN_CLEFT | BTN_DLEFT; s32 sOcarinaCLeftBtnMap = BTN_CLEFT;
s32 sOcarinaCRightBtnMap = BTN_CRIGHT | BTN_DRIGHT; s32 sOcarinaCRightBtnMap = BTN_CRIGHT;
u8 sOcarinaInpEnabled = 0; u8 sOcarinaInpEnabled = 0;
s8 D_80130F10 = 0; // "OCA", ocarina active? s8 D_80130F10 = 0; // "OCA", ocarina active?
u8 sCurOcarinaBtnVal = 0xFF; u8 sCurOcarinaBtnVal = 0xFF;
@ -1248,8 +1247,9 @@ void func_800F56A8(void);
void Audio_PlayNatureAmbienceSequence(u8 natureAmbienceId); void Audio_PlayNatureAmbienceSequence(u8 natureAmbienceId);
s32 Audio_SetGanonDistVol(u8 targetVol); s32 Audio_SetGanonDistVol(u8 targetVol);
// Function originally not called, so repurposing for DPad input
void func_800EC960(u8 custom) { void func_800EC960(u8 custom) {
if (!custom) { if (custom) {
osSyncPrintf("AUDIO : Ocarina Control Assign Normal\n"); osSyncPrintf("AUDIO : Ocarina Control Assign Normal\n");
sOcarinaAllowedBtnMask = sOcarinaAllowedBtnMask =
(BTN_A | BTN_CUP | BTN_CDOWN | BTN_CLEFT | BTN_CRIGHT | BTN_DUP | BTN_DDOWN | BTN_DLEFT | BTN_DRIGHT); (BTN_A | BTN_CUP | BTN_CDOWN | BTN_CLEFT | BTN_CRIGHT | BTN_DUP | BTN_DDOWN | BTN_DLEFT | BTN_DRIGHT);
@ -1258,14 +1258,6 @@ void func_800EC960(u8 custom) {
sOcarinaCDownBtnMap = BTN_CDOWN | BTN_DDOWN; sOcarinaCDownBtnMap = BTN_CDOWN | BTN_DDOWN;
sOcarinaCLeftBtnMap = BTN_CLEFT | BTN_DLEFT; sOcarinaCLeftBtnMap = BTN_CLEFT | BTN_DLEFT;
sOcarinaCRightBtnMap = BTN_CRIGHT | BTN_DRIGHT; sOcarinaCRightBtnMap = BTN_CRIGHT | BTN_DRIGHT;
} 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;
} }
} }
@ -1550,6 +1542,7 @@ void func_800ED200(void) {
void func_800ED458(s32 arg0) { void func_800ED458(s32 arg0) {
u32 phi_v1_2; u32 phi_v1_2;
bool dpad = CVar_GetS32("gDpadOcarinaText", 0);
if (D_80130F3C != 0 && D_80131880 != 0) { if (D_80130F3C != 0 && D_80131880 != 0) {
D_80131880--; D_80131880--;
@ -1569,6 +1562,7 @@ void func_800ED458(s32 arg0) {
D_8016BA18 &= phi_v1_2; D_8016BA18 &= phi_v1_2;
} }
func_800EC960(dpad);
if (D_8016BA18 & sOcarinaABtnMap) { if (D_8016BA18 & sOcarinaABtnMap) {
osSyncPrintf("Presss NA_KEY_D4 %08x\n", sOcarinaABtnMap); osSyncPrintf("Presss NA_KEY_D4 %08x\n", sOcarinaABtnMap);
sCurOcarinaBtnVal = 2; sCurOcarinaBtnVal = 2;

View file

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