diff --git a/libultraship/libultraship/GameSettings.cpp b/libultraship/libultraship/GameSettings.cpp index 1186fa27c..8cef8be74 100644 --- a/libultraship/libultraship/GameSettings.cpp +++ b/libultraship/libultraship/GameSettings.cpp @@ -89,6 +89,9 @@ namespace Game { Settings.controller.input_enabled = stob(Conf[ControllerSection]["input_enabled"]); CVar_SetS32(const_cast("gInputEnabled"), Settings.controller.input_enabled); + + Settings.controller.dpad_shop = stob(Conf[ControllerSection]["dpad_shop"]); + CVar_SetS32(const_cast("gDpadShop"), Settings.controller.dpad_shop); // Cheats Settings.cheats.debug_mode = stob(Conf[CheatSection]["debug_mode"]); @@ -149,6 +152,7 @@ namespace Game { 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_enabled"] = std::to_string(Settings.controller.input_enabled); + Conf[ControllerSection]["dpad_shop"] = std::to_string(Settings.controller.dpad_shop); // Cheats Conf[CheatSection]["debug_mode"] = std::to_string(Settings.cheats.debug_mode); diff --git a/libultraship/libultraship/GameSettings.h b/libultraship/libultraship/GameSettings.h index 4f9bb4c99..8f7783fad 100644 --- a/libultraship/libultraship/GameSettings.h +++ b/libultraship/libultraship/GameSettings.h @@ -34,6 +34,7 @@ struct SoHConfigType { float gyroDriftX = 0.0f; float gyroDriftY = 0.0f; bool input_enabled = false; + bool dpad_shop = false; } controller; // Cheats diff --git a/libultraship/libultraship/SohImGuiImpl.cpp b/libultraship/libultraship/SohImGuiImpl.cpp index d95a27d08..bede4a602 100644 --- a/libultraship/libultraship/SohImGuiImpl.cpp +++ b/libultraship/libultraship/SohImGuiImpl.cpp @@ -328,6 +328,11 @@ namespace SohImGui { needs_save = true; } + if (ImGui::Checkbox("DPad Support for Browsing Shop Items", &Game::Settings.controller.dpad_shop)) { + CVar_SetS32(const_cast("gDpadShop"), Game::Settings.controller.dpad_shop); + needs_save = true; + } + ImGui::EndMenu(); } diff --git a/soh/src/overlays/actors/ovl_En_Ossan/z_en_ossan.c b/soh/src/overlays/actors/ovl_En_Ossan/z_en_ossan.c index f4e2a19d7..4d5fefec6 100644 --- a/soh/src/overlays/actors/ovl_En_Ossan/z_en_ossan.c +++ b/soh/src/overlays/actors/ovl_En_Ossan/z_en_ossan.c @@ -950,6 +950,7 @@ s32 EnOssan_FacingShopkeeperDialogResult(EnOssan* this, GlobalContext* globalCtx void EnOssan_State_FacingShopkeeper(EnOssan* this, GlobalContext* globalCtx, Player* player) { Input* input = &globalCtx->state.input[0]; u8 nextIndex; + bool dpad = CVar_GetS32("gDpadShop", 0); if ((Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_CHOICE) && !EnOssan_TestEndInteraction(this, globalCtx, &globalCtx->state.input[0])) { @@ -958,7 +959,7 @@ void EnOssan_State_FacingShopkeeper(EnOssan* this, GlobalContext* globalCtx, Pla return; } // Stick Left - if ((this->stickAccumX < 0) || CHECK_BTN_ALL(input->press.button, BTN_DLEFT)) { + if ((this->stickAccumX < 0) || (dpad && CHECK_BTN_ALL(input->press.button, BTN_DLEFT))) { nextIndex = EnOssan_SetCursorIndexFromNeutral(this, 4); if (nextIndex != CURSOR_INVALID) { this->cursorIndex = nextIndex; @@ -967,7 +968,7 @@ void EnOssan_State_FacingShopkeeper(EnOssan* this, GlobalContext* globalCtx, Pla this->stickLeftPrompt.isEnabled = false; func_80078884(NA_SE_SY_CURSOR); } - } else if ((this->stickAccumX > 0) || CHECK_BTN_ALL(input->press.button, BTN_DRIGHT)) { + } else if ((this->stickAccumX > 0) || (dpad && CHECK_BTN_ALL(input->press.button, BTN_DRIGHT))) { nextIndex = EnOssan_SetCursorIndexFromNeutral(this, 0); if (nextIndex != CURSOR_INVALID) { this->cursorIndex = nextIndex; @@ -1028,8 +1029,9 @@ void EnOssan_CursorUpDown(EnOssan* this, GlobalContext* globalCtx) { Input* input = &globalCtx->state.input[0]; u8 curTemp = this->cursorIndex; u8 curScanTemp; + bool dpad = CVar_GetS32("gDpadShop", 0); - if ((this->stickAccumY < 0) || CHECK_BTN_ALL(input->press.button, BTN_DDOWN)) { + if ((this->stickAccumY < 0) || (dpad && CHECK_BTN_ALL(input->press.button, BTN_DDOWN))) { curTemp &= 0xFE; if (this->shelfSlots[curTemp] != NULL) { this->cursorIndex = curTemp; @@ -1068,7 +1070,7 @@ void EnOssan_CursorUpDown(EnOssan* this, GlobalContext* globalCtx) { } } } - } else if ((this->stickAccumY > 0) || CHECK_BTN_ALL(input->press.button, BTN_DUP)) { + } else if ((this->stickAccumY > 0) || (dpad && CHECK_BTN_ALL(input->press.button, BTN_DUP))) { curTemp |= 1; if (this->shelfSlots[curTemp] != NULL) { this->cursorIndex = curTemp; @@ -1180,6 +1182,7 @@ void EnOssan_State_BrowseLeftShelf(EnOssan* this, GlobalContext* globalCtx, Play u8 prevIndex = this->cursorIndex; s32 c; s32 d; + bool dpad = CVar_GetS32("gDpadShop", 0); if (!EnOssan_ReturnItemToShelf(this)) { osSyncPrintf("%s[%d]:" VT_FGCOL(GREEN) "ズーム中!!" VT_RST "\n", "../z_en_oB1.c", 2152); @@ -1196,7 +1199,7 @@ void EnOssan_State_BrowseLeftShelf(EnOssan* this, GlobalContext* globalCtx, Play if ((Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_EVENT) && !EnOssan_HasPlayerSelectedItem(globalCtx, this, &globalCtx->state.input[0])) { if (this->moveHorizontal) { - if ((this->stickAccumX > 0) || CHECK_BTN_ALL(input->press.button, BTN_DRIGHT)) { + if ((this->stickAccumX > 0) || (dpad && CHECK_BTN_ALL(input->press.button, BTN_DRIGHT))) { a = EnOssan_CursorRight(this, this->cursorIndex, 4); if (a != CURSOR_INVALID) { this->cursorIndex = a; @@ -1204,14 +1207,14 @@ void EnOssan_State_BrowseLeftShelf(EnOssan* this, GlobalContext* globalCtx, Play EnOssan_SetLookToShopkeeperFromShelf(globalCtx, this); return; } - } else if ((this->stickAccumX < 0) || CHECK_BTN_ALL(input->press.button, BTN_DLEFT)) { + } else if ((this->stickAccumX < 0) || (dpad && CHECK_BTN_ALL(input->press.button, BTN_DLEFT))) { b = EnOssan_CursorLeft(this, this->cursorIndex, 8); if (b != CURSOR_INVALID) { this->cursorIndex = b; } } } else { - if ((this->stickAccumX > 0 && this->stickAccumX > 500) || CHECK_BTN_ALL(input->press.button, BTN_DRIGHT)) { + if ((this->stickAccumX > 0 && this->stickAccumX > 500) || (dpad && CHECK_BTN_ALL(input->press.button, BTN_DRIGHT))) { c = EnOssan_CursorRight(this, this->cursorIndex, 4); if (c != CURSOR_INVALID) { this->cursorIndex = c; @@ -1219,7 +1222,7 @@ void EnOssan_State_BrowseLeftShelf(EnOssan* this, GlobalContext* globalCtx, Play EnOssan_SetLookToShopkeeperFromShelf(globalCtx, this); return; } - } else if ((this->stickAccumX < 0 && this->stickAccumX < -500) || CHECK_BTN_ALL(input->press.button, BTN_DLEFT)) { + } else if ((this->stickAccumX < 0 && this->stickAccumX < -500) || (dpad && CHECK_BTN_ALL(input->press.button, BTN_DLEFT))) { d = EnOssan_CursorLeft(this, this->cursorIndex, 8); if (d != CURSOR_INVALID) { this->cursorIndex = d; @@ -1239,6 +1242,7 @@ void EnOssan_State_BrowseRightShelf(EnOssan* this, GlobalContext* globalCtx, Pla s32 pad[2]; u8 prevIndex; u8 nextIndex; + bool dpad = CVar_GetS32("gDpadShop", 0); prevIndex = this->cursorIndex; if (!EnOssan_ReturnItemToShelf(this)) { @@ -1256,7 +1260,7 @@ void EnOssan_State_BrowseRightShelf(EnOssan* this, GlobalContext* globalCtx, Pla if ((Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_EVENT) && !EnOssan_HasPlayerSelectedItem(globalCtx, this, &globalCtx->state.input[0])) { if (this->moveHorizontal) { - if ((this->stickAccumX < 0) || CHECK_BTN_ALL(input->press.button, BTN_DLEFT)) { + if ((this->stickAccumX < 0) || (dpad && CHECK_BTN_ALL(input->press.button, BTN_DLEFT))) { nextIndex = EnOssan_CursorRight(this, this->cursorIndex, 0); if (nextIndex != CURSOR_INVALID) { this->cursorIndex = nextIndex; @@ -1264,14 +1268,14 @@ void EnOssan_State_BrowseRightShelf(EnOssan* this, GlobalContext* globalCtx, Pla EnOssan_SetLookToShopkeeperFromShelf(globalCtx, this); return; } - } else if ((this->stickAccumX > 0) || CHECK_BTN_ALL(input->press.button, BTN_DRIGHT)) { + } else if ((this->stickAccumX > 0) || (dpad && CHECK_BTN_ALL(input->press.button, BTN_DRIGHT))) { nextIndex = EnOssan_CursorLeft(this, this->cursorIndex, 4); if (nextIndex != CURSOR_INVALID) { this->cursorIndex = nextIndex; } } } else { - if ((this->stickAccumX < 0 && this->stickAccumX < -500) || CHECK_BTN_ALL(input->press.button, BTN_DLEFT)) { + if ((this->stickAccumX < 0 && this->stickAccumX < -500) || (dpad && CHECK_BTN_ALL(input->press.button, BTN_DLEFT))) { nextIndex = EnOssan_CursorRight(this, this->cursorIndex, 0); if (nextIndex != CURSOR_INVALID) { this->cursorIndex = nextIndex; @@ -1279,7 +1283,7 @@ void EnOssan_State_BrowseRightShelf(EnOssan* this, GlobalContext* globalCtx, Pla EnOssan_SetLookToShopkeeperFromShelf(globalCtx, this); return; } - } else if ((this->stickAccumX > 0 && this->stickAccumX > 500) || CHECK_BTN_ALL(input->press.button, BTN_DRIGHT)) { + } else if ((this->stickAccumX > 0 && this->stickAccumX > 500) || (dpad && CHECK_BTN_ALL(input->press.button, BTN_DRIGHT))) { nextIndex = EnOssan_CursorLeft(this, this->cursorIndex, 4); if (nextIndex != CURSOR_INVALID) { this->cursorIndex = nextIndex;