From bc3b671e3419e3ca4a16600c3f8d5a404ee01520 Mon Sep 17 00:00:00 2001 From: Giorgio Mendieta <31053658+GiorgioMendieta@users.noreply.github.com> Date: Mon, 18 May 2026 22:42:55 +0200 Subject: [PATCH 1/9] feat: Add texture replacement action binding option --- include/dusk/action_bindings.h | 1 + include/dusk/settings.h | 1 + src/dusk/action_bindings.cpp | 1 + src/dusk/settings.cpp | 10 ++++++++++ 4 files changed, 13 insertions(+) diff --git a/include/dusk/action_bindings.h b/include/dusk/action_bindings.h index 7eba412fe8..b2675faa24 100644 --- a/include/dusk/action_bindings.h +++ b/include/dusk/action_bindings.h @@ -11,6 +11,7 @@ enum class ActionBinds { CALL_MIDNA, OPEN_DUSKLIGHT_MENU, TURBO_SPEED_BUTTON, + TOGGLE_TEXTURE_PACK, COUNT, }; diff --git a/include/dusk/settings.h b/include/dusk/settings.h index 923a1e9fc6..948c909fad 100644 --- a/include/dusk/settings.h +++ b/include/dusk/settings.h @@ -263,6 +263,7 @@ struct UserSettings { std::array callMidna; std::array openDusklightMenu; std::array turboSpeedButton; + std::array toggleTexturePack; } actionBindings; }; diff --git a/src/dusk/action_bindings.cpp b/src/dusk/action_bindings.cpp index 204f219558..f8cf3c8f68 100644 --- a/src/dusk/action_bindings.cpp +++ b/src/dusk/action_bindings.cpp @@ -14,6 +14,7 @@ ActionBindsMap& getActionBinds() { {ActionBinds::CALL_MIDNA, {&getSettings().actionBindings.callMidna, "Call Midna"}}, {ActionBinds::OPEN_DUSKLIGHT_MENU, {&getSettings().actionBindings.openDusklightMenu, "Open Dusklight Menu"}}, {ActionBinds::TURBO_SPEED_BUTTON, {&getSettings().actionBindings.turboSpeedButton, "Turbo Speed Button"}}, + {ActionBinds::TOGGLE_TEXTURE_PACK, {&getSettings().actionBindings.toggleTexturePack, "Toggle Texture Pack"}}, }; return actionBinds; } diff --git a/src/dusk/settings.cpp b/src/dusk/settings.cpp index ef639e2b05..ab7a58f810 100644 --- a/src/dusk/settings.cpp +++ b/src/dusk/settings.cpp @@ -171,6 +171,12 @@ UserSettings g_userSettings = { ActionBindConfigVar{"actionBindings.turboButton_port2", PAD_NATIVE_BUTTON_INVALID}, ActionBindConfigVar{"actionBindings.turboButton_port3", PAD_NATIVE_BUTTON_INVALID}, }, + .toggleTexturePack { + ActionBindConfigVar{"actionBindings.toggleTexturePack_port0", PAD_NATIVE_BUTTON_INVALID}, + ActionBindConfigVar{"actionBindings.toggleTexturePack_port1", PAD_NATIVE_BUTTON_INVALID}, + ActionBindConfigVar{"actionBindings.toggleTexturePack_port2", PAD_NATIVE_BUTTON_INVALID}, + ActionBindConfigVar{"actionBindings.toggleTexturePack_port3", PAD_NATIVE_BUTTON_INVALID}, + }, } }; @@ -313,6 +319,10 @@ void registerSettings() { Register(g_userSettings.actionBindings.turboSpeedButton[1]); Register(g_userSettings.actionBindings.turboSpeedButton[2]); Register(g_userSettings.actionBindings.turboSpeedButton[3]); + Register(g_userSettings.actionBindings.toggleTexturePack[0]); + Register(g_userSettings.actionBindings.toggleTexturePack[1]); + Register(g_userSettings.actionBindings.toggleTexturePack[2]); + Register(g_userSettings.actionBindings.toggleTexturePack[3]); } // Transient settings From 55496c444ca3c7bfb85add93c3d8312effef9d70 Mon Sep 17 00:00:00 2001 From: Giorgio Mendieta <31053658+GiorgioMendieta@users.noreply.github.com> Date: Mon, 18 May 2026 23:07:19 +0200 Subject: [PATCH 2/9] feat: Implement texture replacement action binding logic --- src/dusk/action_bindings.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/dusk/action_bindings.cpp b/src/dusk/action_bindings.cpp index f8cf3c8f68..9c7b6233c5 100644 --- a/src/dusk/action_bindings.cpp +++ b/src/dusk/action_bindings.cpp @@ -1,6 +1,8 @@ #include "dusk/action_bindings.h" +#include "aurora/gfx.h" #include "aurora/lib/input.hpp" +#include "dusk/config.hpp" #include "dusk/settings.h" #include "dusk/ui/ui.hpp" @@ -8,6 +10,8 @@ namespace dusk { static std::array(ActionBinds::COUNT)>, PAD_CHANMAX> actionPressData{}; +static void handleActionTriggers(); + ActionBindsMap& getActionBinds() { static ActionBindsMap actionBinds = { {ActionBinds::FIRST_PERSON_CAMERA, {&getSettings().actionBindings.firstPersonCamera, "First Person Camera"}}, @@ -68,6 +72,8 @@ void updateActionBindings() { } } } + + handleActionTriggers(); } bool getActionBindTrig(ActionBinds action, u32 port) { @@ -91,6 +97,20 @@ bool getActionBindHoldAnyPort(ActionBinds action) { return false; } +static void handleActionTriggers() { + for (u32 port = 0; port < PAD_CHANMAX; ++port) { + if (!getActionBindTrig(ActionBinds::TOGGLE_TEXTURE_PACK, port)) { + continue; + } + + const bool enabled = !getSettings().game.enableTextureReplacements.getValue(); + getSettings().game.enableTextureReplacements.setValue(enabled); + aurora_set_texture_replacements_enabled(enabled); + config::Save(); + break; + } +} + int getActionBindButton(ActionBinds action, u32 port) { return (*getActionBinds()[action].configVars)[port]; } From 5a67e831934477f45209659602357a568a9a6ae6 Mon Sep 17 00:00:00 2001 From: Giorgio Mendieta <31053658+GiorgioMendieta@users.noreply.github.com> Date: Fri, 22 May 2026 19:21:22 +0200 Subject: [PATCH 3/9] fix: simplify action trigger handling --- src/dusk/action_bindings.cpp | 27 +++++++++------------------ 1 file changed, 9 insertions(+), 18 deletions(-) diff --git a/src/dusk/action_bindings.cpp b/src/dusk/action_bindings.cpp index 9c7b6233c5..d92d46ed13 100644 --- a/src/dusk/action_bindings.cpp +++ b/src/dusk/action_bindings.cpp @@ -10,8 +10,6 @@ namespace dusk { static std::array(ActionBinds::COUNT)>, PAD_CHANMAX> actionPressData{}; -static void handleActionTriggers(); - ActionBindsMap& getActionBinds() { static ActionBindsMap actionBinds = { {ActionBinds::FIRST_PERSON_CAMERA, {&getSettings().actionBindings.firstPersonCamera, "First Person Camera"}}, @@ -70,10 +68,17 @@ void updateActionBindings() { } } } + + // Handle action triggers + if (getActionBindTrig(ActionBinds::TOGGLE_TEXTURE_PACK, port)) { + const bool enabled = !getSettings().game.enableTextureReplacements.getValue(); + getSettings().game.enableTextureReplacements.setValue(enabled); + aurora_set_texture_replacements_enabled(enabled); + config::Save(); + break; + } } } - - handleActionTriggers(); } bool getActionBindTrig(ActionBinds action, u32 port) { @@ -97,20 +102,6 @@ bool getActionBindHoldAnyPort(ActionBinds action) { return false; } -static void handleActionTriggers() { - for (u32 port = 0; port < PAD_CHANMAX; ++port) { - if (!getActionBindTrig(ActionBinds::TOGGLE_TEXTURE_PACK, port)) { - continue; - } - - const bool enabled = !getSettings().game.enableTextureReplacements.getValue(); - getSettings().game.enableTextureReplacements.setValue(enabled); - aurora_set_texture_replacements_enabled(enabled); - config::Save(); - break; - } -} - int getActionBindButton(ActionBinds action, u32 port) { return (*getActionBinds()[action].configVars)[port]; } From 6b6f3f3ac0a8b4eab9dd17cb67526ea808756f6d Mon Sep 17 00:00:00 2001 From: Giorgio Mendieta <31053658+GiorgioMendieta@users.noreply.github.com> Date: Fri, 22 May 2026 19:58:05 +0200 Subject: [PATCH 4/9] feat: separate logic between gameplay and interface action bindings --- include/dusk/action_bindings.h | 4 +- src/dusk/action_bindings.cpp | 61 +++++++++++++++++++++++++++---- src/dusk/config.cpp | 2 +- src/dusk/ui/controller_config.cpp | 25 ++++++++++--- 4 files changed, 78 insertions(+), 14 deletions(-) diff --git a/include/dusk/action_bindings.h b/include/dusk/action_bindings.h index b2675faa24..5d18950c11 100644 --- a/include/dusk/action_bindings.h +++ b/include/dusk/action_bindings.h @@ -27,7 +27,9 @@ struct ActionBindPressData { using ActionBindsMap = std::unordered_map; -ActionBindsMap& getActionBinds(); +ActionBindsMap& getActionBindsGameplay(); + +ActionBindsMap& getActionBindsInterface(); bool isActionBound(ActionBinds action, u32 port); diff --git a/src/dusk/action_bindings.cpp b/src/dusk/action_bindings.cpp index d92d46ed13..294747f9f1 100644 --- a/src/dusk/action_bindings.cpp +++ b/src/dusk/action_bindings.cpp @@ -10,21 +10,30 @@ namespace dusk { static std::array(ActionBinds::COUNT)>, PAD_CHANMAX> actionPressData{}; -ActionBindsMap& getActionBinds() { +// Action Bindings that affect gameplay +ActionBindsMap& getActionBindsGameplay() { static ActionBindsMap actionBinds = { {ActionBinds::FIRST_PERSON_CAMERA, {&getSettings().actionBindings.firstPersonCamera, "First Person Camera"}}, {ActionBinds::CALL_MIDNA, {&getSettings().actionBindings.callMidna, "Call Midna"}}, {ActionBinds::OPEN_DUSKLIGHT_MENU, {&getSettings().actionBindings.openDusklightMenu, "Open Dusklight Menu"}}, {ActionBinds::TURBO_SPEED_BUTTON, {&getSettings().actionBindings.turboSpeedButton, "Turbo Speed Button"}}, + }; + return actionBinds; +} + +// Action Bindings that affect the interface (menus, etc.) +ActionBindsMap& getActionBindsInterface() { + static ActionBindsMap actionBinds = { {ActionBinds::TOGGLE_TEXTURE_PACK, {&getSettings().actionBindings.toggleTexturePack, "Toggle Texture Pack"}}, }; return actionBinds; } bool isActionBound(ActionBinds action, u32 port) { - auto& actionBinds = getActionBinds(); + auto& actionBindsGameplay = getActionBindsGameplay(); + auto& actionBindsInterface = getActionBindsInterface(); // Check to make sure action is properly bound - if (!actionBinds.contains(action)) { + if (!actionBindsGameplay.contains(action) && !actionBindsInterface.contains(action)) { return false; } @@ -39,8 +48,8 @@ void updateActionBindings() { pressData.pressedCurFrame = false; } - // Update current frame with whether action button is pressed - for (auto& [action, boundAction] : getActionBinds()) { + // Update current frame with whether gameplay action button is pressed + for (auto& [action, boundAction] : getActionBindsGameplay()) { // If the action isn't bound, or if documents are visible and the action isn't // opening the dusklight menu, don't update. Otherwise, we may accidentally // perform actions while the dusklight menu is open. @@ -68,8 +77,35 @@ void updateActionBindings() { } } } + } + + // Update current frame for interface binds and handle their triggers separately + for (auto& [action, boundAction] : getActionBindsInterface()) { + // Interface binds should update regardless of UI visibility + if (!isActionBound(action, port) || + (ui::any_document_visible() && action != ActionBinds::OPEN_DUSKLIGHT_MENU)) { + continue; + } + + int button = boundAction.configVars->at(port); + + u32 count = 0; + if (PADGetKeyButtonBindings(port, &count) != nullptr) { + int numKeys = 0; + const bool* kbState = SDL_GetKeyboardState(&numKeys); + if (kbState[button]) { + actionPressData[port][static_cast(action)].pressedCurFrame = true; + } + } else { + auto controller = aurora::input::get_controller_for_player(port); + if (controller) { + if (SDL_GetGamepadButton(controller->m_controller, static_cast(button))) { + actionPressData[port][static_cast(action)].pressedCurFrame = true; + } + } + } - // Handle action triggers + // Interface-specific triggers (do not apply gameplay UI visibility gating) if (getActionBindTrig(ActionBinds::TOGGLE_TEXTURE_PACK, port)) { const bool enabled = !getSettings().game.enableTextureReplacements.getValue(); getSettings().game.enableTextureReplacements.setValue(enabled); @@ -103,6 +139,17 @@ bool getActionBindHoldAnyPort(ActionBinds action) { } int getActionBindButton(ActionBinds action, u32 port) { - return (*getActionBinds()[action].configVars)[port]; + auto& gameplayBinds = getActionBindsGameplay(); + auto& interfaceBinds = getActionBindsInterface(); + + if (gameplayBinds.contains(action)) { + return (*gameplayBinds[action].configVars)[port]; + } + + if (interfaceBinds.contains(action)) { + return (*interfaceBinds[action].configVars)[port]; + } + + return PAD_NATIVE_BUTTON_INVALID; } } diff --git a/src/dusk/config.cpp b/src/dusk/config.cpp index c0edd84591..8adac39856 100644 --- a/src/dusk/config.cpp +++ b/src/dusk/config.cpp @@ -280,7 +280,7 @@ void dusk::config::Save() { } void dusk::config::ClearAllActionBindings(int port) { - for (auto& actionBinding : getActionBinds() | std::views::values) { + for (auto& actionBinding : getActionBindsGameplay() | std::views::values) { actionBinding.configVars->at(port).setValue(PAD_NATIVE_BUTTON_INVALID); } Save(); diff --git a/src/dusk/ui/controller_config.cpp b/src/dusk/ui/controller_config.cpp index 20c599ecfd..ceb6725855 100644 --- a/src/dusk/ui/controller_config.cpp +++ b/src/dusk/ui/controller_config.cpp @@ -937,9 +937,17 @@ void ControllerConfigWindow::render_page(Pane& pane, int port, Page page) { pane.add_section("Custom Action Bindings"); pane.add_text("A key bound to any action here will REPLACE the default control for" " that action. Only bind buttons here that aren't used anywhere else."); - for (auto& [configVars, actionName] : getActionBinds() | std::views::values) { + + pane.add_section("Gameplay"); + for (auto& [configVars, actionName] : getActionBindsGameplay() | std::views::values) { addActionBinding(&configVars->at(port), actionName); } + + pane.add_section("Interface"); + for (auto& [configVars, actionName] : getActionBindsInterface() | std::views::values) { + addActionBinding(&configVars->at(port), actionName); + } + break; } @@ -953,9 +961,10 @@ void ControllerConfigWindow::render_page(Pane& pane, int port, Page page) { SDL_Gamepad* gamepad = gamepad_for_port(port); pane.add_section("Custom Action Bindings"); pane.add_text("A button bound to any action here will REPLACE the default control for" - " that action. Only bind buttons here that aren't used anywhere else. The glyphs" - " shown for in game actions will not change. This is not recommended for " - " regular Gamecube controllers."); + " that action. Only bind buttons here that aren't used anywhere else." + " Note: The glyphs shown for in game actions will not change." + " This is not recommended for regular Gamecube controllers."); + auto addActionBinding = [&](auto actionBind, const std::string& key) { pane.add_select_button({ .key = key, @@ -978,7 +987,13 @@ void ControllerConfigWindow::render_page(Pane& pane, int port, Page page) { }); }; - for (auto& [configVars, actionName] : getActionBinds() | std::views::values) { + pane.add_section("Gameplay"); + for (auto& [configVars, actionName] : getActionBindsGameplay() | std::views::values) { + addActionBinding(&configVars->at(port), actionName); + } + + pane.add_section("Interface"); + for (auto& [configVars, actionName] : getActionBindsInterface() | std::views::values) { addActionBinding(&configVars->at(port), actionName); } break; From 509624ae0a4e49406dfe5ae9054f47d7353d4f53 Mon Sep 17 00:00:00 2001 From: Giorgio Mendieta <31053658+GiorgioMendieta@users.noreply.github.com> Date: Fri, 22 May 2026 20:49:30 +0200 Subject: [PATCH 5/9] fix: add line break before note --- src/dusk/ui/controller_config.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/dusk/ui/controller_config.cpp b/src/dusk/ui/controller_config.cpp index ceb6725855..fe76ac4626 100644 --- a/src/dusk/ui/controller_config.cpp +++ b/src/dusk/ui/controller_config.cpp @@ -960,9 +960,9 @@ void ControllerConfigWindow::render_page(Pane& pane, int port, Page page) { SDL_Gamepad* gamepad = gamepad_for_port(port); pane.add_section("Custom Action Bindings"); - pane.add_text("A button bound to any action here will REPLACE the default control for" + pane.add_rml("A button bound to any action here will REPLACE the default control for" " that action. Only bind buttons here that aren't used anywhere else." - " Note: The glyphs shown for in game actions will not change." + "

