Re-implement old toggles for Dpad and Right Stick Ocarina Playback. (#4660)

This commit is contained in:
Malkierian 2024-12-14 14:31:10 -07:00 committed by GitHub
parent e0f25905c2
commit 4b07a6f59a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 37 additions and 3 deletions

View File

@ -1535,8 +1535,10 @@ void SohInputEditorWindow::DrawMapping(CustomButtonMap& mapping, float labelWidt
void SohInputEditorWindow::DrawOcarinaControlPanel() { void SohInputEditorWindow::DrawOcarinaControlPanel() {
ImVec2 cursor = ImGui::GetCursorPos(); ImVec2 cursor = ImGui::GetCursorPos();
ImGui::SetCursorPos(ImVec2(cursor.x + 24, cursor.y + 5)); ImGui::SetCursorPos(ImVec2(cursor.x, cursor.y + 5));
UIWidgets::EnhancementCheckbox("Dpad Ocarina Playback", CVAR_SETTING("CustomOcarina.Dpad"));
UIWidgets::EnhancementCheckbox("Right Stick Ocarina Playback", CVAR_SETTING("CustomOcarina.RightStick"));
UIWidgets::EnhancementCheckbox("Customize Ocarina Controls", CVAR_SETTING("CustomOcarina.Enabled")); UIWidgets::EnhancementCheckbox("Customize Ocarina Controls", CVAR_SETTING("CustomOcarina.Enabled"));
if (!CVarGetInteger(CVAR_SETTING("CustomOcarina.Enabled"), 0)) { if (!CVarGetInteger(CVAR_SETTING("CustomOcarina.Enabled"), 0)) {

View File

@ -26,6 +26,10 @@
#define Audio_SeqCmd8(playerIdx, a, b, c) \ #define Audio_SeqCmd8(playerIdx, a, b, c) \
Audio_QueueSeqCmd(0x80000000 | ((u8)playerIdx << 24) | ((u8)a << 16) | ((u8)b << 8) | ((u8)c)) Audio_QueueSeqCmd(0x80000000 | ((u8)playerIdx << 24) | ((u8)a << 16) | ((u8)b << 8) | ((u8)c))
#define Audio_SeqCmdF(playerIdx, a) Audio_QueueSeqCmd(0xF0000000 | ((u8)playerIdx << 24) | ((u8)a)) #define Audio_SeqCmdF(playerIdx, a) Audio_QueueSeqCmd(0xF0000000 | ((u8)playerIdx << 24) | ((u8)a))
#define BTN_CUSTOM_RSTICK_UP ((CONTROLLERBUTTONS_T)0x01000000)
#define BTN_CUSTOM_RSTICK_DOWN ((CONTROLLERBUTTONS_T)0x02000000)
#define BTN_CUSTOM_RSTICK_LEFT ((CONTROLLERBUTTONS_T)0x04000000)
#define BTN_CUSTOM_RSTICK_RIGHT ((CONTROLLERBUTTONS_T)0x08000000)
typedef struct { typedef struct {
/* 0x0 */ f32 vol; /* 0x0 */ f32 vol;
@ -1261,13 +1265,26 @@ void Audio_OcaUpdateBtnMap(bool customControls) {
sOcarinaA4BtnMap = BTN_CUSTOM_OCARINA_NOTE_A4; sOcarinaA4BtnMap = BTN_CUSTOM_OCARINA_NOTE_A4;
sOcarinaF4BtnMap = BTN_CUSTOM_OCARINA_NOTE_F4; sOcarinaF4BtnMap = BTN_CUSTOM_OCARINA_NOTE_F4;
sOcarinaD4BtnMap = BTN_CUSTOM_OCARINA_NOTE_D4; sOcarinaD4BtnMap = BTN_CUSTOM_OCARINA_NOTE_D4;
} else { }
else {
sOcarinaD5BtnMap = BTN_CUP; sOcarinaD5BtnMap = BTN_CUP;
sOcarinaB4BtnMap = BTN_CLEFT; sOcarinaB4BtnMap = BTN_CLEFT;
sOcarinaA4BtnMap = BTN_CRIGHT; sOcarinaA4BtnMap = BTN_CRIGHT;
sOcarinaF4BtnMap = BTN_CDOWN; sOcarinaF4BtnMap = BTN_CDOWN;
sOcarinaD4BtnMap = BTN_A; sOcarinaD4BtnMap = BTN_A;
} }
if (CVarGetInteger(CVAR_SETTING("CustomOcarina.Dpad"), 0)) {
sOcarinaD5BtnMap |= BTN_DUP;
sOcarinaB4BtnMap |= BTN_DLEFT;
sOcarinaA4BtnMap |= BTN_DRIGHT;
sOcarinaF4BtnMap |= BTN_DDOWN;
}
if (CVarGetInteger(CVAR_SETTING("CustomOcarina.RightStick"), 0)) {
sOcarinaD5BtnMap |= BTN_CUSTOM_RSTICK_UP;
sOcarinaB4BtnMap |= BTN_CUSTOM_RSTICK_LEFT;
sOcarinaA4BtnMap |= BTN_CUSTOM_RSTICK_RIGHT;
sOcarinaF4BtnMap |= BTN_CUSTOM_RSTICK_DOWN;
}
sOcarinaAllowedBtnMask = ( sOcarinaAllowedBtnMask = (
sOcarinaD5BtnMap | sOcarinaD5BtnMap |
@ -1289,6 +1306,21 @@ void Audio_GetOcaInput(void) {
sPrevOcarinaBtnPress = sp18; sPrevOcarinaBtnPress = sp18;
sCurOcaStick.x = input->rel.stick_x; sCurOcaStick.x = input->rel.stick_x;
sCurOcaStick.y = input->rel.stick_y; sCurOcaStick.y = input->rel.stick_y;
s8 rstick_x = input->cur.right_stick_x;
s8 rstick_y = input->cur.right_stick_y;
const s8 sensitivity = 64;
if (rstick_x > sensitivity) {
sCurOcarinaBtnPress |= BTN_CUSTOM_RSTICK_RIGHT;
}
if (rstick_x < -sensitivity) {
sCurOcarinaBtnPress |= BTN_CUSTOM_RSTICK_LEFT;
}
if (rstick_y > sensitivity) {
sCurOcarinaBtnPress |= BTN_CUSTOM_RSTICK_UP;
}
if (rstick_y < -sensitivity) {
sCurOcarinaBtnPress |= BTN_CUSTOM_RSTICK_DOWN;
}
} }
f32 Audio_OcaAdjStick(s8 inp) { f32 Audio_OcaAdjStick(s8 inp) {