From 1109222d2bc059cc502118c875f1ecc10a744416 Mon Sep 17 00:00:00 2001 From: Demur Rumed Date: Tue, 15 Apr 2025 20:50:37 +0000 Subject: [PATCH 1/6] wip --- soh/soh/Enhancements/controls/SohInputEditorWindow.cpp | 5 +++++ soh/soh/OTRGlobals.cpp | 1 + soh/soh/OTRGlobals.h | 1 + 3 files changed, 7 insertions(+) diff --git a/soh/soh/Enhancements/controls/SohInputEditorWindow.cpp b/soh/soh/Enhancements/controls/SohInputEditorWindow.cpp index 3f77d1ed4..341fc6255 100644 --- a/soh/soh/Enhancements/controls/SohInputEditorWindow.cpp +++ b/soh/soh/Enhancements/controls/SohInputEditorWindow.cpp @@ -1584,6 +1584,10 @@ void SohInputEditorWindow::DrawLinkTab() { DrawStickSection(portIndex, Ship::RIGHT, 1, CHIP_COLOR_N64_YELLOW); } + if (ImGui::CollapsingHeader("A11y")) { + + } + if (ImGui::CollapsingHeader("Rumble")) { DrawRumbleSection(portIndex); } @@ -1597,6 +1601,7 @@ void SohInputEditorWindow::DrawLinkTab() { } if (ImGui::CollapsingHeader("Modifier Buttons")) { + DrawButtonLine("QV", portIndex, BTN_CUSTOM_QUERYVIEW); DrawButtonLine("M1", portIndex, BTN_CUSTOM_MODIFIER1); DrawButtonLine("M2", portIndex, BTN_CUSTOM_MODIFIER2); diff --git a/soh/soh/OTRGlobals.cpp b/soh/soh/OTRGlobals.cpp index 87cb361e1..6eeee2126 100644 --- a/soh/soh/OTRGlobals.cpp +++ b/soh/soh/OTRGlobals.cpp @@ -314,6 +314,7 @@ OTRGlobals::OTRGlobals() { context->GetResourceManager()->SetAltAssetsEnabled(prevAltAssets); auto controlDeck = std::make_shared(std::vector({ + BTN_CUSTOM_QUERYVIEW, BTN_CUSTOM_MODIFIER1, BTN_CUSTOM_MODIFIER2, BTN_CUSTOM_OCARINA_NOTE_D4, diff --git a/soh/soh/OTRGlobals.h b/soh/soh/OTRGlobals.h index 6f83d78ad..96ba7b612 100644 --- a/soh/soh/OTRGlobals.h +++ b/soh/soh/OTRGlobals.h @@ -3,6 +3,7 @@ #pragma once +#define BTN_CUSTOM_QUERYVIEW 0x0020 #define BTN_CUSTOM_MODIFIER1 0x0040 #define BTN_CUSTOM_MODIFIER2 0x0080 From f48647986be9843bb7bb913909cdb8141d7dc8dd Mon Sep 17 00:00:00 2001 From: Demur Rumed Date: Wed, 16 Apr 2025 00:13:41 +0000 Subject: [PATCH 2/6] BTN_CUSTOM_QUERYVIEW --- .../controls/SohInputEditorWindow.cpp | 4 --- soh/soh/Enhancements/tts/tts.cpp | 34 ++++++++++++++++++- soh/soh/OTRGlobals.cpp | 2 -- 3 files changed, 33 insertions(+), 7 deletions(-) diff --git a/soh/soh/Enhancements/controls/SohInputEditorWindow.cpp b/soh/soh/Enhancements/controls/SohInputEditorWindow.cpp index 341fc6255..f6b44ceac 100644 --- a/soh/soh/Enhancements/controls/SohInputEditorWindow.cpp +++ b/soh/soh/Enhancements/controls/SohInputEditorWindow.cpp @@ -1584,10 +1584,6 @@ void SohInputEditorWindow::DrawLinkTab() { DrawStickSection(portIndex, Ship::RIGHT, 1, CHIP_COLOR_N64_YELLOW); } - if (ImGui::CollapsingHeader("A11y")) { - - } - if (ImGui::CollapsingHeader("Rumble")) { DrawRumbleSection(portIndex); } diff --git a/soh/soh/Enhancements/tts/tts.cpp b/soh/soh/Enhancements/tts/tts.cpp index b8a43453f..bbfbf91ca 100644 --- a/soh/soh/Enhancements/tts/tts.cpp +++ b/soh/soh/Enhancements/tts/tts.cpp @@ -1,6 +1,5 @@ #include "soh/Enhancements/game-interactor/GameInteractor.h" #include "soh/Enhancements/speechsynthesizer/SpeechSynthesizer.h" - #include #include #include @@ -11,6 +10,8 @@ #include "soh/OTRGlobals.h" #include "message_data_static.h" #include "overlays/gamestates/ovl_file_choose/file_choose.h" +#include "overlays/actors/ovl_En_Elf/z_en_elf.h" +#include "soh/ActorDB.h" #include "soh/Enhancements/boss-rush/BossRush.h" #include "soh/resource/type/SohResourceType.h" @@ -176,6 +177,37 @@ void RegisterOnInterfaceUpdateHook() { if (!GameInteractor::IsSaveLoaded(true)) return; + if (CHECK_BTN_ALL(gPlayState->state.input->press.button, BTN_CUSTOM_QUERYVIEW)) { + int minDist = 1000000; + Actor* readOut = NULL; + Player* player = GET_PLAYER(gPlayState); + if (player != NULL) { + for (int i = 0; i < ACTORCAT_MAX; i++) { + if (i == ACTORCAT_PLAYER) + continue; + for (Actor* actor = gPlayState->actorCtx.actorLists[i].head; actor != NULL; actor = actor->next) { + if (actor->id == ACTOR_EN_ELF && actor->params == FAIRY_NAVI) + continue; + u16 reverseYaw = (actor->yawTowardsPlayer + 0x8000) - player->actor.world.rot.y; + if ((reverseYaw < 0x2000 || reverseYaw > 0xE000) && actor->xyzDistToPlayerSq < minDist) { + readOut = actor; + minDist = actor->xyzDistToPlayerSq; + } + } + } + if (readOut != NULL) { + auto entry = ActorDB::Instance->RetrieveEntry(readOut->id); + if (entry.name.empty()) { + char ttsAnnounceBuf[8]; + int annouceBuf = snprintf(ttsAnnounceBuf, sizeof(ttsAnnounceBuf), "%d", readOut->id); + SpeechSynthesizer::Instance->Speak(ttsAnnounceBuf, "en-US"); + } else { + SpeechSynthesizer::Instance->Speak(entry.name.c_str(), "en-US"); + } + } + } + } + static int16_t lostHealth = 0; static int16_t prevHealth = 0; diff --git a/soh/soh/OTRGlobals.cpp b/soh/soh/OTRGlobals.cpp index 6eeee2126..5bdfa6431 100644 --- a/soh/soh/OTRGlobals.cpp +++ b/soh/soh/OTRGlobals.cpp @@ -1421,13 +1421,11 @@ extern "C" void Graph_StartFrame() { break; } -#if defined(_WIN32) || defined(__APPLE__) case KbScancode::LUS_KB_F9: { // Toggle TTS CVarSetInteger(CVAR_SETTING("A11yTTS"), !CVarGetInteger(CVAR_SETTING("A11yTTS"), 0)); break; } -#endif case KbScancode::LUS_KB_TAB: { CVarSetInteger(CVAR_SETTING("AltAssets"), !CVarGetInteger(CVAR_SETTING("AltAssets"), 0)); break; From 2e25f846bc86687718410b84c6f1db390a422972 Mon Sep 17 00:00:00 2001 From: Demur Rumed Date: Wed, 16 Apr 2025 03:19:00 +0000 Subject: [PATCH 3/6] alias controls on M1/M2 for now --- .../Enhancements/controls/SohInputEditorWindow.cpp | 1 - soh/soh/Enhancements/tts/tts.cpp | 12 +++++++++++- soh/soh/OTRGlobals.cpp | 1 - soh/soh/OTRGlobals.h | 1 - 4 files changed, 11 insertions(+), 4 deletions(-) diff --git a/soh/soh/Enhancements/controls/SohInputEditorWindow.cpp b/soh/soh/Enhancements/controls/SohInputEditorWindow.cpp index f6b44ceac..3f77d1ed4 100644 --- a/soh/soh/Enhancements/controls/SohInputEditorWindow.cpp +++ b/soh/soh/Enhancements/controls/SohInputEditorWindow.cpp @@ -1597,7 +1597,6 @@ void SohInputEditorWindow::DrawLinkTab() { } if (ImGui::CollapsingHeader("Modifier Buttons")) { - DrawButtonLine("QV", portIndex, BTN_CUSTOM_QUERYVIEW); DrawButtonLine("M1", portIndex, BTN_CUSTOM_MODIFIER1); DrawButtonLine("M2", portIndex, BTN_CUSTOM_MODIFIER2); diff --git a/soh/soh/Enhancements/tts/tts.cpp b/soh/soh/Enhancements/tts/tts.cpp index bbfbf91ca..54e3aa079 100644 --- a/soh/soh/Enhancements/tts/tts.cpp +++ b/soh/soh/Enhancements/tts/tts.cpp @@ -177,7 +177,17 @@ void RegisterOnInterfaceUpdateHook() { if (!GameInteractor::IsSaveLoaded(true)) return; - if (CHECK_BTN_ALL(gPlayState->state.input->press.button, BTN_CUSTOM_QUERYVIEW)) { + if (CHECK_BTN_ALL(gPlayState->state.input->press.button, BTN_CUSTOM_MODIFIER1)) { + Player* player = GET_PLAYER(gPlayState); + if (player != NULL) { + char ttsAnnounceBuf[16]; + int angle = (int)(player->actor.world.rot.y / (65536 / 360.0)); + int annouceBuf = snprintf(ttsAnnounceBuf, sizeof(ttsAnnounceBuf), "facing %d", angle); + SpeechSynthesizer::Instance->Speak(ttsAnnounceBuf, "en-US"); + } + } + + if (CHECK_BTN_ALL(gPlayState->state.input->press.button, BTN_CUSTOM_MODIFIER2)) { int minDist = 1000000; Actor* readOut = NULL; Player* player = GET_PLAYER(gPlayState); diff --git a/soh/soh/OTRGlobals.cpp b/soh/soh/OTRGlobals.cpp index 5bdfa6431..ad4e2be7a 100644 --- a/soh/soh/OTRGlobals.cpp +++ b/soh/soh/OTRGlobals.cpp @@ -314,7 +314,6 @@ OTRGlobals::OTRGlobals() { context->GetResourceManager()->SetAltAssetsEnabled(prevAltAssets); auto controlDeck = std::make_shared(std::vector({ - BTN_CUSTOM_QUERYVIEW, BTN_CUSTOM_MODIFIER1, BTN_CUSTOM_MODIFIER2, BTN_CUSTOM_OCARINA_NOTE_D4, diff --git a/soh/soh/OTRGlobals.h b/soh/soh/OTRGlobals.h index 96ba7b612..6f83d78ad 100644 --- a/soh/soh/OTRGlobals.h +++ b/soh/soh/OTRGlobals.h @@ -3,7 +3,6 @@ #pragma once -#define BTN_CUSTOM_QUERYVIEW 0x0020 #define BTN_CUSTOM_MODIFIER1 0x0040 #define BTN_CUSTOM_MODIFIER2 0x0080 From 2a3714cd9beda5a2cc4bc0b0476fa78a883d5b5c Mon Sep 17 00:00:00 2001 From: Demur Rumed Date: Thu, 17 Apr 2025 01:19:09 +0000 Subject: [PATCH 4/6] change direction from degrees to 8-way cardinal names --- soh/soh/Enhancements/tts/tts.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/soh/soh/Enhancements/tts/tts.cpp b/soh/soh/Enhancements/tts/tts.cpp index 54e3aa079..a7579e586 100644 --- a/soh/soh/Enhancements/tts/tts.cpp +++ b/soh/soh/Enhancements/tts/tts.cpp @@ -180,10 +180,16 @@ void RegisterOnInterfaceUpdateHook() { if (CHECK_BTN_ALL(gPlayState->state.input->press.button, BTN_CUSTOM_MODIFIER1)) { Player* player = GET_PLAYER(gPlayState); if (player != NULL) { - char ttsAnnounceBuf[16]; - int angle = (int)(player->actor.world.rot.y / (65536 / 360.0)); - int annouceBuf = snprintf(ttsAnnounceBuf, sizeof(ttsAnnounceBuf), "facing %d", angle); - SpeechSynthesizer::Instance->Speak(ttsAnnounceBuf, "en-US"); + u16 angle = (u16)player->actor.world.rot.y; + const char* ttsAnnounce = (angle > 0xf000 || angle < 0x1000) ? "south" + : angle < 0x3000 ? "southeast" + : angle < 0x5000 ? "east" + : angle < 0x7000 ? "northeast" + : angle < 0x9000 ? "north" + : angle < 0xB000 ? "northwest" + : angle < 0xD000 ? "west" + : "southwest"; + SpeechSynthesizer::Instance->Speak(ttsAnnounce, "en-US"); } } From 1a96696139620f0f1584dae76b8fd10e7630e92b Mon Sep 17 00:00:00 2001 From: Demur Rumed Date: Fri, 18 Apr 2025 02:53:48 +0000 Subject: [PATCH 5/6] check for freestanding item directly below player while swimming don't detect sun actor --- soh/soh/Enhancements/tts/tts.cpp | 31 ++++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/soh/soh/Enhancements/tts/tts.cpp b/soh/soh/Enhancements/tts/tts.cpp index a7579e586..4561653ef 100644 --- a/soh/soh/Enhancements/tts/tts.cpp +++ b/soh/soh/Enhancements/tts/tts.cpp @@ -198,16 +198,28 @@ void RegisterOnInterfaceUpdateHook() { Actor* readOut = NULL; Player* player = GET_PLAYER(gPlayState); if (player != NULL) { - for (int i = 0; i < ACTORCAT_MAX; i++) { - if (i == ACTORCAT_PLAYER) - continue; - for (Actor* actor = gPlayState->actorCtx.actorLists[i].head; actor != NULL; actor = actor->next) { - if (actor->id == ACTOR_EN_ELF && actor->params == FAIRY_NAVI) + if (player->focusActor != NULL) { + readOut = player->focusActor; + } else { + for (int i = 0; i < ACTORCAT_MAX; i++) { + if (i == ACTORCAT_PLAYER) continue; - u16 reverseYaw = (actor->yawTowardsPlayer + 0x8000) - player->actor.world.rot.y; - if ((reverseYaw < 0x2000 || reverseYaw > 0xE000) && actor->xyzDistToPlayerSq < minDist) { - readOut = actor; - minDist = actor->xyzDistToPlayerSq; + for (Actor* actor = gPlayState->actorCtx.actorLists[i].head; actor != NULL; + actor = actor->next) { + if ((actor->id == ACTOR_EN_ELF && actor->params == FAIRY_NAVI) || + actor->id == ACTOR_SHOT_SUN) + continue; + if (actor->id == ACTOR_EN_ITEM00 && (player->stateFlags1 & PLAYER_STATE1_IN_WATER) && + player->currentBoots != PLAYER_BOOTS_IRON && actor->xzDistToPlayer < 40 && + actor->world.pos.z < player->actor.world.pos.z) { + SpeechSynthesizer::Instance->Speak("item below", "en-US"); + goto spoke; + } + u16 reverseYaw = (actor->yawTowardsPlayer + 0x8000) - player->actor.world.rot.y; + if ((reverseYaw < 0x2000 || reverseYaw > 0xE000) && actor->xyzDistToPlayerSq < minDist) { + readOut = actor; + minDist = actor->xyzDistToPlayerSq; + } } } } @@ -223,6 +235,7 @@ void RegisterOnInterfaceUpdateHook() { } } } + spoke: static int16_t lostHealth = 0; static int16_t prevHealth = 0; From 27cb1b54202535e7b22610a449639eaf592f07da Mon Sep 17 00:00:00 2001 From: Demur Rumed Date: Fri, 18 Apr 2025 21:22:59 +0000 Subject: [PATCH 6/6] also detect underwater switch --- soh/soh/Enhancements/tts/tts.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/soh/soh/Enhancements/tts/tts.cpp b/soh/soh/Enhancements/tts/tts.cpp index 4561653ef..834402830 100644 --- a/soh/soh/Enhancements/tts/tts.cpp +++ b/soh/soh/Enhancements/tts/tts.cpp @@ -209,11 +209,16 @@ void RegisterOnInterfaceUpdateHook() { if ((actor->id == ACTOR_EN_ELF && actor->params == FAIRY_NAVI) || actor->id == ACTOR_SHOT_SUN) continue; - if (actor->id == ACTOR_EN_ITEM00 && (player->stateFlags1 & PLAYER_STATE1_IN_WATER) && - player->currentBoots != PLAYER_BOOTS_IRON && actor->xzDistToPlayer < 40 && + if (actor->xzDistToPlayer < 40 && (player->stateFlags1 & PLAYER_STATE1_IN_WATER) && + player->currentBoots != PLAYER_BOOTS_IRON && actor->world.pos.z < player->actor.world.pos.z) { - SpeechSynthesizer::Instance->Speak("item below", "en-US"); - goto spoke; + if (actor->id == ACTOR_EN_ITEM00) { + SpeechSynthesizer::Instance->Speak("item below", "en-US"); + goto spoke; + } else if (actor->id == ACTOR_OBJ_SWITCH) { + SpeechSynthesizer::Instance->Speak("switch below", "en-US"); + goto spoke; + } } u16 reverseYaw = (actor->yawTowardsPlayer + 0x8000) - player->actor.world.rot.y; if ((reverseYaw < 0x2000 || reverseYaw > 0xE000) && actor->xyzDistToPlayerSq < minDist) {