Note: The glyphs shown for in game actions will not change." " This is not recommended for regular Gamecube controllers."); auto addActionBinding = [&](auto actionBind, const std::string& key) { From 0536bef52604d343289eb7f2f7a817f425c80ba8 Mon Sep 17 00:00:00 2001 From: Giorgio Mendieta <31053658+GiorgioMendieta@users.noreply.github.com> Date: Fri, 22 May 2026 21:00:44 +0200 Subject: [PATCH 6/9] fix: move "open dusklight menu" to interface action bindings --- src/dusk/action_bindings.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/dusk/action_bindings.cpp b/src/dusk/action_bindings.cpp index 294747f9f1..8f059809ff 100644 --- a/src/dusk/action_bindings.cpp +++ b/src/dusk/action_bindings.cpp @@ -15,7 +15,6 @@ ActionBindsMap& getActionBindsGameplay() { static ActionBindsMap actionBinds = { {ActionBinds::FIRST_PERSON_CAMERA, {&getSettings().actionBindings.firstPersonCamera, "First Person Camera"}}, {ActionBinds::CALL_MIDNA, {&getSettings().actionBindings.callMidna, "Call Midna"}}, - {ActionBinds::OPEN_DUSKLIGHT_MENU, {&getSettings().actionBindings.openDusklightMenu, "Open Dusklight Menu"}}, {ActionBinds::TURBO_SPEED_BUTTON, {&getSettings().actionBindings.turboSpeedButton, "Turbo Speed Button"}}, }; return actionBinds; @@ -24,6 +23,7 @@ ActionBindsMap& getActionBindsGameplay() { // Action Bindings that affect the interface (menus, etc.) ActionBindsMap& getActionBindsInterface() { static ActionBindsMap actionBinds = { + {ActionBinds::OPEN_DUSKLIGHT_MENU, {&getSettings().actionBindings.openDusklightMenu, "Open Dusklight Menu"}}, {ActionBinds::TOGGLE_TEXTURE_PACK, {&getSettings().actionBindings.toggleTexturePack, "Toggle Texture Pack"}}, }; return actionBinds; From d0763d43849d7f2f0410f982d49bf6404435388a Mon Sep 17 00:00:00 2001 From: Giorgio Mendieta <31053658+GiorgioMendieta@users.noreply.github.com> Date: Fri, 22 May 2026 21:09:37 +0200 Subject: [PATCH 7/9] fix: typo --- src/dusk/ui/controller_config.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/dusk/ui/controller_config.cpp b/src/dusk/ui/controller_config.cpp index fe76ac4626..6f7f2338ac 100644 --- a/src/dusk/ui/controller_config.cpp +++ b/src/dusk/ui/controller_config.cpp @@ -962,7 +962,7 @@ void ControllerConfigWindow::render_page(Pane& pane, int port, Page page) { pane.add_section("Custom Action Bindings"); pane.add_rml("A button bound to any action here will REPLACE the default control for" " that action. Only bind buttons here that aren't used anywhere else." - "

Note: The glyphs shown for in game actions will not change." + "

Note: The glyphs shown for in-game actions will not change." " This is not recommended for regular Gamecube controllers."); auto addActionBinding = [&](auto actionBind, const std::string& key) { From 752d3ab6fb53b62ff4bc3e687affd2f21af53bf9 Mon Sep 17 00:00:00 2001 From: Giorgio Mendieta <31053658+GiorgioMendieta@users.noreply.github.com> Date: Fri, 22 May 2026 22:17:57 +0200 Subject: [PATCH 8/9] fix: add type to action bindings fix: deduplicates logic for action bindings --- include/dusk/action_bindings.h | 12 ++++-- src/dusk/action_bindings.cpp | 71 ++++++------------------------- src/dusk/config.cpp | 2 +- src/dusk/ui/controller_config.cpp | 24 +++++++---- 4 files changed, 38 insertions(+), 71 deletions(-) diff --git a/include/dusk/action_bindings.h b/include/dusk/action_bindings.h index 5d18950c11..142ff1b453 100644 --- a/include/dusk/action_bindings.h +++ b/include/dusk/action_bindings.h @@ -15,9 +15,15 @@ enum class ActionBinds { COUNT, }; +enum class Type { + GAMEPLAY, + INTERFACE, +}; + struct ActionBindData { std::array* configVars{}; std::string actionName{}; + Type type{}; }; struct ActionBindPressData { @@ -27,9 +33,7 @@ struct ActionBindPressData { using ActionBindsMap = std::unordered_map; -ActionBindsMap& getActionBindsGameplay(); - -ActionBindsMap& getActionBindsInterface(); +ActionBindsMap& getActionBinds(); bool isActionBound(ActionBinds action, u32 port); @@ -43,4 +47,6 @@ bool getActionBindHoldAnyPort(ActionBinds action); int getActionBindButton(ActionBinds action, u32 port); +Type getActionBindType(ActionBinds action); + } diff --git a/src/dusk/action_bindings.cpp b/src/dusk/action_bindings.cpp index 8f059809ff..fcfb021a50 100644 --- a/src/dusk/action_bindings.cpp +++ b/src/dusk/action_bindings.cpp @@ -10,30 +10,21 @@ namespace dusk { static std::array(ActionBinds::COUNT)>, PAD_CHANMAX> actionPressData{}; -// Action Bindings that affect gameplay -ActionBindsMap& getActionBindsGameplay() { +ActionBindsMap& getActionBinds() { static ActionBindsMap actionBinds = { - {ActionBinds::FIRST_PERSON_CAMERA, {&getSettings().actionBindings.firstPersonCamera, "First Person Camera"}}, - {ActionBinds::CALL_MIDNA, {&getSettings().actionBindings.callMidna, "Call Midna"}}, - {ActionBinds::TURBO_SPEED_BUTTON, {&getSettings().actionBindings.turboSpeedButton, "Turbo Speed Button"}}, - }; - return actionBinds; -} - -// Action Bindings that affect the interface (menus, etc.) -ActionBindsMap& getActionBindsInterface() { - static ActionBindsMap actionBinds = { - {ActionBinds::OPEN_DUSKLIGHT_MENU, {&getSettings().actionBindings.openDusklightMenu, "Open Dusklight Menu"}}, - {ActionBinds::TOGGLE_TEXTURE_PACK, {&getSettings().actionBindings.toggleTexturePack, "Toggle Texture Pack"}}, + {ActionBinds::FIRST_PERSON_CAMERA, {&getSettings().actionBindings.firstPersonCamera, "First Person Camera", Type::GAMEPLAY}}, + {ActionBinds::CALL_MIDNA, {&getSettings().actionBindings.callMidna, "Call Midna", Type::GAMEPLAY}}, + {ActionBinds::TURBO_SPEED_BUTTON, {&getSettings().actionBindings.turboSpeedButton, "Turbo Speed Button", Type::GAMEPLAY}}, + {ActionBinds::OPEN_DUSKLIGHT_MENU, {&getSettings().actionBindings.openDusklightMenu, "Open Dusklight Menu", Type::INTERFACE}}, + {ActionBinds::TOGGLE_TEXTURE_PACK, {&getSettings().actionBindings.toggleTexturePack, "Toggle Texture Pack", Type::INTERFACE}}, }; return actionBinds; } bool isActionBound(ActionBinds action, u32 port) { - auto& actionBindsGameplay = getActionBindsGameplay(); - auto& actionBindsInterface = getActionBindsInterface(); + auto& actionBinds = getActionBinds(); // Check to make sure action is properly bound - if (!actionBindsGameplay.contains(action) && !actionBindsInterface.contains(action)) { + if (!actionBinds.contains(action)) { return false; } @@ -48,8 +39,8 @@ void updateActionBindings() { pressData.pressedCurFrame = false; } - // Update current frame with whether gameplay action button is pressed - for (auto& [action, boundAction] : getActionBindsGameplay()) { + // Update current frame with whether action button is pressed + for (auto& [action, boundAction] : getActionBinds()) { // If the action isn't bound, or if documents are visible and the action isn't // opening the dusklight menu, don't update. Otherwise, we may accidentally // perform actions while the dusklight menu is open. @@ -77,35 +68,8 @@ void updateActionBindings() { } } } - } - - // Update current frame for interface binds and handle their triggers separately - for (auto& [action, boundAction] : getActionBindsInterface()) { - // Interface binds should update regardless of UI visibility - if (!isActionBound(action, port) || - (ui::any_document_visible() && action != ActionBinds::OPEN_DUSKLIGHT_MENU)) { - continue; - } - - int button = boundAction.configVars->at(port); - - u32 count = 0; - if (PADGetKeyButtonBindings(port, &count) != nullptr) { - int numKeys = 0; - const bool* kbState = SDL_GetKeyboardState(&numKeys); - if (kbState[button]) { - actionPressData[port][static_cast(action)].pressedCurFrame = true; - } - } else { - auto controller = aurora::input::get_controller_for_player(port); - if (controller) { - if (SDL_GetGamepadButton(controller->m_controller, static_cast(button))) { - actionPressData[port][static_cast(action)].pressedCurFrame = true; - } - } - } - // Interface-specific triggers (do not apply gameplay UI visibility gating) + // Interface-specific triggers if (getActionBindTrig(ActionBinds::TOGGLE_TEXTURE_PACK, port)) { const bool enabled = !getSettings().game.enableTextureReplacements.getValue(); getSettings().game.enableTextureReplacements.setValue(enabled); @@ -139,17 +103,6 @@ bool getActionBindHoldAnyPort(ActionBinds action) { } int getActionBindButton(ActionBinds action, u32 port) { - auto& gameplayBinds = getActionBindsGameplay(); - auto& interfaceBinds = getActionBindsInterface(); - - if (gameplayBinds.contains(action)) { - return (*gameplayBinds[action].configVars)[port]; - } - - if (interfaceBinds.contains(action)) { - return (*interfaceBinds[action].configVars)[port]; - } - - return PAD_NATIVE_BUTTON_INVALID; + return (*getActionBinds()[action].configVars)[port]; } } diff --git a/src/dusk/config.cpp b/src/dusk/config.cpp index 8adac39856..c0edd84591 100644 --- a/src/dusk/config.cpp +++ b/src/dusk/config.cpp @@ -280,7 +280,7 @@ void dusk::config::Save() { } void dusk::config::ClearAllActionBindings(int port) { - for (auto& actionBinding : getActionBindsGameplay() | std::views::values) { + for (auto& actionBinding : getActionBinds() | std::views::values) { actionBinding.configVars->at(port).setValue(PAD_NATIVE_BUTTON_INVALID); } Save(); diff --git a/src/dusk/ui/controller_config.cpp b/src/dusk/ui/controller_config.cpp index 6f7f2338ac..0e05dc059d 100644 --- a/src/dusk/ui/controller_config.cpp +++ b/src/dusk/ui/controller_config.cpp @@ -939,13 +939,17 @@ void ControllerConfigWindow::render_page(Pane& pane, int port, Page page) { " that action. Only bind buttons here that aren't used anywhere else."); pane.add_section("Gameplay"); - for (auto& [configVars, actionName] : getActionBindsGameplay() | std::views::values) { - addActionBinding(&configVars->at(port), actionName); + for (auto& [configVars, actionName, type] : getActionBinds() | std::views::values) { + if (type == Type::GAMEPLAY) { + addActionBinding(&configVars->at(port), actionName); + } } pane.add_section("Interface"); - for (auto& [configVars, actionName] : getActionBindsInterface() | std::views::values) { - addActionBinding(&configVars->at(port), actionName); + for (auto& [configVars, actionName, type] : getActionBinds() | std::views::values) { + if (type == Type::INTERFACE) { + addActionBinding(&configVars->at(port), actionName); + } } break; @@ -988,13 +992,17 @@ void ControllerConfigWindow::render_page(Pane& pane, int port, Page page) { }; pane.add_section("Gameplay"); - for (auto& [configVars, actionName] : getActionBindsGameplay() | std::views::values) { - addActionBinding(&configVars->at(port), actionName); + for (auto& [configVars, actionName, type] : getActionBinds() | std::views::values) { + if (type == Type::GAMEPLAY) { + addActionBinding(&configVars->at(port), actionName); + } } pane.add_section("Interface"); - for (auto& [configVars, actionName] : getActionBindsInterface() | std::views::values) { - addActionBinding(&configVars->at(port), actionName); + for (auto& [configVars, actionName, type] : getActionBinds() | std::views::values) { + if (type == Type::INTERFACE) { + addActionBinding(&configVars->at(port), actionName); + } } break; } From 46228bbd91c53b9c78d1896ac5734ad89e54aee1 Mon Sep 17 00:00:00 2001 From: Giorgio Mendieta <31053658+GiorgioMendieta@users.noreply.github.com> Date: Fri, 22 May 2026 22:31:13 +0200 Subject: [PATCH 9/9] fix: rename ActionBindType enum --- include/dusk/action_bindings.h | 6 +++--- src/dusk/action_bindings.cpp | 10 +++++----- src/dusk/ui/controller_config.cpp | 8 ++++---- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/include/dusk/action_bindings.h b/include/dusk/action_bindings.h index 142ff1b453..45883cebab 100644 --- a/include/dusk/action_bindings.h +++ b/include/dusk/action_bindings.h @@ -15,7 +15,7 @@ enum class ActionBinds { COUNT, }; -enum class Type { +enum class ActionBindType { GAMEPLAY, INTERFACE, }; @@ -23,7 +23,7 @@ enum class Type { struct ActionBindData { std::array* configVars{}; std::string actionName{}; - Type type{}; + ActionBindType type{}; }; struct ActionBindPressData { @@ -47,6 +47,6 @@ bool getActionBindHoldAnyPort(ActionBinds action); int getActionBindButton(ActionBinds action, u32 port); -Type getActionBindType(ActionBinds action); +ActionBindType getActionBindType(ActionBinds action); } diff --git a/src/dusk/action_bindings.cpp b/src/dusk/action_bindings.cpp index fcfb021a50..c85acc8f8c 100644 --- a/src/dusk/action_bindings.cpp +++ b/src/dusk/action_bindings.cpp @@ -12,11 +12,11 @@ static std::array(ActionBinds:: ActionBindsMap& getActionBinds() { static ActionBindsMap actionBinds = { - {ActionBinds::FIRST_PERSON_CAMERA, {&getSettings().actionBindings.firstPersonCamera, "First Person Camera", Type::GAMEPLAY}}, - {ActionBinds::CALL_MIDNA, {&getSettings().actionBindings.callMidna, "Call Midna", Type::GAMEPLAY}}, - {ActionBinds::TURBO_SPEED_BUTTON, {&getSettings().actionBindings.turboSpeedButton, "Turbo Speed Button", Type::GAMEPLAY}}, - {ActionBinds::OPEN_DUSKLIGHT_MENU, {&getSettings().actionBindings.openDusklightMenu, "Open Dusklight Menu", Type::INTERFACE}}, - {ActionBinds::TOGGLE_TEXTURE_PACK, {&getSettings().actionBindings.toggleTexturePack, "Toggle Texture Pack", Type::INTERFACE}}, + {ActionBinds::FIRST_PERSON_CAMERA, {&getSettings().actionBindings.firstPersonCamera, "First Person Camera", ActionBindType::GAMEPLAY}}, + {ActionBinds::CALL_MIDNA, {&getSettings().actionBindings.callMidna, "Call Midna", ActionBindType::GAMEPLAY}}, + {ActionBinds::TURBO_SPEED_BUTTON, {&getSettings().actionBindings.turboSpeedButton, "Turbo Speed Button", ActionBindType::GAMEPLAY}}, + {ActionBinds::OPEN_DUSKLIGHT_MENU, {&getSettings().actionBindings.openDusklightMenu, "Open Dusklight Menu", ActionBindType::INTERFACE}}, + {ActionBinds::TOGGLE_TEXTURE_PACK, {&getSettings().actionBindings.toggleTexturePack, "Toggle Texture Pack", ActionBindType::INTERFACE}}, }; return actionBinds; } diff --git a/src/dusk/ui/controller_config.cpp b/src/dusk/ui/controller_config.cpp index 0e05dc059d..eead7e8287 100644 --- a/src/dusk/ui/controller_config.cpp +++ b/src/dusk/ui/controller_config.cpp @@ -940,14 +940,14 @@ void ControllerConfigWindow::render_page(Pane& pane, int port, Page page) { pane.add_section("Gameplay"); for (auto& [configVars, actionName, type] : getActionBinds() | std::views::values) { - if (type == Type::GAMEPLAY) { + if (type == ActionBindType::GAMEPLAY) { addActionBinding(&configVars->at(port), actionName); } } pane.add_section("Interface"); for (auto& [configVars, actionName, type] : getActionBinds() | std::views::values) { - if (type == Type::INTERFACE) { + if (type == ActionBindType::INTERFACE) { addActionBinding(&configVars->at(port), actionName); } } @@ -993,14 +993,14 @@ void ControllerConfigWindow::render_page(Pane& pane, int port, Page page) { pane.add_section("Gameplay"); for (auto& [configVars, actionName, type] : getActionBinds() | std::views::values) { - if (type == Type::GAMEPLAY) { + if (type == ActionBindType::GAMEPLAY) { addActionBinding(&configVars->at(port), actionName); } } pane.add_section("Interface"); for (auto& [configVars, actionName, type] : getActionBinds() | std::views::values) { - if (type == Type::INTERFACE) { + if (type == ActionBindType::INTERFACE) { addActionBinding(&configVars->at(port), actionName); } }