From 40023d42c0da7500f2b84ec5219fb9fb863a2fcb Mon Sep 17 00:00:00 2001 From: briaguya <70942617+briaguya-ai@users.noreply.github.com> Date: Sun, 19 Jan 2025 05:03:31 -0500 Subject: [PATCH 01/22] start moving towards just using `ShipDeviceIndex::SDLGamepad` --- libultraship | 2 +- .../controls/SohInputEditorWindow.cpp | 36 ++++++------------- .../controls/SohInputEditorWindow.h | 2 +- 3 files changed, 13 insertions(+), 27 deletions(-) diff --git a/libultraship b/libultraship index 9a974e002f..308fe81a67 160000 --- a/libultraship +++ b/libultraship @@ -1 +1 @@ -Subproject commit 9a974e002f84cd1fe834ee9d2fa4ccf16d899e0f +Subproject commit 308fe81a670ee373c08cd1b90bdf527f9807e3d8 diff --git a/soh/soh/Enhancements/controls/SohInputEditorWindow.cpp b/soh/soh/Enhancements/controls/SohInputEditorWindow.cpp index 492517738a..9ef3aeccf7 100644 --- a/soh/soh/Enhancements/controls/SohInputEditorWindow.cpp +++ b/soh/soh/Enhancements/controls/SohInputEditorWindow.cpp @@ -47,12 +47,10 @@ void SohInputEditorWindow::InitElement() { addButtonName(BTN_DRIGHT, "D-pad right"); addButtonName(0, "None"); - mDeviceIndexVisiblity.clear(); - mDeviceIndexVisiblity[Ship::ShipDeviceIndex::Keyboard] = true; - mDeviceIndexVisiblity[Ship::ShipDeviceIndex::Blue] = true; - for (auto index = 1; index < Ship::ShipDeviceIndex::Max; index++) { - mDeviceIndexVisiblity[static_cast(index)] = false; - } + mDeviceIndexVisibility.clear(); + mDeviceIndexVisibility[Ship::ShipDeviceIndex::Keyboard] = true; + mDeviceIndexVisibility[Ship::ShipDeviceIndex::SDLGamepad] = true; + mDeviceIndexVisibility[Ship::ShipDeviceIndex::Max] = false; } #define INPUT_EDITOR_WINDOW_GAME_INPUT_BLOCK_ID 95237929 @@ -198,22 +196,10 @@ void SohInputEditorWindow::GetButtonColorsForLUSDeviceIndex(Ship::ShipDeviceInde buttonColor = BUTTON_COLOR_KEYBOARD_BEIGE; buttonHoveredColor = BUTTON_COLOR_KEYBOARD_BEIGE_HOVERED; break; - case Ship::ShipDeviceIndex::Blue: + case Ship::ShipDeviceIndex::SDLGamepad: buttonColor = BUTTON_COLOR_GAMEPAD_BLUE; buttonHoveredColor = BUTTON_COLOR_GAMEPAD_BLUE_HOVERED; break; - case Ship::ShipDeviceIndex::Red: - buttonColor = BUTTON_COLOR_GAMEPAD_RED; - buttonHoveredColor = BUTTON_COLOR_GAMEPAD_RED_HOVERED; - break; - case Ship::ShipDeviceIndex::Orange: - buttonColor = BUTTON_COLOR_GAMEPAD_ORANGE; - buttonHoveredColor = BUTTON_COLOR_GAMEPAD_ORANGE_HOVERED; - break; - case Ship::ShipDeviceIndex::Green: - buttonColor = BUTTON_COLOR_GAMEPAD_GREEN; - buttonHoveredColor = BUTTON_COLOR_GAMEPAD_GREEN_HOVERED; - break; default: buttonColor = BUTTON_COLOR_GAMEPAD_PURPLE; buttonHoveredColor = BUTTON_COLOR_GAMEPAD_PURPLE_HOVERED; @@ -266,7 +252,7 @@ void SohInputEditorWindow::DrawButtonLineEditMappingButton(uint8_t port, N64Butt if (mapping == nullptr) { return; } - if (!mDeviceIndexVisiblity[mapping->GetShipDeviceIndex()]) { + if (!mDeviceIndexVisibility[mapping->GetShipDeviceIndex()]) { return; } @@ -539,7 +525,7 @@ void SohInputEditorWindow::DrawStickDirectionLineEditMappingButton(uint8_t port, if (mapping == nullptr) { return; } - if (!mDeviceIndexVisiblity[mapping->GetShipDeviceIndex()]) { + if (!mDeviceIndexVisibility[mapping->GetShipDeviceIndex()]) { return; } @@ -1682,11 +1668,11 @@ void SohInputEditorWindow::DrawDeviceVisibilityButtons() { GetButtonColorsForLUSDeviceIndex(Ship::ShipDeviceIndex::Keyboard, keyboardButtonColor, keyboardButtonHoveredColor); ImGui::PushStyleColor(ImGuiCol_Button, keyboardButtonColor); ImGui::PushStyleColor(ImGuiCol_ButtonHovered, keyboardButtonHoveredColor); - bool keyboardVisible = mDeviceIndexVisiblity[Ship::ShipDeviceIndex::Keyboard]; + bool keyboardVisible = mDeviceIndexVisibility[Ship::ShipDeviceIndex::Keyboard]; if(ImGui::Button( StringHelper::Sprintf("%s %s Keyboard", keyboardVisible ? ICON_FA_EYE : ICON_FA_EYE_SLASH, ICON_FA_KEYBOARD_O) .c_str())) { - mDeviceIndexVisiblity[Ship::ShipDeviceIndex::Keyboard] = !keyboardVisible; + mDeviceIndexVisibility[Ship::ShipDeviceIndex::Keyboard] = !keyboardVisible; } ImGui::PopStyleColor(); ImGui::PopStyleColor(); @@ -1702,12 +1688,12 @@ void SohInputEditorWindow::DrawDeviceVisibilityButtons() { ImGui::PushStyleColor(ImGuiCol_Button, buttonColor); ImGui::PushStyleColor(ImGuiCol_ButtonHovered, buttonHoveredColor); - bool visible = mDeviceIndexVisiblity[lusIndex]; + bool visible = mDeviceIndexVisibility[lusIndex]; if(ImGui::Button( StringHelper::Sprintf("%s %s %s (%s)", visible ? ICON_FA_EYE : ICON_FA_EYE_SLASH, connected ? ICON_FA_GAMEPAD : ICON_FA_CHAIN_BROKEN, name.c_str(), connected ? StringHelper::Sprintf("SDL %d", sdlIndex).c_str() : "Disconnected") .c_str())) { - mDeviceIndexVisiblity[lusIndex] = !visible; + mDeviceIndexVisibility[lusIndex] = !visible; } ImGui::PopStyleColor(); ImGui::PopStyleColor(); diff --git a/soh/soh/Enhancements/controls/SohInputEditorWindow.h b/soh/soh/Enhancements/controls/SohInputEditorWindow.h index fdb3c77b00..aae33f19f4 100644 --- a/soh/soh/Enhancements/controls/SohInputEditorWindow.h +++ b/soh/soh/Enhancements/controls/SohInputEditorWindow.h @@ -101,6 +101,6 @@ class SohInputEditorWindow : public Ship::GuiWindow { void DrawSetDefaultsButton(uint8_t portIndex); void DrawClearAllButton(uint8_t portIndex); - std::map mDeviceIndexVisiblity; + std::map mDeviceIndexVisibility; void DrawDeviceVisibilityButtons(); }; From 672ef86c0d0755bf7fa8371c4c61c69d0941bfeb Mon Sep 17 00:00:00 2001 From: briaguya <70942617+briaguya-ai@users.noreply.github.com> Date: Sun, 19 Jan 2025 07:38:15 -0500 Subject: [PATCH 02/22] rename `ShipDeviceIndex` to `ShipDeviceType` --- libultraship | 2 +- .../controls/SohInputEditorWindow.cpp | 94 +++++++++---------- .../controls/SohInputEditorWindow.h | 4 +- 3 files changed, 50 insertions(+), 50 deletions(-) diff --git a/libultraship b/libultraship index 308fe81a67..03fa9c1e13 160000 --- a/libultraship +++ b/libultraship @@ -1 +1 @@ -Subproject commit 308fe81a670ee373c08cd1b90bdf527f9807e3d8 +Subproject commit 03fa9c1e134e0d0381d67adb98b512520d54f827 diff --git a/soh/soh/Enhancements/controls/SohInputEditorWindow.cpp b/soh/soh/Enhancements/controls/SohInputEditorWindow.cpp index 9ef3aeccf7..eaedf98eeb 100644 --- a/soh/soh/Enhancements/controls/SohInputEditorWindow.cpp +++ b/soh/soh/Enhancements/controls/SohInputEditorWindow.cpp @@ -48,9 +48,9 @@ void SohInputEditorWindow::InitElement() { addButtonName(0, "None"); mDeviceIndexVisibility.clear(); - mDeviceIndexVisibility[Ship::ShipDeviceIndex::Keyboard] = true; - mDeviceIndexVisibility[Ship::ShipDeviceIndex::SDLGamepad] = true; - mDeviceIndexVisibility[Ship::ShipDeviceIndex::Max] = false; + mDeviceIndexVisibility[Ship::ShipDeviceType::Keyboard] = true; + mDeviceIndexVisibility[Ship::ShipDeviceType::SDLGamepad] = true; + mDeviceIndexVisibility[Ship::ShipDeviceType::Max] = false; } #define INPUT_EDITOR_WINDOW_GAME_INPUT_BLOCK_ID 95237929 @@ -189,14 +189,14 @@ void SohInputEditorWindow::DrawAnalogPreview(const char* label, ImVec2 stick, fl #define BUTTON_COLOR_GAMEPAD_PURPLE ImVec4(0.431f, 0.369f, 0.706f, 0.5f) #define BUTTON_COLOR_GAMEPAD_PURPLE_HOVERED ImVec4(0.431f, 0.369f, 0.706f, 1.0f) -void SohInputEditorWindow::GetButtonColorsForLUSDeviceIndex(Ship::ShipDeviceIndex lusIndex, ImVec4& buttonColor, +void SohInputEditorWindow::GetButtonColorsForLUSDeviceIndex(Ship::ShipDeviceType lusIndex, ImVec4& buttonColor, ImVec4& buttonHoveredColor) { switch (lusIndex) { - case Ship::ShipDeviceIndex::Keyboard: + case Ship::ShipDeviceType::Keyboard: buttonColor = BUTTON_COLOR_KEYBOARD_BEIGE; buttonHoveredColor = BUTTON_COLOR_KEYBOARD_BEIGE_HOVERED; break; - case Ship::ShipDeviceIndex::SDLGamepad: + case Ship::ShipDeviceType::SDLGamepad: buttonColor = BUTTON_COLOR_GAMEPAD_BLUE; buttonHoveredColor = BUTTON_COLOR_GAMEPAD_BLUE_HOVERED; break; @@ -252,7 +252,7 @@ void SohInputEditorWindow::DrawButtonLineEditMappingButton(uint8_t port, N64Butt if (mapping == nullptr) { return; } - if (!mDeviceIndexVisibility[mapping->GetShipDeviceIndex()]) { + if (!mDeviceIndexVisibility[mapping->GetShipDeviceType()]) { return; } @@ -273,7 +273,7 @@ void SohInputEditorWindow::DrawButtonLineEditMappingButton(uint8_t port, N64Butt auto buttonHoveredColor = ImGui::GetStyleColorVec4(ImGuiCol_ButtonHovered); auto physicalInputDisplayName = StringHelper::Sprintf("%s %s", icon.c_str(), mapping->GetPhysicalInputName().c_str()); - GetButtonColorsForLUSDeviceIndex(mapping->GetShipDeviceIndex(), buttonColor, buttonHoveredColor); + GetButtonColorsForLUSDeviceIndex(mapping->GetShipDeviceType(), buttonColor, buttonHoveredColor); ImGui::PushStyleColor(ImGuiCol_Button, buttonColor); ImGui::PushStyleColor(ImGuiCol_ButtonHovered, buttonHoveredColor); auto popupId = StringHelper::Sprintf("editButtonMappingPopup##%s", id.c_str()); @@ -315,14 +315,14 @@ void SohInputEditorWindow::DrawButtonLineEditMappingButton(uint8_t port, N64Butt auto indexMapping = Ship::Context::GetInstance() ->GetControlDeck() ->GetDeviceIndexMappingManager() - ->GetDeviceIndexMappingFromShipDeviceIndex(mapping->GetShipDeviceIndex()); + ->GetDeviceIndexMappingFromShipDeviceIndex(mapping->GetShipDeviceType()); auto sdlIndexMapping = std::dynamic_pointer_cast(indexMapping); if (sdlIndexMapping != nullptr && sdlAxisDirectionToButtonMapping != nullptr) { ImGui::PushStyleVar(ImGuiStyleVar_ButtonTextAlign, ImVec2(0.0f, 0.5f)); auto buttonColor = ImGui::GetStyleColorVec4(ImGuiCol_Button); auto buttonHoveredColor = ImGui::GetStyleColorVec4(ImGuiCol_ButtonHovered); - GetButtonColorsForLUSDeviceIndex(mapping->GetShipDeviceIndex(), buttonColor, buttonHoveredColor); + GetButtonColorsForLUSDeviceIndex(mapping->GetShipDeviceType(), buttonColor, buttonHoveredColor); ImGui::PushStyleColor(ImGuiCol_Button, buttonColor); ImGui::PushStyleColor(ImGuiCol_ButtonHovered, buttonHoveredColor); ImGui::PushStyleVar(ImGuiStyleVar_ButtonTextAlign, ImVec2(1.0f, 0.5f)); @@ -525,7 +525,7 @@ void SohInputEditorWindow::DrawStickDirectionLineEditMappingButton(uint8_t port, if (mapping == nullptr) { return; } - if (!mDeviceIndexVisibility[mapping->GetShipDeviceIndex()]) { + if (!mDeviceIndexVisibility[mapping->GetShipDeviceType()]) { return; } @@ -546,7 +546,7 @@ void SohInputEditorWindow::DrawStickDirectionLineEditMappingButton(uint8_t port, auto buttonHoveredColor = ImGui::GetStyleColorVec4(ImGuiCol_ButtonHovered); auto physicalInputDisplayName = StringHelper::Sprintf("%s %s", icon.c_str(), mapping->GetPhysicalInputName().c_str()); - GetButtonColorsForLUSDeviceIndex(mapping->GetShipDeviceIndex(), buttonColor, buttonHoveredColor); + GetButtonColorsForLUSDeviceIndex(mapping->GetShipDeviceType(), buttonColor, buttonHoveredColor); ImGui::PushStyleColor(ImGuiCol_Button, buttonColor); ImGui::PushStyleColor(ImGuiCol_ButtonHovered, buttonHoveredColor); auto popupId = StringHelper::Sprintf("editStickDirectionMappingPopup##%s", id.c_str()); @@ -871,7 +871,7 @@ void SohInputEditorWindow::DrawRumbleSection(uint8_t port) { ImGui::SetNextItemOpen(true, ImGuiCond_Once); auto buttonColor = ImGui::GetStyleColorVec4(ImGuiCol_Button); auto buttonHoveredColor = ImGui::GetStyleColorVec4(ImGuiCol_ButtonHovered); - GetButtonColorsForLUSDeviceIndex(mapping->GetShipDeviceIndex(), buttonColor, buttonHoveredColor); + GetButtonColorsForLUSDeviceIndex(mapping->GetShipDeviceType(), buttonColor, buttonHoveredColor); // begin hackaround https://github.com/ocornut/imgui/issues/282#issuecomment-123763192 // spaces to have background color for text in a tree node std::string spaces = ""; @@ -1243,8 +1243,8 @@ void SohInputEditorWindow::DrawGyroSection(uint8_t port) { } void SohInputEditorWindow::DrawButtonDeviceIcons(uint8_t portIndex, std::set bitmasks) { - std::set allLusDeviceIndices; - allLusDeviceIndices.insert(Ship::ShipDeviceIndex::Keyboard); + std::set allLusDeviceIndices; + allLusDeviceIndices.insert(Ship::ShipDeviceType::Keyboard); for (auto [lusIndex, mapping] : Ship::Context::GetInstance() ->GetControlDeck() ->GetDeviceIndexMappingManager() @@ -1252,7 +1252,7 @@ void SohInputEditorWindow::DrawButtonDeviceIcons(uint8_t portIndex, std::set> lusDeviceIndiciesWithMappings; + std::vector> lusDeviceIndiciesWithMappings; for (auto lusIndex : allLusDeviceIndices) { for (auto [bitmask, button] : Ship::Context::GetInstance()->GetControlDeck()->GetControllerByPort(portIndex)->GetAllButtons()) { @@ -1260,11 +1260,11 @@ void SohInputEditorWindow::DrawButtonDeviceIcons(uint8_t portIndex, std::setHasMappingsForShipDeviceIndex(lusIndex)) { + if (button->HasMappingsForShipDeviceType(lusIndex)) { for (auto [id, mapping] : button->GetAllButtonMappings()) { - if (mapping->GetShipDeviceIndex() == lusIndex) { + if (mapping->GetShipDeviceType() == lusIndex) { lusDeviceIndiciesWithMappings.push_back( - std::pair(lusIndex, mapping->PhysicalDeviceIsConnected())); + std::pair(lusIndex, mapping->PhysicalDeviceIsConnected())); break; } } @@ -1280,7 +1280,7 @@ void SohInputEditorWindow::DrawButtonDeviceIcons(uint8_t portIndex, std::set allLusDeviceIndices; - allLusDeviceIndices.insert(Ship::ShipDeviceIndex::Keyboard); + std::set allLusDeviceIndices; + allLusDeviceIndices.insert(Ship::ShipDeviceType::Keyboard); for (auto [lusIndex, mapping] : Ship::Context::GetInstance() ->GetControlDeck() ->GetDeviceIndexMappingManager() @@ -1300,20 +1300,20 @@ void SohInputEditorWindow::DrawAnalogStickDeviceIcons(uint8_t portIndex, Ship::S allLusDeviceIndices.insert(lusIndex); } - std::vector> lusDeviceIndiciesWithMappings; + std::vector> lusDeviceIndiciesWithMappings; for (auto lusIndex : allLusDeviceIndices) { auto controllerStick = stickIndex == Ship::StickIndex::LEFT_STICK ? Ship::Context::GetInstance()->GetControlDeck()->GetControllerByPort(portIndex)->GetLeftStick() : Ship::Context::GetInstance()->GetControlDeck()->GetControllerByPort(portIndex)->GetRightStick(); - if (controllerStick->HasMappingsForShipDeviceIndex(lusIndex)) { + if (controllerStick->HasMappingsForShipDeviceType(lusIndex)) { for (auto [direction, mappings] : controllerStick->GetAllAxisDirectionMappings()) { bool foundMapping = false; for (auto [id, mapping] : mappings) { - if (mapping->GetShipDeviceIndex() == lusIndex) { + if (mapping->GetShipDeviceType() == lusIndex) { foundMapping = true; lusDeviceIndiciesWithMappings.push_back( - std::pair(lusIndex, mapping->PhysicalDeviceIsConnected())); + std::pair(lusIndex, mapping->PhysicalDeviceIsConnected())); break; } } @@ -1331,7 +1331,7 @@ void SohInputEditorWindow::DrawAnalogStickDeviceIcons(uint8_t portIndex, Ship::S ImGui::PushStyleColor(ImGuiCol_Button, buttonColor); ImGui::PushStyleColor(ImGuiCol_ButtonHovered, buttonHoveredColor); ImGui::SameLine(); - if (lusIndex == Ship::ShipDeviceIndex::Keyboard) { + if (lusIndex == Ship::ShipDeviceType::Keyboard) { ImGui::SmallButton(ICON_FA_KEYBOARD_O); } else { ImGui::SmallButton(connected ? ICON_FA_GAMEPAD : ICON_FA_CHAIN_BROKEN); @@ -1342,7 +1342,7 @@ void SohInputEditorWindow::DrawAnalogStickDeviceIcons(uint8_t portIndex, Ship::S } void SohInputEditorWindow::DrawRumbleDeviceIcons(uint8_t portIndex) { - std::set allLusDeviceIndices; + std::set allLusDeviceIndices; for (auto [lusIndex, mapping] : Ship::Context::GetInstance() ->GetControlDeck() ->GetDeviceIndexMappingManager() @@ -1350,21 +1350,21 @@ void SohInputEditorWindow::DrawRumbleDeviceIcons(uint8_t portIndex) { allLusDeviceIndices.insert(lusIndex); } - std::vector> lusDeviceIndiciesWithMappings; + std::vector> lusDeviceIndiciesWithMappings; for (auto lusIndex : allLusDeviceIndices) { if (Ship::Context::GetInstance() ->GetControlDeck() ->GetControllerByPort(portIndex) ->GetRumble() - ->HasMappingsForShipDeviceIndex(lusIndex)) { + ->HasMappingsForShipDeviceType(lusIndex)) { for (auto [id, mapping] : Ship::Context::GetInstance() ->GetControlDeck() ->GetControllerByPort(portIndex) ->GetRumble() ->GetAllRumbleMappings()) { - if (mapping->GetShipDeviceIndex() == lusIndex) { + if (mapping->GetShipDeviceType() == lusIndex) { lusDeviceIndiciesWithMappings.push_back( - std::pair(lusIndex, mapping->PhysicalDeviceIsConnected())); + std::pair(lusIndex, mapping->PhysicalDeviceIsConnected())); break; } } @@ -1393,7 +1393,7 @@ void SohInputEditorWindow::DrawGyroDeviceIcons(uint8_t portIndex) { auto buttonColor = ImGui::GetStyleColorVec4(ImGuiCol_Button); auto buttonHoveredColor = ImGui::GetStyleColorVec4(ImGuiCol_ButtonHovered); - GetButtonColorsForLUSDeviceIndex(mapping->GetShipDeviceIndex(), buttonColor, buttonHoveredColor); + GetButtonColorsForLUSDeviceIndex(mapping->GetShipDeviceType(), buttonColor, buttonHoveredColor); ImGui::PushStyleColor(ImGuiCol_Button, buttonColor); ImGui::PushStyleColor(ImGuiCol_ButtonHovered, buttonHoveredColor); ImGui::SameLine(); @@ -1403,7 +1403,7 @@ void SohInputEditorWindow::DrawGyroDeviceIcons(uint8_t portIndex) { } void SohInputEditorWindow::DrawLEDDeviceIcons(uint8_t portIndex) { - std::set allLusDeviceIndices; + std::set allLusDeviceIndices; for (auto [lusIndex, mapping] : Ship::Context::GetInstance() ->GetControlDeck() ->GetDeviceIndexMappingManager() @@ -1411,21 +1411,21 @@ void SohInputEditorWindow::DrawLEDDeviceIcons(uint8_t portIndex) { allLusDeviceIndices.insert(lusIndex); } - std::vector> lusDeviceIndiciesWithMappings; + std::vector> lusDeviceIndiciesWithMappings; for (auto lusIndex : allLusDeviceIndices) { if (Ship::Context::GetInstance() ->GetControlDeck() ->GetControllerByPort(portIndex) - ->GetRumble() - ->HasMappingsForShipDeviceIndex(lusIndex)) { + ->GetLED() + ->HasMappingsForShipDeviceType(lusIndex)) { for (auto [id, mapping] : Ship::Context::GetInstance() ->GetControlDeck() ->GetControllerByPort(portIndex) ->GetLED() ->GetAllLEDMappings()) { - if (mapping->GetShipDeviceIndex() == lusIndex) { + if (mapping->GetShipDeviceType() == lusIndex) { lusDeviceIndiciesWithMappings.push_back( - std::pair(lusIndex, mapping->PhysicalDeviceIsConnected())); + std::pair(lusIndex, mapping->PhysicalDeviceIsConnected())); break; } } @@ -1638,7 +1638,7 @@ void SohInputEditorWindow::DrawDpadControlPanel() { } void SohInputEditorWindow::DrawDeviceVisibilityButtons() { - std::map> indexMappings; + std::map> indexMappings; for (auto [lusIndex, mapping] : Ship::Context::GetInstance() ->GetControlDeck() ->GetDeviceIndexMappingManager() @@ -1665,14 +1665,14 @@ void SohInputEditorWindow::DrawDeviceVisibilityButtons() { auto keyboardButtonColor = ImGui::GetStyleColorVec4(ImGuiCol_Button); auto keyboardButtonHoveredColor = ImGui::GetStyleColorVec4(ImGuiCol_ButtonHovered); - GetButtonColorsForLUSDeviceIndex(Ship::ShipDeviceIndex::Keyboard, keyboardButtonColor, keyboardButtonHoveredColor); + GetButtonColorsForLUSDeviceIndex(Ship::ShipDeviceType::Keyboard, keyboardButtonColor, keyboardButtonHoveredColor); ImGui::PushStyleColor(ImGuiCol_Button, keyboardButtonColor); ImGui::PushStyleColor(ImGuiCol_ButtonHovered, keyboardButtonHoveredColor); - bool keyboardVisible = mDeviceIndexVisibility[Ship::ShipDeviceIndex::Keyboard]; + bool keyboardVisible = mDeviceIndexVisibility[Ship::ShipDeviceType::Keyboard]; if(ImGui::Button( StringHelper::Sprintf("%s %s Keyboard", keyboardVisible ? ICON_FA_EYE : ICON_FA_EYE_SLASH, ICON_FA_KEYBOARD_O) .c_str())) { - mDeviceIndexVisibility[Ship::ShipDeviceIndex::Keyboard] = !keyboardVisible; + mDeviceIndexVisibility[Ship::ShipDeviceType::Keyboard] = !keyboardVisible; } ImGui::PopStyleColor(); ImGui::PopStyleColor(); @@ -1996,7 +1996,7 @@ void SohInputEditorWindow::DrawSetDefaultsButton(uint8_t portIndex) { } if (ImGui::BeginPopup(popupId.c_str())) { - std::map> indexMappings; + std::map> indexMappings; for (auto [lusIndex, mapping] : Ship::Context::GetInstance() ->GetControlDeck() ->GetDeviceIndexMappingManager() @@ -2027,9 +2027,9 @@ void SohInputEditorWindow::DrawSetDefaultsButton(uint8_t portIndex) { Ship::Context::GetInstance() ->GetControlDeck() ->GetControllerByPort(portIndex) - ->ClearAllMappingsForDevice(Ship::ShipDeviceIndex::Keyboard); + ->ClearAllMappingsForDeviceType(Ship::ShipDeviceType::Keyboard); Ship::Context::GetInstance()->GetControlDeck()->GetControllerByPort(portIndex)->AddDefaultMappings( - Ship::ShipDeviceIndex::Keyboard); + Ship::ShipDeviceType::Keyboard); shouldClose = true; ImGui::CloseCurrentPopup(); } @@ -2062,7 +2062,7 @@ void SohInputEditorWindow::DrawSetDefaultsButton(uint8_t portIndex) { Ship::Context::GetInstance() ->GetControlDeck() ->GetControllerByPort(portIndex) - ->ClearAllMappingsForDevice(lusIndex); + ->ClearAllMappingsForDeviceType(lusIndex); Ship::Context::GetInstance()->GetControlDeck()->GetControllerByPort(portIndex)->AddDefaultMappings( lusIndex); shouldClose = true; diff --git a/soh/soh/Enhancements/controls/SohInputEditorWindow.h b/soh/soh/Enhancements/controls/SohInputEditorWindow.h index aae33f19f4..8aaaa3a212 100644 --- a/soh/soh/Enhancements/controls/SohInputEditorWindow.h +++ b/soh/soh/Enhancements/controls/SohInputEditorWindow.h @@ -83,7 +83,7 @@ class SohInputEditorWindow : public Ship::GuiWindow { void UpdateBitmaskToMappingIds(uint8_t port); void UpdateStickDirectionToMappingIds(uint8_t port); - void GetButtonColorsForLUSDeviceIndex(Ship::ShipDeviceIndex lusIndex, ImVec4& buttonColor, + void GetButtonColorsForLUSDeviceIndex(Ship::ShipDeviceType lusIndex, ImVec4& buttonColor, ImVec4& buttonHoveredColor); void DrawLinkTab(); void DrawIvanTab(); @@ -101,6 +101,6 @@ class SohInputEditorWindow : public Ship::GuiWindow { void DrawSetDefaultsButton(uint8_t portIndex); void DrawClearAllButton(uint8_t portIndex); - std::map mDeviceIndexVisibility; + std::map mDeviceIndexVisibility; void DrawDeviceVisibilityButtons(); }; From 05d80f9ca39ab4e25b856b0461c2e5de4a734ddd Mon Sep 17 00:00:00 2001 From: briaguya <70942617+briaguya-ai@users.noreply.github.com> Date: Sun, 19 Jan 2025 07:59:16 -0500 Subject: [PATCH 03/22] all sdl mappings are always `ShipDeviceType::SDLGamepad` --- libultraship | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libultraship b/libultraship index 03fa9c1e13..1e1fe6d53b 160000 --- a/libultraship +++ b/libultraship @@ -1 +1 @@ -Subproject commit 03fa9c1e134e0d0381d67adb98b512520d54f827 +Subproject commit 1e1fe6d53bf70b82dcbd925f9f627a91d7df4182 From 855b2bfd016a629dce37db9a16c508510d099e40 Mon Sep 17 00:00:00 2001 From: briaguya <70942617+briaguya-ai@users.noreply.github.com> Date: Sun, 19 Jan 2025 09:02:45 -0500 Subject: [PATCH 04/22] create new `physicaldevice` directory where the new stuff can live --- libultraship | 2 +- .../controls/SohInputEditorWindow.cpp | 90 +++++++++---------- .../controls/SohInputEditorWindow.h | 4 +- 3 files changed, 48 insertions(+), 48 deletions(-) diff --git a/libultraship b/libultraship index 1e1fe6d53b..e7d28a574a 160000 --- a/libultraship +++ b/libultraship @@ -1 +1 @@ -Subproject commit 1e1fe6d53bf70b82dcbd925f9f627a91d7df4182 +Subproject commit e7d28a574a76eefd7f911d7ce0966530c4bfbb13 diff --git a/soh/soh/Enhancements/controls/SohInputEditorWindow.cpp b/soh/soh/Enhancements/controls/SohInputEditorWindow.cpp index eaedf98eeb..8cd6d4dc0b 100644 --- a/soh/soh/Enhancements/controls/SohInputEditorWindow.cpp +++ b/soh/soh/Enhancements/controls/SohInputEditorWindow.cpp @@ -48,9 +48,9 @@ void SohInputEditorWindow::InitElement() { addButtonName(0, "None"); mDeviceIndexVisibility.clear(); - mDeviceIndexVisibility[Ship::ShipDeviceType::Keyboard] = true; - mDeviceIndexVisibility[Ship::ShipDeviceType::SDLGamepad] = true; - mDeviceIndexVisibility[Ship::ShipDeviceType::Max] = false; + mDeviceIndexVisibility[Ship::PhysicalDeviceType::Keyboard] = true; + mDeviceIndexVisibility[Ship::PhysicalDeviceType::SDLGamepad] = true; + mDeviceIndexVisibility[Ship::PhysicalDeviceType::Max] = false; } #define INPUT_EDITOR_WINDOW_GAME_INPUT_BLOCK_ID 95237929 @@ -189,14 +189,14 @@ void SohInputEditorWindow::DrawAnalogPreview(const char* label, ImVec2 stick, fl #define BUTTON_COLOR_GAMEPAD_PURPLE ImVec4(0.431f, 0.369f, 0.706f, 0.5f) #define BUTTON_COLOR_GAMEPAD_PURPLE_HOVERED ImVec4(0.431f, 0.369f, 0.706f, 1.0f) -void SohInputEditorWindow::GetButtonColorsForLUSDeviceIndex(Ship::ShipDeviceType lusIndex, ImVec4& buttonColor, +void SohInputEditorWindow::GetButtonColorsForLUSDeviceIndex(Ship::PhysicalDeviceType lusIndex, ImVec4& buttonColor, ImVec4& buttonHoveredColor) { switch (lusIndex) { - case Ship::ShipDeviceType::Keyboard: + case Ship::PhysicalDeviceType::Keyboard: buttonColor = BUTTON_COLOR_KEYBOARD_BEIGE; buttonHoveredColor = BUTTON_COLOR_KEYBOARD_BEIGE_HOVERED; break; - case Ship::ShipDeviceType::SDLGamepad: + case Ship::PhysicalDeviceType::SDLGamepad: buttonColor = BUTTON_COLOR_GAMEPAD_BLUE; buttonHoveredColor = BUTTON_COLOR_GAMEPAD_BLUE_HOVERED; break; @@ -252,7 +252,7 @@ void SohInputEditorWindow::DrawButtonLineEditMappingButton(uint8_t port, N64Butt if (mapping == nullptr) { return; } - if (!mDeviceIndexVisibility[mapping->GetShipDeviceType()]) { + if (!mDeviceIndexVisibility[mapping->GetPhysicalDeviceType()]) { return; } @@ -273,7 +273,7 @@ void SohInputEditorWindow::DrawButtonLineEditMappingButton(uint8_t port, N64Butt auto buttonHoveredColor = ImGui::GetStyleColorVec4(ImGuiCol_ButtonHovered); auto physicalInputDisplayName = StringHelper::Sprintf("%s %s", icon.c_str(), mapping->GetPhysicalInputName().c_str()); - GetButtonColorsForLUSDeviceIndex(mapping->GetShipDeviceType(), buttonColor, buttonHoveredColor); + GetButtonColorsForLUSDeviceIndex(mapping->GetPhysicalDeviceType(), buttonColor, buttonHoveredColor); ImGui::PushStyleColor(ImGuiCol_Button, buttonColor); ImGui::PushStyleColor(ImGuiCol_ButtonHovered, buttonHoveredColor); auto popupId = StringHelper::Sprintf("editButtonMappingPopup##%s", id.c_str()); @@ -315,14 +315,14 @@ void SohInputEditorWindow::DrawButtonLineEditMappingButton(uint8_t port, N64Butt auto indexMapping = Ship::Context::GetInstance() ->GetControlDeck() ->GetDeviceIndexMappingManager() - ->GetDeviceIndexMappingFromShipDeviceIndex(mapping->GetShipDeviceType()); + ->GetDeviceIndexMappingFromShipDeviceIndex(mapping->GetPhysicalDeviceType()); auto sdlIndexMapping = std::dynamic_pointer_cast(indexMapping); if (sdlIndexMapping != nullptr && sdlAxisDirectionToButtonMapping != nullptr) { ImGui::PushStyleVar(ImGuiStyleVar_ButtonTextAlign, ImVec2(0.0f, 0.5f)); auto buttonColor = ImGui::GetStyleColorVec4(ImGuiCol_Button); auto buttonHoveredColor = ImGui::GetStyleColorVec4(ImGuiCol_ButtonHovered); - GetButtonColorsForLUSDeviceIndex(mapping->GetShipDeviceType(), buttonColor, buttonHoveredColor); + GetButtonColorsForLUSDeviceIndex(mapping->GetPhysicalDeviceType(), buttonColor, buttonHoveredColor); ImGui::PushStyleColor(ImGuiCol_Button, buttonColor); ImGui::PushStyleColor(ImGuiCol_ButtonHovered, buttonHoveredColor); ImGui::PushStyleVar(ImGuiStyleVar_ButtonTextAlign, ImVec2(1.0f, 0.5f)); @@ -525,7 +525,7 @@ void SohInputEditorWindow::DrawStickDirectionLineEditMappingButton(uint8_t port, if (mapping == nullptr) { return; } - if (!mDeviceIndexVisibility[mapping->GetShipDeviceType()]) { + if (!mDeviceIndexVisibility[mapping->GetPhysicalDeviceType()]) { return; } @@ -546,7 +546,7 @@ void SohInputEditorWindow::DrawStickDirectionLineEditMappingButton(uint8_t port, auto buttonHoveredColor = ImGui::GetStyleColorVec4(ImGuiCol_ButtonHovered); auto physicalInputDisplayName = StringHelper::Sprintf("%s %s", icon.c_str(), mapping->GetPhysicalInputName().c_str()); - GetButtonColorsForLUSDeviceIndex(mapping->GetShipDeviceType(), buttonColor, buttonHoveredColor); + GetButtonColorsForLUSDeviceIndex(mapping->GetPhysicalDeviceType(), buttonColor, buttonHoveredColor); ImGui::PushStyleColor(ImGuiCol_Button, buttonColor); ImGui::PushStyleColor(ImGuiCol_ButtonHovered, buttonHoveredColor); auto popupId = StringHelper::Sprintf("editStickDirectionMappingPopup##%s", id.c_str()); @@ -871,7 +871,7 @@ void SohInputEditorWindow::DrawRumbleSection(uint8_t port) { ImGui::SetNextItemOpen(true, ImGuiCond_Once); auto buttonColor = ImGui::GetStyleColorVec4(ImGuiCol_Button); auto buttonHoveredColor = ImGui::GetStyleColorVec4(ImGuiCol_ButtonHovered); - GetButtonColorsForLUSDeviceIndex(mapping->GetShipDeviceType(), buttonColor, buttonHoveredColor); + GetButtonColorsForLUSDeviceIndex(mapping->GetPhysicalDeviceType(), buttonColor, buttonHoveredColor); // begin hackaround https://github.com/ocornut/imgui/issues/282#issuecomment-123763192 // spaces to have background color for text in a tree node std::string spaces = ""; @@ -1243,8 +1243,8 @@ void SohInputEditorWindow::DrawGyroSection(uint8_t port) { } void SohInputEditorWindow::DrawButtonDeviceIcons(uint8_t portIndex, std::set bitmasks) { - std::set allLusDeviceIndices; - allLusDeviceIndices.insert(Ship::ShipDeviceType::Keyboard); + std::set allLusDeviceIndices; + allLusDeviceIndices.insert(Ship::PhysicalDeviceType::Keyboard); for (auto [lusIndex, mapping] : Ship::Context::GetInstance() ->GetControlDeck() ->GetDeviceIndexMappingManager() @@ -1252,7 +1252,7 @@ void SohInputEditorWindow::DrawButtonDeviceIcons(uint8_t portIndex, std::set> lusDeviceIndiciesWithMappings; + std::vector> lusDeviceIndiciesWithMappings; for (auto lusIndex : allLusDeviceIndices) { for (auto [bitmask, button] : Ship::Context::GetInstance()->GetControlDeck()->GetControllerByPort(portIndex)->GetAllButtons()) { @@ -1260,11 +1260,11 @@ void SohInputEditorWindow::DrawButtonDeviceIcons(uint8_t portIndex, std::setHasMappingsForShipDeviceType(lusIndex)) { + if (button->HasMappingsForPhysicalDeviceType(lusIndex)) { for (auto [id, mapping] : button->GetAllButtonMappings()) { - if (mapping->GetShipDeviceType() == lusIndex) { + if (mapping->GetPhysicalDeviceType() == lusIndex) { lusDeviceIndiciesWithMappings.push_back( - std::pair(lusIndex, mapping->PhysicalDeviceIsConnected())); + std::pair(lusIndex, mapping->PhysicalDeviceIsConnected())); break; } } @@ -1280,7 +1280,7 @@ void SohInputEditorWindow::DrawButtonDeviceIcons(uint8_t portIndex, std::set allLusDeviceIndices; - allLusDeviceIndices.insert(Ship::ShipDeviceType::Keyboard); + std::set allLusDeviceIndices; + allLusDeviceIndices.insert(Ship::PhysicalDeviceType::Keyboard); for (auto [lusIndex, mapping] : Ship::Context::GetInstance() ->GetControlDeck() ->GetDeviceIndexMappingManager() @@ -1300,20 +1300,20 @@ void SohInputEditorWindow::DrawAnalogStickDeviceIcons(uint8_t portIndex, Ship::S allLusDeviceIndices.insert(lusIndex); } - std::vector> lusDeviceIndiciesWithMappings; + std::vector> lusDeviceIndiciesWithMappings; for (auto lusIndex : allLusDeviceIndices) { auto controllerStick = stickIndex == Ship::StickIndex::LEFT_STICK ? Ship::Context::GetInstance()->GetControlDeck()->GetControllerByPort(portIndex)->GetLeftStick() : Ship::Context::GetInstance()->GetControlDeck()->GetControllerByPort(portIndex)->GetRightStick(); - if (controllerStick->HasMappingsForShipDeviceType(lusIndex)) { + if (controllerStick->HasMappingsForPhysicalDeviceType(lusIndex)) { for (auto [direction, mappings] : controllerStick->GetAllAxisDirectionMappings()) { bool foundMapping = false; for (auto [id, mapping] : mappings) { - if (mapping->GetShipDeviceType() == lusIndex) { + if (mapping->GetPhysicalDeviceType() == lusIndex) { foundMapping = true; lusDeviceIndiciesWithMappings.push_back( - std::pair(lusIndex, mapping->PhysicalDeviceIsConnected())); + std::pair(lusIndex, mapping->PhysicalDeviceIsConnected())); break; } } @@ -1331,7 +1331,7 @@ void SohInputEditorWindow::DrawAnalogStickDeviceIcons(uint8_t portIndex, Ship::S ImGui::PushStyleColor(ImGuiCol_Button, buttonColor); ImGui::PushStyleColor(ImGuiCol_ButtonHovered, buttonHoveredColor); ImGui::SameLine(); - if (lusIndex == Ship::ShipDeviceType::Keyboard) { + if (lusIndex == Ship::PhysicalDeviceType::Keyboard) { ImGui::SmallButton(ICON_FA_KEYBOARD_O); } else { ImGui::SmallButton(connected ? ICON_FA_GAMEPAD : ICON_FA_CHAIN_BROKEN); @@ -1342,7 +1342,7 @@ void SohInputEditorWindow::DrawAnalogStickDeviceIcons(uint8_t portIndex, Ship::S } void SohInputEditorWindow::DrawRumbleDeviceIcons(uint8_t portIndex) { - std::set allLusDeviceIndices; + std::set allLusDeviceIndices; for (auto [lusIndex, mapping] : Ship::Context::GetInstance() ->GetControlDeck() ->GetDeviceIndexMappingManager() @@ -1350,21 +1350,21 @@ void SohInputEditorWindow::DrawRumbleDeviceIcons(uint8_t portIndex) { allLusDeviceIndices.insert(lusIndex); } - std::vector> lusDeviceIndiciesWithMappings; + std::vector> lusDeviceIndiciesWithMappings; for (auto lusIndex : allLusDeviceIndices) { if (Ship::Context::GetInstance() ->GetControlDeck() ->GetControllerByPort(portIndex) ->GetRumble() - ->HasMappingsForShipDeviceType(lusIndex)) { + ->HasMappingsForPhysicalDeviceType(lusIndex)) { for (auto [id, mapping] : Ship::Context::GetInstance() ->GetControlDeck() ->GetControllerByPort(portIndex) ->GetRumble() ->GetAllRumbleMappings()) { - if (mapping->GetShipDeviceType() == lusIndex) { + if (mapping->GetPhysicalDeviceType() == lusIndex) { lusDeviceIndiciesWithMappings.push_back( - std::pair(lusIndex, mapping->PhysicalDeviceIsConnected())); + std::pair(lusIndex, mapping->PhysicalDeviceIsConnected())); break; } } @@ -1393,7 +1393,7 @@ void SohInputEditorWindow::DrawGyroDeviceIcons(uint8_t portIndex) { auto buttonColor = ImGui::GetStyleColorVec4(ImGuiCol_Button); auto buttonHoveredColor = ImGui::GetStyleColorVec4(ImGuiCol_ButtonHovered); - GetButtonColorsForLUSDeviceIndex(mapping->GetShipDeviceType(), buttonColor, buttonHoveredColor); + GetButtonColorsForLUSDeviceIndex(mapping->GetPhysicalDeviceType(), buttonColor, buttonHoveredColor); ImGui::PushStyleColor(ImGuiCol_Button, buttonColor); ImGui::PushStyleColor(ImGuiCol_ButtonHovered, buttonHoveredColor); ImGui::SameLine(); @@ -1403,7 +1403,7 @@ void SohInputEditorWindow::DrawGyroDeviceIcons(uint8_t portIndex) { } void SohInputEditorWindow::DrawLEDDeviceIcons(uint8_t portIndex) { - std::set allLusDeviceIndices; + std::set allLusDeviceIndices; for (auto [lusIndex, mapping] : Ship::Context::GetInstance() ->GetControlDeck() ->GetDeviceIndexMappingManager() @@ -1411,21 +1411,21 @@ void SohInputEditorWindow::DrawLEDDeviceIcons(uint8_t portIndex) { allLusDeviceIndices.insert(lusIndex); } - std::vector> lusDeviceIndiciesWithMappings; + std::vector> lusDeviceIndiciesWithMappings; for (auto lusIndex : allLusDeviceIndices) { if (Ship::Context::GetInstance() ->GetControlDeck() ->GetControllerByPort(portIndex) ->GetLED() - ->HasMappingsForShipDeviceType(lusIndex)) { + ->HasMappingsForPhysicalDeviceType(lusIndex)) { for (auto [id, mapping] : Ship::Context::GetInstance() ->GetControlDeck() ->GetControllerByPort(portIndex) ->GetLED() ->GetAllLEDMappings()) { - if (mapping->GetShipDeviceType() == lusIndex) { + if (mapping->GetPhysicalDeviceType() == lusIndex) { lusDeviceIndiciesWithMappings.push_back( - std::pair(lusIndex, mapping->PhysicalDeviceIsConnected())); + std::pair(lusIndex, mapping->PhysicalDeviceIsConnected())); break; } } @@ -1638,7 +1638,7 @@ void SohInputEditorWindow::DrawDpadControlPanel() { } void SohInputEditorWindow::DrawDeviceVisibilityButtons() { - std::map> indexMappings; + std::map> indexMappings; for (auto [lusIndex, mapping] : Ship::Context::GetInstance() ->GetControlDeck() ->GetDeviceIndexMappingManager() @@ -1665,14 +1665,14 @@ void SohInputEditorWindow::DrawDeviceVisibilityButtons() { auto keyboardButtonColor = ImGui::GetStyleColorVec4(ImGuiCol_Button); auto keyboardButtonHoveredColor = ImGui::GetStyleColorVec4(ImGuiCol_ButtonHovered); - GetButtonColorsForLUSDeviceIndex(Ship::ShipDeviceType::Keyboard, keyboardButtonColor, keyboardButtonHoveredColor); + GetButtonColorsForLUSDeviceIndex(Ship::PhysicalDeviceType::Keyboard, keyboardButtonColor, keyboardButtonHoveredColor); ImGui::PushStyleColor(ImGuiCol_Button, keyboardButtonColor); ImGui::PushStyleColor(ImGuiCol_ButtonHovered, keyboardButtonHoveredColor); - bool keyboardVisible = mDeviceIndexVisibility[Ship::ShipDeviceType::Keyboard]; + bool keyboardVisible = mDeviceIndexVisibility[Ship::PhysicalDeviceType::Keyboard]; if(ImGui::Button( StringHelper::Sprintf("%s %s Keyboard", keyboardVisible ? ICON_FA_EYE : ICON_FA_EYE_SLASH, ICON_FA_KEYBOARD_O) .c_str())) { - mDeviceIndexVisibility[Ship::ShipDeviceType::Keyboard] = !keyboardVisible; + mDeviceIndexVisibility[Ship::PhysicalDeviceType::Keyboard] = !keyboardVisible; } ImGui::PopStyleColor(); ImGui::PopStyleColor(); @@ -1996,7 +1996,7 @@ void SohInputEditorWindow::DrawSetDefaultsButton(uint8_t portIndex) { } if (ImGui::BeginPopup(popupId.c_str())) { - std::map> indexMappings; + std::map> indexMappings; for (auto [lusIndex, mapping] : Ship::Context::GetInstance() ->GetControlDeck() ->GetDeviceIndexMappingManager() @@ -2027,9 +2027,9 @@ void SohInputEditorWindow::DrawSetDefaultsButton(uint8_t portIndex) { Ship::Context::GetInstance() ->GetControlDeck() ->GetControllerByPort(portIndex) - ->ClearAllMappingsForDeviceType(Ship::ShipDeviceType::Keyboard); + ->ClearAllMappingsForDeviceType(Ship::PhysicalDeviceType::Keyboard); Ship::Context::GetInstance()->GetControlDeck()->GetControllerByPort(portIndex)->AddDefaultMappings( - Ship::ShipDeviceType::Keyboard); + Ship::PhysicalDeviceType::Keyboard); shouldClose = true; ImGui::CloseCurrentPopup(); } diff --git a/soh/soh/Enhancements/controls/SohInputEditorWindow.h b/soh/soh/Enhancements/controls/SohInputEditorWindow.h index 8aaaa3a212..c4387d2219 100644 --- a/soh/soh/Enhancements/controls/SohInputEditorWindow.h +++ b/soh/soh/Enhancements/controls/SohInputEditorWindow.h @@ -83,7 +83,7 @@ class SohInputEditorWindow : public Ship::GuiWindow { void UpdateBitmaskToMappingIds(uint8_t port); void UpdateStickDirectionToMappingIds(uint8_t port); - void GetButtonColorsForLUSDeviceIndex(Ship::ShipDeviceType lusIndex, ImVec4& buttonColor, + void GetButtonColorsForLUSDeviceIndex(Ship::PhysicalDeviceType lusIndex, ImVec4& buttonColor, ImVec4& buttonHoveredColor); void DrawLinkTab(); void DrawIvanTab(); @@ -101,6 +101,6 @@ class SohInputEditorWindow : public Ship::GuiWindow { void DrawSetDefaultsButton(uint8_t portIndex); void DrawClearAllButton(uint8_t portIndex); - std::map mDeviceIndexVisibility; + std::map mDeviceIndexVisibility; void DrawDeviceVisibilityButtons(); }; From 007f9bb8c629e9766177c6f3702bd7c56fa57993 Mon Sep 17 00:00:00 2001 From: briaguya <70942617+briaguya-ai@users.noreply.github.com> Date: Sun, 19 Jan 2025 10:20:46 -0500 Subject: [PATCH 05/22] `ConnectedPhysicalDeviceManager` --- libultraship | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libultraship b/libultraship index e7d28a574a..7f0f02d17f 160000 --- a/libultraship +++ b/libultraship @@ -1 +1 @@ -Subproject commit e7d28a574a76eefd7f911d7ce0966530c4bfbb13 +Subproject commit 7f0f02d17fe41109777e684801f788b57d0045ed From 07e687fcee99d5d469469186b12b74613c0a9e74 Mon Sep 17 00:00:00 2001 From: briaguya <70942617+briaguya-ai@users.noreply.github.com> Date: Sun, 19 Jan 2025 11:20:18 -0500 Subject: [PATCH 06/22] start to not need index mapping manager --- libultraship | 2 +- soh/soh/Enhancements/controls/SohInputEditorWindow.cpp | 10 +++++----- soh/soh/OTRGlobals.cpp | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/libultraship b/libultraship index 7f0f02d17f..9be3448b4c 160000 --- a/libultraship +++ b/libultraship @@ -1 +1 @@ -Subproject commit 7f0f02d17fe41109777e684801f788b57d0045ed +Subproject commit 9be3448b4c540ea87ce331e21989af5307db74b8 diff --git a/soh/soh/Enhancements/controls/SohInputEditorWindow.cpp b/soh/soh/Enhancements/controls/SohInputEditorWindow.cpp index 8cd6d4dc0b..1243ff6784 100644 --- a/soh/soh/Enhancements/controls/SohInputEditorWindow.cpp +++ b/soh/soh/Enhancements/controls/SohInputEditorWindow.cpp @@ -1264,7 +1264,7 @@ void SohInputEditorWindow::DrawButtonDeviceIcons(uint8_t portIndex, std::setGetAllButtonMappings()) { if (mapping->GetPhysicalDeviceType() == lusIndex) { lusDeviceIndiciesWithMappings.push_back( - std::pair(lusIndex, mapping->PhysicalDeviceIsConnected())); + std::pair(lusIndex, true)); break; } } @@ -1313,7 +1313,7 @@ void SohInputEditorWindow::DrawAnalogStickDeviceIcons(uint8_t portIndex, Ship::S if (mapping->GetPhysicalDeviceType() == lusIndex) { foundMapping = true; lusDeviceIndiciesWithMappings.push_back( - std::pair(lusIndex, mapping->PhysicalDeviceIsConnected())); + std::pair(lusIndex, true)); break; } } @@ -1364,7 +1364,7 @@ void SohInputEditorWindow::DrawRumbleDeviceIcons(uint8_t portIndex) { ->GetAllRumbleMappings()) { if (mapping->GetPhysicalDeviceType() == lusIndex) { lusDeviceIndiciesWithMappings.push_back( - std::pair(lusIndex, mapping->PhysicalDeviceIsConnected())); + std::pair(lusIndex, true)); break; } } @@ -1397,7 +1397,7 @@ void SohInputEditorWindow::DrawGyroDeviceIcons(uint8_t portIndex) { ImGui::PushStyleColor(ImGuiCol_Button, buttonColor); ImGui::PushStyleColor(ImGuiCol_ButtonHovered, buttonHoveredColor); ImGui::SameLine(); - ImGui::SmallButton(mapping->PhysicalDeviceIsConnected() ? ICON_FA_GAMEPAD : ICON_FA_CHAIN_BROKEN); + ImGui::SmallButton(true ? ICON_FA_GAMEPAD : ICON_FA_CHAIN_BROKEN); ImGui::PopStyleColor(); ImGui::PopStyleColor(); } @@ -1425,7 +1425,7 @@ void SohInputEditorWindow::DrawLEDDeviceIcons(uint8_t portIndex) { ->GetAllLEDMappings()) { if (mapping->GetPhysicalDeviceType() == lusIndex) { lusDeviceIndiciesWithMappings.push_back( - std::pair(lusIndex, mapping->PhysicalDeviceIsConnected())); + std::pair(lusIndex, true)); break; } } diff --git a/soh/soh/OTRGlobals.cpp b/soh/soh/OTRGlobals.cpp index 3cf63f18ba..6d3d22fc9a 100644 --- a/soh/soh/OTRGlobals.cpp +++ b/soh/soh/OTRGlobals.cpp @@ -1841,7 +1841,7 @@ extern "C" int Controller_ShouldRumble(size_t slot) { ->GetControllerByPort(static_cast(slot)) ->GetRumble() ->GetAllRumbleMappings()) { - if (mapping->PhysicalDeviceIsConnected()) { + if (true) { return 1; } } From fd4f7c156127f93123da1ec87cdce207d480d466 Mon Sep 17 00:00:00 2001 From: briaguya <70942617+briaguya-ai@users.noreply.github.com> Date: Sun, 19 Jan 2025 11:33:30 -0500 Subject: [PATCH 07/22] somes fixes and stuff --- libultraship | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libultraship b/libultraship index 9be3448b4c..7c269f38fe 160000 --- a/libultraship +++ b/libultraship @@ -1 +1 @@ -Subproject commit 9be3448b4c540ea87ce331e21989af5307db74b8 +Subproject commit 7c269f38fedce48c7248a5dcf1743d671a1bd89e From a890d7308a535a9d7abf277d8a5823228add657d Mon Sep 17 00:00:00 2001 From: briaguya <70942617+briaguya-ai@users.noreply.github.com> Date: Sun, 19 Jan 2025 11:47:02 -0500 Subject: [PATCH 08/22] remove more shipdeviceindex stuff --- libultraship | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libultraship b/libultraship index 7c269f38fe..923239c248 160000 --- a/libultraship +++ b/libultraship @@ -1 +1 @@ -Subproject commit 7c269f38fedce48c7248a5dcf1743d671a1bd89e +Subproject commit 923239c248c28d5b4a47bf1dececa302811a8092 From 89613cd2bb04157083ea3e0f6280774def241830 Mon Sep 17 00:00:00 2001 From: briaguya <70942617+briaguya-ai@users.noreply.github.com> Date: Sun, 19 Jan 2025 11:59:24 -0500 Subject: [PATCH 09/22] more removing and what not --- libultraship | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libultraship b/libultraship index 923239c248..e5babe3d66 160000 --- a/libultraship +++ b/libultraship @@ -1 +1 @@ -Subproject commit 923239c248c28d5b4a47bf1dececa302811a8092 +Subproject commit e5babe3d66e4898f11e05ec058a7ebb801d91a25 From 4f4ce6bddbf3a5c4e71a4c35c93cca6128c48c4b Mon Sep 17 00:00:00 2001 From: briaguya <70942617+briaguya-ai@users.noreply.github.com> Date: Sun, 19 Jan 2025 13:31:44 -0500 Subject: [PATCH 10/22] axis thresholds --- libultraship | 2 +- .../controls/SohInputEditorWindow.cpp | 40 ++++++++----------- 2 files changed, 18 insertions(+), 24 deletions(-) diff --git a/libultraship b/libultraship index e5babe3d66..5dba443030 160000 --- a/libultraship +++ b/libultraship @@ -1 +1 @@ -Subproject commit e5babe3d66e4898f11e05ec058a7ebb801d91a25 +Subproject commit 5dba443030e7171d20fa841ab726169b40bf8b34 diff --git a/soh/soh/Enhancements/controls/SohInputEditorWindow.cpp b/soh/soh/Enhancements/controls/SohInputEditorWindow.cpp index 1243ff6784..40eb788dc4 100644 --- a/soh/soh/Enhancements/controls/SohInputEditorWindow.cpp +++ b/soh/soh/Enhancements/controls/SohInputEditorWindow.cpp @@ -310,15 +310,8 @@ void SohInputEditorWindow::DrawButtonLineEditMappingButton(uint8_t port, N64Butt ImGui::PopStyleVar(); ImGui::SameLine(0, 0); -#ifndef __WIIU__ auto sdlAxisDirectionToButtonMapping = std::dynamic_pointer_cast(mapping); - auto indexMapping = Ship::Context::GetInstance() - ->GetControlDeck() - ->GetDeviceIndexMappingManager() - ->GetDeviceIndexMappingFromShipDeviceIndex(mapping->GetPhysicalDeviceType()); - auto sdlIndexMapping = std::dynamic_pointer_cast(indexMapping); - - if (sdlIndexMapping != nullptr && sdlAxisDirectionToButtonMapping != nullptr) { + if (sdlAxisDirectionToButtonMapping != nullptr) { ImGui::PushStyleVar(ImGuiStyleVar_ButtonTextAlign, ImVec2(0.0f, 0.5f)); auto buttonColor = ImGui::GetStyleColorVec4(ImGuiCol_Button); auto buttonHoveredColor = ImGui::GetStyleColorVec4(ImGuiCol_ButtonHovered); @@ -343,17 +336,19 @@ void SohInputEditorWindow::DrawButtonLineEditMappingButton(uint8_t port, N64Butt ImGui::Text("Axis Threshold\n\nThe extent to which the joystick\nmust be moved or the trigger\npressed to " "initiate the assigned\nbutton action.\n\n"); + auto globalSettings = Ship::Context::GetInstance()->GetControlDeck()->GetGlobalSDLDeviceSettings(); + if (sdlAxisDirectionToButtonMapping->AxisIsStick()) { ImGui::Text("Stick axis threshold:"); - int32_t stickAxisThreshold = sdlIndexMapping->GetStickAxisThresholdPercentage(); + int32_t stickAxisThreshold = globalSettings->GetStickAxisThresholdPercentage(); if (stickAxisThreshold == 0) { ImGui::BeginDisabled(); } ImGui::PushButtonRepeat(true); if (ImGui::Button(StringHelper::Sprintf("-##Stick Axis Threshold%s", id.c_str()).c_str())) { - sdlIndexMapping->SetStickAxisThresholdPercentage(stickAxisThreshold - 1); - sdlIndexMapping->SaveToConfig(); + globalSettings->SetStickAxisThresholdPercentage(stickAxisThreshold - 1); + globalSettings->SaveToConfig(); } ImGui::PopButtonRepeat(); if (stickAxisThreshold == 0) { @@ -363,8 +358,8 @@ void SohInputEditorWindow::DrawButtonLineEditMappingButton(uint8_t port, N64Butt ImGui::SetNextItemWidth(SCALE_IMGUI_SIZE(160.0f)); if (ImGui::SliderInt(StringHelper::Sprintf("##Stick Axis Threshold%s", id.c_str()).c_str(), &stickAxisThreshold, 0, 100, "%d%%", ImGuiSliderFlags_AlwaysClamp)) { - sdlIndexMapping->SetStickAxisThresholdPercentage(stickAxisThreshold); - sdlIndexMapping->SaveToConfig(); + globalSettings->SetStickAxisThresholdPercentage(stickAxisThreshold); + globalSettings->SaveToConfig(); } ImGui::SameLine(0.0f, 0.0f); if (stickAxisThreshold == 100) { @@ -372,8 +367,8 @@ void SohInputEditorWindow::DrawButtonLineEditMappingButton(uint8_t port, N64Butt } ImGui::PushButtonRepeat(true); if (ImGui::Button(StringHelper::Sprintf("+##Stick Axis Threshold%s", id.c_str()).c_str())) { - sdlIndexMapping->SetStickAxisThresholdPercentage(stickAxisThreshold + 1); - sdlIndexMapping->SaveToConfig(); + globalSettings->SetStickAxisThresholdPercentage(stickAxisThreshold + 1); + globalSettings->SaveToConfig(); } ImGui::PopButtonRepeat(); if (stickAxisThreshold == 100) { @@ -384,14 +379,14 @@ void SohInputEditorWindow::DrawButtonLineEditMappingButton(uint8_t port, N64Butt if (sdlAxisDirectionToButtonMapping->AxisIsTrigger()) { ImGui::Text("Trigger axis threshold:"); - int32_t triggerAxisThreshold = sdlIndexMapping->GetTriggerAxisThresholdPercentage(); + int32_t triggerAxisThreshold = globalSettings->GetTriggerAxisThresholdPercentage(); if (triggerAxisThreshold == 0) { ImGui::BeginDisabled(); } ImGui::PushButtonRepeat(true); if (ImGui::Button(StringHelper::Sprintf("-##Trigger Axis Threshold%s", id.c_str()).c_str())) { - sdlIndexMapping->SetTriggerAxisThresholdPercentage(triggerAxisThreshold - 1); - sdlIndexMapping->SaveToConfig(); + globalSettings->SetTriggerAxisThresholdPercentage(triggerAxisThreshold - 1); + globalSettings->SaveToConfig(); } ImGui::PopButtonRepeat(); if (triggerAxisThreshold == 0) { @@ -401,8 +396,8 @@ void SohInputEditorWindow::DrawButtonLineEditMappingButton(uint8_t port, N64Butt ImGui::SetNextItemWidth(SCALE_IMGUI_SIZE(160.0f)); if (ImGui::SliderInt(StringHelper::Sprintf("##Trigger Axis Threshold%s", id.c_str()).c_str(), &triggerAxisThreshold, 0, 100, "%d%%", ImGuiSliderFlags_AlwaysClamp)) { - sdlIndexMapping->SetTriggerAxisThresholdPercentage(triggerAxisThreshold); - sdlIndexMapping->SaveToConfig(); + globalSettings->SetTriggerAxisThresholdPercentage(triggerAxisThreshold); + globalSettings->SaveToConfig(); } ImGui::SameLine(0.0f, 0.0f); if (triggerAxisThreshold == 100) { @@ -410,8 +405,8 @@ void SohInputEditorWindow::DrawButtonLineEditMappingButton(uint8_t port, N64Butt } ImGui::PushButtonRepeat(true); if (ImGui::Button(StringHelper::Sprintf("+##Trigger Axis Threshold%s", id.c_str()).c_str())) { - sdlIndexMapping->SetTriggerAxisThresholdPercentage(triggerAxisThreshold + 1); - sdlIndexMapping->SaveToConfig(); + globalSettings->SetTriggerAxisThresholdPercentage(triggerAxisThreshold + 1); + globalSettings->SaveToConfig(); } ImGui::PopButtonRepeat(); if (triggerAxisThreshold == 100) { @@ -430,7 +425,6 @@ void SohInputEditorWindow::DrawButtonLineEditMappingButton(uint8_t port, N64Butt ImGui::PopStyleVar(); ImGui::SameLine(0, 0); } -#endif ImGui::PushStyleColor(ImGuiCol_Button, buttonColor); ImGui::PushStyleColor(ImGuiCol_ButtonHovered, buttonHoveredColor); From e3fd7ed01a2020c6f67cc1fa995dedae1b32c750 Mon Sep 17 00:00:00 2001 From: briaguya <70942617+briaguya-ai@users.noreply.github.com> Date: Sun, 19 Jan 2025 14:02:50 -0500 Subject: [PATCH 11/22] rename some stuff and remove device icons --- .../controls/SohInputEditorWindow.cpp | 355 +++--------------- .../controls/SohInputEditorWindow.h | 9 +- 2 files changed, 45 insertions(+), 319 deletions(-) diff --git a/soh/soh/Enhancements/controls/SohInputEditorWindow.cpp b/soh/soh/Enhancements/controls/SohInputEditorWindow.cpp index 40eb788dc4..e88c271269 100644 --- a/soh/soh/Enhancements/controls/SohInputEditorWindow.cpp +++ b/soh/soh/Enhancements/controls/SohInputEditorWindow.cpp @@ -47,10 +47,10 @@ void SohInputEditorWindow::InitElement() { addButtonName(BTN_DRIGHT, "D-pad right"); addButtonName(0, "None"); - mDeviceIndexVisibility.clear(); - mDeviceIndexVisibility[Ship::PhysicalDeviceType::Keyboard] = true; - mDeviceIndexVisibility[Ship::PhysicalDeviceType::SDLGamepad] = true; - mDeviceIndexVisibility[Ship::PhysicalDeviceType::Max] = false; + mDeviceTypeVisibility.clear(); + mDeviceTypeVisibility[Ship::PhysicalDeviceType::Keyboard] = true; + mDeviceTypeVisibility[Ship::PhysicalDeviceType::SDLGamepad] = true; + mDeviceTypeVisibility[Ship::PhysicalDeviceType::Max] = false; } #define INPUT_EDITOR_WINDOW_GAME_INPUT_BLOCK_ID 95237929 @@ -189,7 +189,7 @@ void SohInputEditorWindow::DrawAnalogPreview(const char* label, ImVec2 stick, fl #define BUTTON_COLOR_GAMEPAD_PURPLE ImVec4(0.431f, 0.369f, 0.706f, 0.5f) #define BUTTON_COLOR_GAMEPAD_PURPLE_HOVERED ImVec4(0.431f, 0.369f, 0.706f, 1.0f) -void SohInputEditorWindow::GetButtonColorsForLUSDeviceIndex(Ship::PhysicalDeviceType lusIndex, ImVec4& buttonColor, +void SohInputEditorWindow::GetButtonColorsForDeviceType(Ship::PhysicalDeviceType lusIndex, ImVec4& buttonColor, ImVec4& buttonHoveredColor) { switch (lusIndex) { case Ship::PhysicalDeviceType::Keyboard: @@ -252,7 +252,7 @@ void SohInputEditorWindow::DrawButtonLineEditMappingButton(uint8_t port, N64Butt if (mapping == nullptr) { return; } - if (!mDeviceIndexVisibility[mapping->GetPhysicalDeviceType()]) { + if (!mDeviceTypeVisibility[mapping->GetPhysicalDeviceType()]) { return; } @@ -273,7 +273,7 @@ void SohInputEditorWindow::DrawButtonLineEditMappingButton(uint8_t port, N64Butt auto buttonHoveredColor = ImGui::GetStyleColorVec4(ImGuiCol_ButtonHovered); auto physicalInputDisplayName = StringHelper::Sprintf("%s %s", icon.c_str(), mapping->GetPhysicalInputName().c_str()); - GetButtonColorsForLUSDeviceIndex(mapping->GetPhysicalDeviceType(), buttonColor, buttonHoveredColor); + GetButtonColorsForDeviceType(mapping->GetPhysicalDeviceType(), buttonColor, buttonHoveredColor); ImGui::PushStyleColor(ImGuiCol_Button, buttonColor); ImGui::PushStyleColor(ImGuiCol_ButtonHovered, buttonHoveredColor); auto popupId = StringHelper::Sprintf("editButtonMappingPopup##%s", id.c_str()); @@ -315,7 +315,7 @@ void SohInputEditorWindow::DrawButtonLineEditMappingButton(uint8_t port, N64Butt ImGui::PushStyleVar(ImGuiStyleVar_ButtonTextAlign, ImVec2(0.0f, 0.5f)); auto buttonColor = ImGui::GetStyleColorVec4(ImGuiCol_Button); auto buttonHoveredColor = ImGui::GetStyleColorVec4(ImGuiCol_ButtonHovered); - GetButtonColorsForLUSDeviceIndex(mapping->GetPhysicalDeviceType(), buttonColor, buttonHoveredColor); + GetButtonColorsForDeviceType(mapping->GetPhysicalDeviceType(), buttonColor, buttonHoveredColor); ImGui::PushStyleColor(ImGuiCol_Button, buttonColor); ImGui::PushStyleColor(ImGuiCol_ButtonHovered, buttonHoveredColor); ImGui::PushStyleVar(ImGuiStyleVar_ButtonTextAlign, ImVec2(1.0f, 0.5f)); @@ -519,7 +519,7 @@ void SohInputEditorWindow::DrawStickDirectionLineEditMappingButton(uint8_t port, if (mapping == nullptr) { return; } - if (!mDeviceIndexVisibility[mapping->GetPhysicalDeviceType()]) { + if (!mDeviceTypeVisibility[mapping->GetPhysicalDeviceType()]) { return; } @@ -540,7 +540,7 @@ void SohInputEditorWindow::DrawStickDirectionLineEditMappingButton(uint8_t port, auto buttonHoveredColor = ImGui::GetStyleColorVec4(ImGuiCol_ButtonHovered); auto physicalInputDisplayName = StringHelper::Sprintf("%s %s", icon.c_str(), mapping->GetPhysicalInputName().c_str()); - GetButtonColorsForLUSDeviceIndex(mapping->GetPhysicalDeviceType(), buttonColor, buttonHoveredColor); + GetButtonColorsForDeviceType(mapping->GetPhysicalDeviceType(), buttonColor, buttonHoveredColor); ImGui::PushStyleColor(ImGuiCol_Button, buttonColor); ImGui::PushStyleColor(ImGuiCol_ButtonHovered, buttonHoveredColor); auto popupId = StringHelper::Sprintf("editStickDirectionMappingPopup##%s", id.c_str()); @@ -865,7 +865,7 @@ void SohInputEditorWindow::DrawRumbleSection(uint8_t port) { ImGui::SetNextItemOpen(true, ImGuiCond_Once); auto buttonColor = ImGui::GetStyleColorVec4(ImGuiCol_Button); auto buttonHoveredColor = ImGui::GetStyleColorVec4(ImGuiCol_ButtonHovered); - GetButtonColorsForLUSDeviceIndex(mapping->GetPhysicalDeviceType(), buttonColor, buttonHoveredColor); + GetButtonColorsForDeviceType(mapping->GetPhysicalDeviceType(), buttonColor, buttonHoveredColor); // begin hackaround https://github.com/ocornut/imgui/issues/282#issuecomment-123763192 // spaces to have background color for text in a tree node std::string spaces = ""; @@ -1236,209 +1236,6 @@ void SohInputEditorWindow::DrawGyroSection(uint8_t port) { } } -void SohInputEditorWindow::DrawButtonDeviceIcons(uint8_t portIndex, std::set bitmasks) { - std::set allLusDeviceIndices; - allLusDeviceIndices.insert(Ship::PhysicalDeviceType::Keyboard); - for (auto [lusIndex, mapping] : Ship::Context::GetInstance() - ->GetControlDeck() - ->GetDeviceIndexMappingManager() - ->GetAllDeviceIndexMappingsFromConfig()) { - allLusDeviceIndices.insert(lusIndex); - } - - std::vector> lusDeviceIndiciesWithMappings; - for (auto lusIndex : allLusDeviceIndices) { - for (auto [bitmask, button] : - Ship::Context::GetInstance()->GetControlDeck()->GetControllerByPort(portIndex)->GetAllButtons()) { - if (!bitmasks.contains(bitmask)) { - continue; - } - - if (button->HasMappingsForPhysicalDeviceType(lusIndex)) { - for (auto [id, mapping] : button->GetAllButtonMappings()) { - if (mapping->GetPhysicalDeviceType() == lusIndex) { - lusDeviceIndiciesWithMappings.push_back( - std::pair(lusIndex, true)); - break; - } - } - break; - } - } - } - - for (auto [lusIndex, connected] : lusDeviceIndiciesWithMappings) { - auto buttonColor = ImGui::GetStyleColorVec4(ImGuiCol_Button); - auto buttonHoveredColor = ImGui::GetStyleColorVec4(ImGuiCol_ButtonHovered); - GetButtonColorsForLUSDeviceIndex(lusIndex, buttonColor, buttonHoveredColor); - ImGui::PushStyleColor(ImGuiCol_Button, buttonColor); - ImGui::PushStyleColor(ImGuiCol_ButtonHovered, buttonHoveredColor); - ImGui::SameLine(); - if (lusIndex == Ship::PhysicalDeviceType::Keyboard) { - ImGui::SmallButton(ICON_FA_KEYBOARD_O); - } else { - ImGui::SmallButton(connected ? ICON_FA_GAMEPAD : ICON_FA_CHAIN_BROKEN); - } - ImGui::PopStyleColor(); - ImGui::PopStyleColor(); - } -} - -void SohInputEditorWindow::DrawAnalogStickDeviceIcons(uint8_t portIndex, Ship::StickIndex stickIndex) { - std::set allLusDeviceIndices; - allLusDeviceIndices.insert(Ship::PhysicalDeviceType::Keyboard); - for (auto [lusIndex, mapping] : Ship::Context::GetInstance() - ->GetControlDeck() - ->GetDeviceIndexMappingManager() - ->GetAllDeviceIndexMappingsFromConfig()) { - allLusDeviceIndices.insert(lusIndex); - } - - std::vector> lusDeviceIndiciesWithMappings; - for (auto lusIndex : allLusDeviceIndices) { - auto controllerStick = - stickIndex == Ship::StickIndex::LEFT_STICK - ? Ship::Context::GetInstance()->GetControlDeck()->GetControllerByPort(portIndex)->GetLeftStick() - : Ship::Context::GetInstance()->GetControlDeck()->GetControllerByPort(portIndex)->GetRightStick(); - if (controllerStick->HasMappingsForPhysicalDeviceType(lusIndex)) { - for (auto [direction, mappings] : controllerStick->GetAllAxisDirectionMappings()) { - bool foundMapping = false; - for (auto [id, mapping] : mappings) { - if (mapping->GetPhysicalDeviceType() == lusIndex) { - foundMapping = true; - lusDeviceIndiciesWithMappings.push_back( - std::pair(lusIndex, true)); - break; - } - } - if (foundMapping) { - break; - } - } - } - } - - for (auto [lusIndex, connected] : lusDeviceIndiciesWithMappings) { - auto buttonColor = ImGui::GetStyleColorVec4(ImGuiCol_Button); - auto buttonHoveredColor = ImGui::GetStyleColorVec4(ImGuiCol_ButtonHovered); - GetButtonColorsForLUSDeviceIndex(lusIndex, buttonColor, buttonHoveredColor); - ImGui::PushStyleColor(ImGuiCol_Button, buttonColor); - ImGui::PushStyleColor(ImGuiCol_ButtonHovered, buttonHoveredColor); - ImGui::SameLine(); - if (lusIndex == Ship::PhysicalDeviceType::Keyboard) { - ImGui::SmallButton(ICON_FA_KEYBOARD_O); - } else { - ImGui::SmallButton(connected ? ICON_FA_GAMEPAD : ICON_FA_CHAIN_BROKEN); - } - ImGui::PopStyleColor(); - ImGui::PopStyleColor(); - } -} - -void SohInputEditorWindow::DrawRumbleDeviceIcons(uint8_t portIndex) { - std::set allLusDeviceIndices; - for (auto [lusIndex, mapping] : Ship::Context::GetInstance() - ->GetControlDeck() - ->GetDeviceIndexMappingManager() - ->GetAllDeviceIndexMappingsFromConfig()) { - allLusDeviceIndices.insert(lusIndex); - } - - std::vector> lusDeviceIndiciesWithMappings; - for (auto lusIndex : allLusDeviceIndices) { - if (Ship::Context::GetInstance() - ->GetControlDeck() - ->GetControllerByPort(portIndex) - ->GetRumble() - ->HasMappingsForPhysicalDeviceType(lusIndex)) { - for (auto [id, mapping] : Ship::Context::GetInstance() - ->GetControlDeck() - ->GetControllerByPort(portIndex) - ->GetRumble() - ->GetAllRumbleMappings()) { - if (mapping->GetPhysicalDeviceType() == lusIndex) { - lusDeviceIndiciesWithMappings.push_back( - std::pair(lusIndex, true)); - break; - } - } - } - } - - for (auto [lusIndex, connected] : lusDeviceIndiciesWithMappings) { - auto buttonColor = ImGui::GetStyleColorVec4(ImGuiCol_Button); - auto buttonHoveredColor = ImGui::GetStyleColorVec4(ImGuiCol_ButtonHovered); - GetButtonColorsForLUSDeviceIndex(lusIndex, buttonColor, buttonHoveredColor); - ImGui::PushStyleColor(ImGuiCol_Button, buttonColor); - ImGui::PushStyleColor(ImGuiCol_ButtonHovered, buttonHoveredColor); - ImGui::SameLine(); - ImGui::SmallButton(connected ? ICON_FA_GAMEPAD : ICON_FA_CHAIN_BROKEN); - ImGui::PopStyleColor(); - ImGui::PopStyleColor(); - } -} - -void SohInputEditorWindow::DrawGyroDeviceIcons(uint8_t portIndex) { - auto mapping = - Ship::Context::GetInstance()->GetControlDeck()->GetControllerByPort(portIndex)->GetGyro()->GetGyroMapping(); - if (mapping == nullptr) { - return; - } - - auto buttonColor = ImGui::GetStyleColorVec4(ImGuiCol_Button); - auto buttonHoveredColor = ImGui::GetStyleColorVec4(ImGuiCol_ButtonHovered); - GetButtonColorsForLUSDeviceIndex(mapping->GetPhysicalDeviceType(), buttonColor, buttonHoveredColor); - ImGui::PushStyleColor(ImGuiCol_Button, buttonColor); - ImGui::PushStyleColor(ImGuiCol_ButtonHovered, buttonHoveredColor); - ImGui::SameLine(); - ImGui::SmallButton(true ? ICON_FA_GAMEPAD : ICON_FA_CHAIN_BROKEN); - ImGui::PopStyleColor(); - ImGui::PopStyleColor(); -} - -void SohInputEditorWindow::DrawLEDDeviceIcons(uint8_t portIndex) { - std::set allLusDeviceIndices; - for (auto [lusIndex, mapping] : Ship::Context::GetInstance() - ->GetControlDeck() - ->GetDeviceIndexMappingManager() - ->GetAllDeviceIndexMappingsFromConfig()) { - allLusDeviceIndices.insert(lusIndex); - } - - std::vector> lusDeviceIndiciesWithMappings; - for (auto lusIndex : allLusDeviceIndices) { - if (Ship::Context::GetInstance() - ->GetControlDeck() - ->GetControllerByPort(portIndex) - ->GetLED() - ->HasMappingsForPhysicalDeviceType(lusIndex)) { - for (auto [id, mapping] : Ship::Context::GetInstance() - ->GetControlDeck() - ->GetControllerByPort(portIndex) - ->GetLED() - ->GetAllLEDMappings()) { - if (mapping->GetPhysicalDeviceType() == lusIndex) { - lusDeviceIndiciesWithMappings.push_back( - std::pair(lusIndex, true)); - break; - } - } - } - } - - for (auto [lusIndex, connected] : lusDeviceIndiciesWithMappings) { - auto buttonColor = ImGui::GetStyleColorVec4(ImGuiCol_Button); - auto buttonHoveredColor = ImGui::GetStyleColorVec4(ImGuiCol_ButtonHovered); - GetButtonColorsForLUSDeviceIndex(lusIndex, buttonColor, buttonHoveredColor); - ImGui::PushStyleColor(ImGuiCol_Button, buttonColor); - ImGui::PushStyleColor(ImGuiCol_ButtonHovered, buttonHoveredColor); - ImGui::SameLine(); - ImGui::SmallButton(connected ? ICON_FA_GAMEPAD : ICON_FA_CHAIN_BROKEN); - ImGui::PopStyleColor(); - ImGui::PopStyleColor(); - } -} - const ImGuiTableFlags PANEL_TABLE_FLAGS = ImGuiTableFlags_BordersH | ImGuiTableFlags_BordersV; @@ -1659,14 +1456,14 @@ void SohInputEditorWindow::DrawDeviceVisibilityButtons() { auto keyboardButtonColor = ImGui::GetStyleColorVec4(ImGuiCol_Button); auto keyboardButtonHoveredColor = ImGui::GetStyleColorVec4(ImGuiCol_ButtonHovered); - GetButtonColorsForLUSDeviceIndex(Ship::PhysicalDeviceType::Keyboard, keyboardButtonColor, keyboardButtonHoveredColor); + GetButtonColorsForDeviceType(Ship::PhysicalDeviceType::Keyboard, keyboardButtonColor, keyboardButtonHoveredColor); ImGui::PushStyleColor(ImGuiCol_Button, keyboardButtonColor); ImGui::PushStyleColor(ImGuiCol_ButtonHovered, keyboardButtonHoveredColor); - bool keyboardVisible = mDeviceIndexVisibility[Ship::PhysicalDeviceType::Keyboard]; + bool keyboardVisible = mDeviceTypeVisibility[Ship::PhysicalDeviceType::Keyboard]; if(ImGui::Button( StringHelper::Sprintf("%s %s Keyboard", keyboardVisible ? ICON_FA_EYE : ICON_FA_EYE_SLASH, ICON_FA_KEYBOARD_O) .c_str())) { - mDeviceIndexVisibility[Ship::PhysicalDeviceType::Keyboard] = !keyboardVisible; + mDeviceTypeVisibility[Ship::PhysicalDeviceType::Keyboard] = !keyboardVisible; } ImGui::PopStyleColor(); ImGui::PopStyleColor(); @@ -1678,16 +1475,16 @@ void SohInputEditorWindow::DrawDeviceVisibilityButtons() { auto buttonColor = ImGui::GetStyleColorVec4(ImGuiCol_Button); auto buttonHoveredColor = ImGui::GetStyleColorVec4(ImGuiCol_ButtonHovered); - GetButtonColorsForLUSDeviceIndex(lusIndex, buttonColor, buttonHoveredColor); + GetButtonColorsForDeviceType(lusIndex, buttonColor, buttonHoveredColor); ImGui::PushStyleColor(ImGuiCol_Button, buttonColor); ImGui::PushStyleColor(ImGuiCol_ButtonHovered, buttonHoveredColor); - bool visible = mDeviceIndexVisibility[lusIndex]; + bool visible = mDeviceTypeVisibility[lusIndex]; if(ImGui::Button( StringHelper::Sprintf("%s %s %s (%s)", visible ? ICON_FA_EYE : ICON_FA_EYE_SLASH, connected ? ICON_FA_GAMEPAD : ICON_FA_CHAIN_BROKEN, name.c_str(), connected ? StringHelper::Sprintf("SDL %d", sdlIndex).c_str() : "Disconnected") .c_str())) { - mDeviceIndexVisibility[lusIndex] = !visible; + mDeviceTypeVisibility[lusIndex] = !visible; } ImGui::PopStyleColor(); ImGui::PopStyleColor(); @@ -1709,7 +1506,6 @@ void SohInputEditorWindow::DrawLinkTab() { ImGui::PushStyleColor(ImGuiCol_HeaderActive, ImVec4(0.0f, 0.0f, 0.0f, 1.0f)); if (ImGui::CollapsingHeader("Buttons", NULL, ImGuiTreeNodeFlags_DefaultOpen)) { - DrawButtonDeviceIcons(portIndex, mButtonsBitmasks); DrawButtonLine("A", portIndex, BTN_A, CHIP_COLOR_N64_BLUE); DrawButtonLine("B", portIndex, BTN_B, CHIP_COLOR_N64_GREEN); DrawButtonLine("Start", portIndex, BTN_START, CHIP_COLOR_N64_RED); @@ -1724,57 +1520,36 @@ void SohInputEditorWindow::DrawLinkTab() { CHIP_COLOR_N64_YELLOW); DrawButtonLine(StringHelper::Sprintf("C %s", ICON_FA_ARROW_RIGHT).c_str(), portIndex, BTN_CRIGHT, CHIP_COLOR_N64_YELLOW); - } else { - DrawButtonDeviceIcons(portIndex, mButtonsBitmasks); } if (ImGui::CollapsingHeader("D-Pad", NULL, ImGuiTreeNodeFlags_DefaultOpen)) { - DrawButtonDeviceIcons(portIndex, mDpadBitmasks); DrawButtonLine(StringHelper::Sprintf("%s", ICON_FA_ARROW_UP).c_str(), portIndex, BTN_DUP); DrawButtonLine(StringHelper::Sprintf("%s", ICON_FA_ARROW_DOWN).c_str(), portIndex, BTN_DDOWN); DrawButtonLine(StringHelper::Sprintf("%s", ICON_FA_ARROW_LEFT).c_str(), portIndex, BTN_DLEFT); DrawButtonLine(StringHelper::Sprintf("%s", ICON_FA_ARROW_RIGHT).c_str(), portIndex, BTN_DRIGHT); - } else { - DrawButtonDeviceIcons(portIndex, mDpadBitmasks); } if (ImGui::CollapsingHeader("Analog Stick", NULL, ImGuiTreeNodeFlags_DefaultOpen)) { - DrawAnalogStickDeviceIcons(portIndex, Ship::LEFT_STICK); DrawStickSection(portIndex, Ship::LEFT, 0); - } else { - DrawAnalogStickDeviceIcons(portIndex, Ship::LEFT_STICK); } if (ImGui::CollapsingHeader("Additional (\"Right\") Stick")) { - DrawAnalogStickDeviceIcons(portIndex, Ship::RIGHT_STICK); DrawStickSection(portIndex, Ship::RIGHT, 1, CHIP_COLOR_N64_YELLOW); - } else { - DrawAnalogStickDeviceIcons(portIndex, Ship::RIGHT_STICK); } if (ImGui::CollapsingHeader("Rumble")) { - DrawRumbleDeviceIcons(portIndex); DrawRumbleSection(portIndex); - } else { - DrawRumbleDeviceIcons(portIndex); } if (ImGui::CollapsingHeader("Gyro")) { - DrawGyroDeviceIcons(portIndex); DrawGyroSection(portIndex); - } else { - DrawGyroDeviceIcons(portIndex); } if (ImGui::CollapsingHeader("LEDs")) { - DrawLEDDeviceIcons(portIndex); DrawLEDSection(portIndex); - } else { - DrawLEDDeviceIcons(portIndex); } if (ImGui::CollapsingHeader("Modifier Buttons")) { - DrawButtonDeviceIcons(portIndex, mModifierButtonsBitmasks); DrawButtonLine("M1", portIndex, BTN_CUSTOM_MODIFIER1); DrawButtonLine("M2", portIndex, BTN_CUSTOM_MODIFIER2); @@ -1807,15 +1582,10 @@ void SohInputEditorWindow::DrawLinkTab() { Ship::GuiWindow::EndGroupPanel(0); } ImGui::EndDisabled(); - } else { - DrawButtonDeviceIcons(portIndex, mModifierButtonsBitmasks); } if (ImGui::CollapsingHeader("Ocarina Controls")) { - DrawButtonDeviceIcons(portIndex, mCustomOcarinaButtonsBitmasks); DrawOcarinaControlPanel(); - } else { - DrawButtonDeviceIcons(portIndex, mCustomOcarinaButtonsBitmasks); } if (ImGui::CollapsingHeader("Camera Controls")) { @@ -1865,7 +1635,6 @@ void SohInputEditorWindow::DrawIvanTab() { ImGui::PushStyleColor(ImGuiCol_HeaderActive, ImVec4(0.0f, 0.0f, 0.0f, 1.0f)); if (ImGui::CollapsingHeader("Buttons", NULL, ImGuiTreeNodeFlags_DefaultOpen)) { - DrawButtonDeviceIcons(portIndex, mButtonsBitmasks); DrawButtonLine("A", portIndex, BTN_A, CHIP_COLOR_N64_BLUE); DrawButtonLine("B", portIndex, BTN_B, CHIP_COLOR_N64_GREEN); DrawButtonLine("Z", portIndex, BTN_Z); @@ -1877,25 +1646,17 @@ void SohInputEditorWindow::DrawIvanTab() { CHIP_COLOR_N64_YELLOW); DrawButtonLine(StringHelper::Sprintf("C %s", ICON_FA_ARROW_RIGHT).c_str(), portIndex, BTN_CRIGHT, CHIP_COLOR_N64_YELLOW); - } else { - DrawButtonDeviceIcons(portIndex, mButtonsBitmasks); } if (ImGui::CollapsingHeader("D-Pad", NULL, ImGuiTreeNodeFlags_DefaultOpen)) { - DrawButtonDeviceIcons(portIndex, mDpadBitmasks); DrawButtonLine(StringHelper::Sprintf("%s", ICON_FA_ARROW_UP).c_str(), portIndex, BTN_DUP); DrawButtonLine(StringHelper::Sprintf("%s", ICON_FA_ARROW_DOWN).c_str(), portIndex, BTN_DDOWN); DrawButtonLine(StringHelper::Sprintf("%s", ICON_FA_ARROW_LEFT).c_str(), portIndex, BTN_DLEFT); DrawButtonLine(StringHelper::Sprintf("%s", ICON_FA_ARROW_RIGHT).c_str(), portIndex, BTN_DRIGHT); - } else { - DrawButtonDeviceIcons(portIndex, mDpadBitmasks); } if (ImGui::CollapsingHeader("Analog Stick", NULL, ImGuiTreeNodeFlags_DefaultOpen)) { - DrawAnalogStickDeviceIcons(portIndex, Ship::LEFT_STICK); DrawStickSection(portIndex, Ship::LEFT, 0); - } else { - DrawAnalogStickDeviceIcons(portIndex, Ship::LEFT_STICK); } ImGui::PopStyleColor(); @@ -1921,7 +1682,6 @@ void SohInputEditorWindow::DrawDebugPortTab(uint8_t portIndex, std::string custo ImGui::PushStyleColor(ImGuiCol_HeaderActive, ImVec4(0.0f, 0.0f, 0.0f, 1.0f)); if (ImGui::CollapsingHeader("Buttons", NULL, ImGuiTreeNodeFlags_DefaultOpen)) { - DrawButtonDeviceIcons(portIndex, mButtonsBitmasks); DrawButtonLine("A", portIndex, BTN_A, CHIP_COLOR_N64_BLUE); DrawButtonLine("B", portIndex, BTN_B, CHIP_COLOR_N64_GREEN); DrawButtonLine("Start", portIndex, BTN_START, CHIP_COLOR_N64_RED); @@ -1936,25 +1696,16 @@ void SohInputEditorWindow::DrawDebugPortTab(uint8_t portIndex, std::string custo CHIP_COLOR_N64_YELLOW); DrawButtonLine(StringHelper::Sprintf("C %s", ICON_FA_ARROW_RIGHT).c_str(), portIndex, BTN_CRIGHT, CHIP_COLOR_N64_YELLOW); - } else { - DrawButtonDeviceIcons(portIndex, mButtonsBitmasks); } - if (ImGui::CollapsingHeader("D-Pad", NULL, ImGuiTreeNodeFlags_DefaultOpen)) { - DrawButtonDeviceIcons(portIndex, mDpadBitmasks); DrawButtonLine(StringHelper::Sprintf("%s", ICON_FA_ARROW_UP).c_str(), portIndex, BTN_DUP); DrawButtonLine(StringHelper::Sprintf("%s", ICON_FA_ARROW_DOWN).c_str(), portIndex, BTN_DDOWN); DrawButtonLine(StringHelper::Sprintf("%s", ICON_FA_ARROW_LEFT).c_str(), portIndex, BTN_DLEFT); DrawButtonLine(StringHelper::Sprintf("%s", ICON_FA_ARROW_RIGHT).c_str(), portIndex, BTN_DRIGHT); - } else { - DrawButtonDeviceIcons(portIndex, mDpadBitmasks); } if (ImGui::CollapsingHeader("Analog Stick", NULL, ImGuiTreeNodeFlags_DefaultOpen)) { - DrawAnalogStickDeviceIcons(portIndex, Ship::LEFT_STICK); DrawStickSection(portIndex, Ship::LEFT, 0); - } else { - DrawAnalogStickDeviceIcons(portIndex, Ship::LEFT_STICK); } ImGui::PopStyleColor(); @@ -1990,19 +1741,6 @@ void SohInputEditorWindow::DrawSetDefaultsButton(uint8_t portIndex) { } if (ImGui::BeginPopup(popupId.c_str())) { - std::map> indexMappings; - for (auto [lusIndex, mapping] : Ship::Context::GetInstance() - ->GetControlDeck() - ->GetDeviceIndexMappingManager() - ->GetAllDeviceIndexMappings()) { - auto sdlIndexMapping = std::static_pointer_cast(mapping); - if (sdlIndexMapping == nullptr) { - continue; - } - - indexMappings[lusIndex] = { sdlIndexMapping->GetSDLControllerName(), sdlIndexMapping->GetSDLDeviceIndex() }; - } - bool shouldClose = false; ImGui::PushStyleColor(ImGuiCol_Button, BUTTON_COLOR_KEYBOARD_BEIGE); ImGui::PushStyleColor(ImGuiCol_ButtonHovered, BUTTON_COLOR_KEYBOARD_BEIGE_HOVERED); @@ -2029,41 +1767,34 @@ void SohInputEditorWindow::DrawSetDefaultsButton(uint8_t portIndex) { } ImGui::EndPopup(); } - for (auto [lusIndex, info] : indexMappings) { - auto [name, sdlIndex] = info; - - auto buttonColor = ImGui::GetStyleColorVec4(ImGuiCol_Button); - auto buttonHoveredColor = ImGui::GetStyleColorVec4(ImGuiCol_ButtonHovered); - GetButtonColorsForLUSDeviceIndex(lusIndex, buttonColor, buttonHoveredColor); - ImGui::PushStyleColor(ImGuiCol_Button, buttonColor); - ImGui::PushStyleColor(ImGuiCol_ButtonHovered, buttonHoveredColor); - if (ImGui::Button(StringHelper::Sprintf("%s %s (%s)", ICON_FA_GAMEPAD, name.c_str(), - StringHelper::Sprintf("SDL %d", sdlIndex).c_str()) - .c_str())) { - ImGui::OpenPopup(StringHelper::Sprintf("Set Defaults for %s", name.c_str()).c_str()); + + auto buttonColor = ImGui::GetStyleColorVec4(ImGuiCol_Button); + auto buttonHoveredColor = ImGui::GetStyleColorVec4(ImGuiCol_ButtonHovered); + GetButtonColorsForDeviceType(Ship::PhysicalDeviceType::SDLGamepad, buttonColor, buttonHoveredColor); + ImGui::PushStyleColor(ImGuiCol_Button, buttonColor); + ImGui::PushStyleColor(ImGuiCol_ButtonHovered, buttonHoveredColor); + if (ImGui::Button(StringHelper::Sprintf("%s %s", ICON_FA_GAMEPAD, "Gamepad (SDL)").c_str())) { + ImGui::OpenPopup("Set Defaults for Gamepad (SDL)"); + } + ImGui::PopStyleColor(); + ImGui::PopStyleColor(); + if (ImGui::BeginPopupModal("Set Defaults for Gamepad (SDL)", NULL, ImGuiWindowFlags_AlwaysAutoResize)) { + ImGui::Text("This will clear all existing mappings for\nGamepad (SDL) on port %d.\n\nContinue?", portIndex + 1); + if (ImGui::Button("Cancel")) { + shouldClose = true; + ImGui::CloseCurrentPopup(); } - ImGui::PopStyleColor(); - ImGui::PopStyleColor(); - if (ImGui::BeginPopupModal(StringHelper::Sprintf("Set Defaults for %s", name.c_str()).c_str(), NULL, - ImGuiWindowFlags_AlwaysAutoResize)) { - ImGui::Text("This will clear all existing mappings for\n%s (SDL %d) on port %d.\n\nContinue?", - name.c_str(), sdlIndex, portIndex + 1); - if (ImGui::Button("Cancel")) { - shouldClose = true; - ImGui::CloseCurrentPopup(); - } - if (ImGui::Button("Set defaults")) { - Ship::Context::GetInstance() - ->GetControlDeck() - ->GetControllerByPort(portIndex) - ->ClearAllMappingsForDeviceType(lusIndex); - Ship::Context::GetInstance()->GetControlDeck()->GetControllerByPort(portIndex)->AddDefaultMappings( - lusIndex); - shouldClose = true; - ImGui::CloseCurrentPopup(); - } - ImGui::EndPopup(); + if (ImGui::Button("Set defaults")) { + Ship::Context::GetInstance() + ->GetControlDeck() + ->GetControllerByPort(portIndex) + ->ClearAllMappingsForDeviceType(Ship::PhysicalDeviceType::SDLGamepad); + Ship::Context::GetInstance()->GetControlDeck()->GetControllerByPort(portIndex)->AddDefaultMappings( + Ship::PhysicalDeviceType::SDLGamepad); + shouldClose = true; + ImGui::CloseCurrentPopup(); } + ImGui::EndPopup(); } if (ImGui::Button("Cancel") || shouldClose) { diff --git a/soh/soh/Enhancements/controls/SohInputEditorWindow.h b/soh/soh/Enhancements/controls/SohInputEditorWindow.h index c4387d2219..dd9bd5e590 100644 --- a/soh/soh/Enhancements/controls/SohInputEditorWindow.h +++ b/soh/soh/Enhancements/controls/SohInputEditorWindow.h @@ -83,7 +83,7 @@ class SohInputEditorWindow : public Ship::GuiWindow { void UpdateBitmaskToMappingIds(uint8_t port); void UpdateStickDirectionToMappingIds(uint8_t port); - void GetButtonColorsForLUSDeviceIndex(Ship::PhysicalDeviceType lusIndex, ImVec4& buttonColor, + void GetButtonColorsForDeviceType(Ship::PhysicalDeviceType lusIndex, ImVec4& buttonColor, ImVec4& buttonHoveredColor); void DrawLinkTab(); void DrawIvanTab(); @@ -92,15 +92,10 @@ class SohInputEditorWindow : public Ship::GuiWindow { std::set mDpadBitmasks; std::set mModifierButtonsBitmasks; std::set mCustomOcarinaButtonsBitmasks; - void DrawButtonDeviceIcons(uint8_t portIndex, std::set bitmasks); - void DrawAnalogStickDeviceIcons(uint8_t portIndex, Ship::StickIndex stickIndex); - void DrawRumbleDeviceIcons(uint8_t portIndex); - void DrawGyroDeviceIcons(uint8_t portIndex); - void DrawLEDDeviceIcons(uint8_t portIndex); bool mInputEditorPopupOpen; void DrawSetDefaultsButton(uint8_t portIndex); void DrawClearAllButton(uint8_t portIndex); - std::map mDeviceIndexVisibility; + std::map mDeviceTypeVisibility; void DrawDeviceVisibilityButtons(); }; From 70c36f3c27a215f3a89848adc144cb46f25a83bf Mon Sep 17 00:00:00 2001 From: briaguya <70942617+briaguya-ai@users.noreply.github.com> Date: Sun, 19 Jan 2025 14:18:28 -0500 Subject: [PATCH 12/22] back to all stuff visible --- .../controls/SohInputEditorWindow.cpp | 102 +++++++----------- .../controls/SohInputEditorWindow.h | 3 +- 2 files changed, 38 insertions(+), 67 deletions(-) diff --git a/soh/soh/Enhancements/controls/SohInputEditorWindow.cpp b/soh/soh/Enhancements/controls/SohInputEditorWindow.cpp index e88c271269..2a6373ab74 100644 --- a/soh/soh/Enhancements/controls/SohInputEditorWindow.cpp +++ b/soh/soh/Enhancements/controls/SohInputEditorWindow.cpp @@ -46,11 +46,6 @@ void SohInputEditorWindow::InitElement() { addButtonName(BTN_DLEFT, "D-pad left"); addButtonName(BTN_DRIGHT, "D-pad right"); addButtonName(0, "None"); - - mDeviceTypeVisibility.clear(); - mDeviceTypeVisibility[Ship::PhysicalDeviceType::Keyboard] = true; - mDeviceTypeVisibility[Ship::PhysicalDeviceType::SDLGamepad] = true; - mDeviceTypeVisibility[Ship::PhysicalDeviceType::Max] = false; } #define INPUT_EDITOR_WINDOW_GAME_INPUT_BLOCK_ID 95237929 @@ -193,6 +188,7 @@ void SohInputEditorWindow::GetButtonColorsForDeviceType(Ship::PhysicalDeviceType ImVec4& buttonHoveredColor) { switch (lusIndex) { case Ship::PhysicalDeviceType::Keyboard: + case Ship::PhysicalDeviceType::Mouse: buttonColor = BUTTON_COLOR_KEYBOARD_BEIGE; buttonHoveredColor = BUTTON_COLOR_KEYBOARD_BEIGE_HOVERED; break; @@ -252,9 +248,6 @@ void SohInputEditorWindow::DrawButtonLineEditMappingButton(uint8_t port, N64Butt if (mapping == nullptr) { return; } - if (!mDeviceTypeVisibility[mapping->GetPhysicalDeviceType()]) { - return; - } ImGui::PushStyleVar(ImGuiStyleVar_ButtonTextAlign, ImVec2(0.0f, 0.5f)); std::string icon = ""; @@ -519,9 +512,6 @@ void SohInputEditorWindow::DrawStickDirectionLineEditMappingButton(uint8_t port, if (mapping == nullptr) { return; } - if (!mDeviceTypeVisibility[mapping->GetPhysicalDeviceType()]) { - return; - } ImGui::PushStyleVar(ImGuiStyleVar_ButtonTextAlign, ImVec2(0.0f, 0.5f)); std::string icon = ""; @@ -1428,67 +1418,49 @@ void SohInputEditorWindow::DrawDpadControlPanel() { Ship::GuiWindow::EndGroupPanel(0); } -void SohInputEditorWindow::DrawDeviceVisibilityButtons() { - std::map> indexMappings; - for (auto [lusIndex, mapping] : Ship::Context::GetInstance() - ->GetControlDeck() - ->GetDeviceIndexMappingManager() - ->GetAllDeviceIndexMappingsFromConfig()) { - auto sdlIndexMapping = std::static_pointer_cast(mapping); - if (sdlIndexMapping == nullptr) { - continue; - } - - indexMappings[lusIndex] = { sdlIndexMapping->GetSDLControllerName(), -1 }; - } - - for (auto [lusIndex, mapping] : Ship::Context::GetInstance() - ->GetControlDeck() - ->GetDeviceIndexMappingManager() - ->GetAllDeviceIndexMappings()) { - auto sdlIndexMapping = std::static_pointer_cast(mapping); - if (sdlIndexMapping == nullptr) { - continue; - } - - indexMappings[lusIndex] = { sdlIndexMapping->GetSDLControllerName(), sdlIndexMapping->GetSDLDeviceIndex() }; - } +void SohInputEditorWindow::DrawDeviceNameButtons() { + ImGui::PushItemFlag(ImGuiItemFlags_Disabled, true); auto keyboardButtonColor = ImGui::GetStyleColorVec4(ImGuiCol_Button); auto keyboardButtonHoveredColor = ImGui::GetStyleColorVec4(ImGuiCol_ButtonHovered); GetButtonColorsForDeviceType(Ship::PhysicalDeviceType::Keyboard, keyboardButtonColor, keyboardButtonHoveredColor); ImGui::PushStyleColor(ImGuiCol_Button, keyboardButtonColor); ImGui::PushStyleColor(ImGuiCol_ButtonHovered, keyboardButtonHoveredColor); - bool keyboardVisible = mDeviceTypeVisibility[Ship::PhysicalDeviceType::Keyboard]; - if(ImGui::Button( - StringHelper::Sprintf("%s %s Keyboard", keyboardVisible ? ICON_FA_EYE : ICON_FA_EYE_SLASH, ICON_FA_KEYBOARD_O) - .c_str())) { - mDeviceTypeVisibility[Ship::PhysicalDeviceType::Keyboard] = !keyboardVisible; - } + ImGui::Button(StringHelper::Sprintf("%s Keyboard", ICON_FA_KEYBOARD_O).c_str()); ImGui::PopStyleColor(); ImGui::PopStyleColor(); + auto mouseButtonColor = ImGui::GetStyleColorVec4(ImGuiCol_Button); + auto mouseButtonHoveredColor = ImGui::GetStyleColorVec4(ImGuiCol_ButtonHovered); + GetButtonColorsForDeviceType(Ship::PhysicalDeviceType::Mouse, mouseButtonColor, mouseButtonHoveredColor); + ImGui::PushStyleColor(ImGuiCol_Button, mouseButtonColor); + ImGui::PushStyleColor(ImGuiCol_ButtonHovered, mouseButtonHoveredColor); + ImGui::Button(StringHelper::Sprintf("%s Mouse", ICON_FA_KEYBOARD_O).c_str()); + ImGui::PopStyleColor(); + ImGui::PopStyleColor(); - for (auto [lusIndex, info] : indexMappings) { - auto [name, sdlIndex] = info; - bool connected = sdlIndex != -1; - - auto buttonColor = ImGui::GetStyleColorVec4(ImGuiCol_Button); - auto buttonHoveredColor = ImGui::GetStyleColorVec4(ImGuiCol_ButtonHovered); - GetButtonColorsForDeviceType(lusIndex, buttonColor, buttonHoveredColor); - - ImGui::PushStyleColor(ImGuiCol_Button, buttonColor); - ImGui::PushStyleColor(ImGuiCol_ButtonHovered, buttonHoveredColor); - bool visible = mDeviceTypeVisibility[lusIndex]; - if(ImGui::Button( - StringHelper::Sprintf("%s %s %s (%s)", visible ? ICON_FA_EYE : ICON_FA_EYE_SLASH, connected ? ICON_FA_GAMEPAD : ICON_FA_CHAIN_BROKEN, name.c_str(), - connected ? StringHelper::Sprintf("SDL %d", sdlIndex).c_str() : "Disconnected") - .c_str())) { - mDeviceTypeVisibility[lusIndex] = !visible; - } - ImGui::PopStyleColor(); - ImGui::PopStyleColor(); - } + // todo: display connected controller device names + // for (auto [lusIndex, info] : indexMappings) { + // auto [name, sdlIndex] = info; + // bool connected = sdlIndex != -1; + + // auto buttonColor = ImGui::GetStyleColorVec4(ImGuiCol_Button); + // auto buttonHoveredColor = ImGui::GetStyleColorVec4(ImGuiCol_ButtonHovered); + // GetButtonColorsForDeviceType(lusIndex, buttonColor, buttonHoveredColor); + + // ImGui::PushStyleColor(ImGuiCol_Button, buttonColor); + // ImGui::PushStyleColor(ImGuiCol_ButtonHovered, buttonHoveredColor); + // bool visible = mDeviceTypeVisibility[lusIndex]; + // if(ImGui::Button( + // StringHelper::Sprintf("%s %s %s (%s)", visible ? ICON_FA_EYE : ICON_FA_EYE_SLASH, connected ? ICON_FA_GAMEPAD : ICON_FA_CHAIN_BROKEN, name.c_str(), + // connected ? StringHelper::Sprintf("SDL %d", sdlIndex).c_str() : "Disconnected") + // .c_str())) { + // mDeviceTypeVisibility[lusIndex] = !visible; + // } + // ImGui::PopStyleColor(); + // ImGui::PopStyleColor(); + // } + ImGui::PopItemFlag(); } void SohInputEditorWindow::DrawLinkTab() { @@ -1496,7 +1468,7 @@ void SohInputEditorWindow::DrawLinkTab() { if (ImGui::BeginTabItem(StringHelper::Sprintf("Link (P1)###port%d", portIndex).c_str())) { DrawClearAllButton(portIndex); DrawSetDefaultsButton(portIndex); - DrawDeviceVisibilityButtons(); + DrawDeviceNameButtons(); UpdateBitmaskToMappingIds(portIndex); UpdateStickDirectionToMappingIds(portIndex); @@ -1625,7 +1597,7 @@ void SohInputEditorWindow::DrawIvanTab() { if (ImGui::BeginTabItem(StringHelper::Sprintf("Ivan (P2)###port%d", portIndex).c_str())) { DrawClearAllButton(portIndex); DrawSetDefaultsButton(portIndex); - DrawDeviceVisibilityButtons(); + DrawDeviceNameButtons(); UpdateBitmaskToMappingIds(portIndex); UpdateStickDirectionToMappingIds(portIndex); @@ -1672,7 +1644,7 @@ void SohInputEditorWindow::DrawDebugPortTab(uint8_t portIndex, std::string custo : customName.c_str())) { DrawClearAllButton(portIndex); DrawSetDefaultsButton(portIndex); - DrawDeviceVisibilityButtons(); + DrawDeviceNameButtons(); UpdateBitmaskToMappingIds(portIndex); UpdateStickDirectionToMappingIds(portIndex); diff --git a/soh/soh/Enhancements/controls/SohInputEditorWindow.h b/soh/soh/Enhancements/controls/SohInputEditorWindow.h index dd9bd5e590..7b5d83ba70 100644 --- a/soh/soh/Enhancements/controls/SohInputEditorWindow.h +++ b/soh/soh/Enhancements/controls/SohInputEditorWindow.h @@ -96,6 +96,5 @@ class SohInputEditorWindow : public Ship::GuiWindow { void DrawSetDefaultsButton(uint8_t portIndex); void DrawClearAllButton(uint8_t portIndex); - std::map mDeviceTypeVisibility; - void DrawDeviceVisibilityButtons(); + void DrawDeviceNameButtons(); }; From 458008f43f4c29b6019280e3a02f84fae594bc53 Mon Sep 17 00:00:00 2001 From: briaguya <70942617+briaguya-ai@users.noreply.github.com> Date: Sun, 19 Jan 2025 14:35:19 -0500 Subject: [PATCH 13/22] show connected device names --- libultraship | 2 +- .../controls/SohInputEditorWindow.cpp | 32 +++++++------------ 2 files changed, 12 insertions(+), 22 deletions(-) diff --git a/libultraship b/libultraship index 5dba443030..ab9ca34352 160000 --- a/libultraship +++ b/libultraship @@ -1 +1 @@ -Subproject commit 5dba443030e7171d20fa841ab726169b40bf8b34 +Subproject commit ab9ca3435256ac64038a38985427945d02deab23 diff --git a/soh/soh/Enhancements/controls/SohInputEditorWindow.cpp b/soh/soh/Enhancements/controls/SohInputEditorWindow.cpp index 2a6373ab74..29b7d9b220 100644 --- a/soh/soh/Enhancements/controls/SohInputEditorWindow.cpp +++ b/soh/soh/Enhancements/controls/SohInputEditorWindow.cpp @@ -1439,27 +1439,17 @@ void SohInputEditorWindow::DrawDeviceNameButtons() { ImGui::PopStyleColor(); ImGui::PopStyleColor(); - // todo: display connected controller device names - // for (auto [lusIndex, info] : indexMappings) { - // auto [name, sdlIndex] = info; - // bool connected = sdlIndex != -1; - - // auto buttonColor = ImGui::GetStyleColorVec4(ImGuiCol_Button); - // auto buttonHoveredColor = ImGui::GetStyleColorVec4(ImGuiCol_ButtonHovered); - // GetButtonColorsForDeviceType(lusIndex, buttonColor, buttonHoveredColor); - - // ImGui::PushStyleColor(ImGuiCol_Button, buttonColor); - // ImGui::PushStyleColor(ImGuiCol_ButtonHovered, buttonHoveredColor); - // bool visible = mDeviceTypeVisibility[lusIndex]; - // if(ImGui::Button( - // StringHelper::Sprintf("%s %s %s (%s)", visible ? ICON_FA_EYE : ICON_FA_EYE_SLASH, connected ? ICON_FA_GAMEPAD : ICON_FA_CHAIN_BROKEN, name.c_str(), - // connected ? StringHelper::Sprintf("SDL %d", sdlIndex).c_str() : "Disconnected") - // .c_str())) { - // mDeviceTypeVisibility[lusIndex] = !visible; - // } - // ImGui::PopStyleColor(); - // ImGui::PopStyleColor(); - // } + for (const auto& name : Ship::Context::GetInstance()->GetControlDeck()->GetConnectedPhysicalDeviceManager()->GetConnectedSDLGamepadNames()) { + auto buttonColor = ImGui::GetStyleColorVec4(ImGuiCol_Button); + auto buttonHoveredColor = ImGui::GetStyleColorVec4(ImGuiCol_ButtonHovered); + GetButtonColorsForDeviceType(Ship::PhysicalDeviceType::SDLGamepad, buttonColor, buttonHoveredColor); + ImGui::PushStyleColor(ImGuiCol_Button, buttonColor); + ImGui::PushStyleColor(ImGuiCol_ButtonHovered, buttonHoveredColor); + ImGui::Button(StringHelper::Sprintf("%s %s (SDL)", ICON_FA_GAMEPAD, name.c_str()).c_str()); + ImGui::PopStyleColor(); + ImGui::PopStyleColor(); + } + ImGui::PopItemFlag(); } From 75c6bc1b856200fbcfad2515ec760585fc3db532 Mon Sep 17 00:00:00 2001 From: briaguya <70942617+briaguya-ai@users.noreply.github.com> Date: Sun, 19 Jan 2025 14:44:52 -0500 Subject: [PATCH 14/22] bring in mouse color from lus input editor window --- soh/soh/Enhancements/controls/SohInputEditorWindow.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/soh/soh/Enhancements/controls/SohInputEditorWindow.cpp b/soh/soh/Enhancements/controls/SohInputEditorWindow.cpp index 29b7d9b220..774e64014a 100644 --- a/soh/soh/Enhancements/controls/SohInputEditorWindow.cpp +++ b/soh/soh/Enhancements/controls/SohInputEditorWindow.cpp @@ -169,6 +169,9 @@ void SohInputEditorWindow::DrawAnalogPreview(const char* label, ImVec2 stick, fl #define BUTTON_COLOR_KEYBOARD_BEIGE ImVec4(0.651f, 0.482f, 0.357f, 0.5f) #define BUTTON_COLOR_KEYBOARD_BEIGE_HOVERED ImVec4(0.651f, 0.482f, 0.357f, 1.0f) +#define BUTTON_COLOR_MOUSE_BEIGE ImVec4(0.5f, 0.5f, 0.5f, 0.5f) +#define BUTTON_COLOR_MOUSE_BEIGE_HOVERED ImVec4(0.5f, 0.5f, 0.5f, 1.0f) + #define BUTTON_COLOR_GAMEPAD_BLUE ImVec4(0.0f, 0.255f, 0.976f, 0.5f) #define BUTTON_COLOR_GAMEPAD_BLUE_HOVERED ImVec4(0.0f, 0.255f, 0.976f, 1.0f) @@ -188,10 +191,13 @@ void SohInputEditorWindow::GetButtonColorsForDeviceType(Ship::PhysicalDeviceType ImVec4& buttonHoveredColor) { switch (lusIndex) { case Ship::PhysicalDeviceType::Keyboard: - case Ship::PhysicalDeviceType::Mouse: buttonColor = BUTTON_COLOR_KEYBOARD_BEIGE; buttonHoveredColor = BUTTON_COLOR_KEYBOARD_BEIGE_HOVERED; break; + case Ship::PhysicalDeviceType::Mouse: + buttonColor = BUTTON_COLOR_MOUSE_BEIGE; + buttonHoveredColor = BUTTON_COLOR_MOUSE_BEIGE_HOVERED; + break; case Ship::PhysicalDeviceType::SDLGamepad: buttonColor = BUTTON_COLOR_GAMEPAD_BLUE; buttonHoveredColor = BUTTON_COLOR_GAMEPAD_BLUE_HOVERED; From bfad7bed19e0fb8934733760d9f00ba36326d90b Mon Sep 17 00:00:00 2001 From: briaguya <70942617+briaguya-ai@users.noreply.github.com> Date: Sun, 19 Jan 2025 14:58:18 -0500 Subject: [PATCH 15/22] lus --- libultraship | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libultraship b/libultraship index ab9ca34352..c8400d0c35 160000 --- a/libultraship +++ b/libultraship @@ -1 +1 @@ -Subproject commit ab9ca3435256ac64038a38985427945d02deab23 +Subproject commit c8400d0c35acd0fb987c946d403be8fa3a9b0232 From dee04b4d29926e9cb231a555c6545b88f3f972a6 Mon Sep 17 00:00:00 2001 From: briaguya <70942617+briaguya-ai@users.noreply.github.com> Date: Sun, 19 Jan 2025 15:21:49 -0500 Subject: [PATCH 16/22] remove --- libultraship | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libultraship b/libultraship index c8400d0c35..b6a0b39337 160000 --- a/libultraship +++ b/libultraship @@ -1 +1 @@ -Subproject commit c8400d0c35acd0fb987c946d403be8fa3a9b0232 +Subproject commit b6a0b393378bb023b9fdcaf810b6ba019bd68be2 From 88d2e46da2b270ae1272740027e5563871dd180f Mon Sep 17 00:00:00 2001 From: briaguya <70942617+briaguya-ai@users.noreply.github.com> Date: Sun, 19 Jan 2025 16:13:27 -0500 Subject: [PATCH 17/22] more stuff --- libultraship | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libultraship b/libultraship index b6a0b39337..e5e1c92f47 160000 --- a/libultraship +++ b/libultraship @@ -1 +1 @@ -Subproject commit b6a0b393378bb023b9fdcaf810b6ba019bd68be2 +Subproject commit e5e1c92f473908cf1f5d3d9093a50df2dda5fb11 From 619a7e665f29fe9aa6d1c2545da1d46d2af67e88 Mon Sep 17 00:00:00 2001 From: briaguya <70942617+briaguya-ai@users.noreply.github.com> Date: Sun, 19 Jan 2025 16:58:11 -0500 Subject: [PATCH 18/22] more lus --- libultraship | 2 +- soh/soh/OTRGlobals.cpp | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/libultraship b/libultraship index e5e1c92f47..5bbe7271ce 160000 --- a/libultraship +++ b/libultraship @@ -1 +1 @@ -Subproject commit e5e1c92f473908cf1f5d3d9093a50df2dda5fb11 +Subproject commit 5bbe7271ce46105f9fddf86f8610df4f2595e88b diff --git a/soh/soh/OTRGlobals.cpp b/soh/soh/OTRGlobals.cpp index 6d3d22fc9a..97c9c2968f 100644 --- a/soh/soh/OTRGlobals.cpp +++ b/soh/soh/OTRGlobals.cpp @@ -341,7 +341,6 @@ OTRGlobals::OTRGlobals() { BTN_CUSTOM_OCARINA_PITCH_DOWN, })); context->InitControlDeck(controlDeck); - context->GetControlDeck()->SetSinglePlayerMappingMode(true); context->InitCrashHandler(); context->InitConsole(); From 6155f59314483a16e0bc5f1a1178a83ce23545bc Mon Sep 17 00:00:00 2001 From: briaguya <70942617+briaguya-ai@users.noreply.github.com> Date: Sun, 19 Jan 2025 19:24:13 -0500 Subject: [PATCH 19/22] basic filtering --- libultraship | 2 +- .../controls/SohInputEditorWindow.cpp | 28 ++++++++++++++----- .../controls/SohInputEditorWindow.h | 2 +- 3 files changed, 23 insertions(+), 9 deletions(-) diff --git a/libultraship b/libultraship index 5bbe7271ce..96e7d20d44 160000 --- a/libultraship +++ b/libultraship @@ -1 +1 @@ -Subproject commit 5bbe7271ce46105f9fddf86f8610df4f2595e88b +Subproject commit 96e7d20d44d8013983d3633b67aa0189793d90ca diff --git a/soh/soh/Enhancements/controls/SohInputEditorWindow.cpp b/soh/soh/Enhancements/controls/SohInputEditorWindow.cpp index 774e64014a..7967c3d15e 100644 --- a/soh/soh/Enhancements/controls/SohInputEditorWindow.cpp +++ b/soh/soh/Enhancements/controls/SohInputEditorWindow.cpp @@ -1424,7 +1424,7 @@ void SohInputEditorWindow::DrawDpadControlPanel() { Ship::GuiWindow::EndGroupPanel(0); } -void SohInputEditorWindow::DrawDeviceNameButtons() { +void SohInputEditorWindow::DrawDeviceToggles(uint8_t portIndex) { ImGui::PushItemFlag(ImGuiItemFlags_Disabled, true); auto keyboardButtonColor = ImGui::GetStyleColorVec4(ImGuiCol_Button); @@ -1445,18 +1445,32 @@ void SohInputEditorWindow::DrawDeviceNameButtons() { ImGui::PopStyleColor(); ImGui::PopStyleColor(); - for (const auto& name : Ship::Context::GetInstance()->GetControlDeck()->GetConnectedPhysicalDeviceManager()->GetConnectedSDLGamepadNames()) { + ImGui::PopItemFlag(); + + auto connectedDeviceManager = Ship::Context::GetInstance()->GetControlDeck()->GetConnectedPhysicalDeviceManager(); + for (const auto& [instanceId, name] : connectedDeviceManager->GetConnectedSDLGamepadNames()) { + ImGui::PushItemFlag(ImGuiItemFlags_Disabled, true); auto buttonColor = ImGui::GetStyleColorVec4(ImGuiCol_Button); auto buttonHoveredColor = ImGui::GetStyleColorVec4(ImGuiCol_ButtonHovered); GetButtonColorsForDeviceType(Ship::PhysicalDeviceType::SDLGamepad, buttonColor, buttonHoveredColor); ImGui::PushStyleColor(ImGuiCol_Button, buttonColor); ImGui::PushStyleColor(ImGuiCol_ButtonHovered, buttonHoveredColor); + auto notIgnored = !connectedDeviceManager->PortIsIgnoringInstanceId(portIndex, instanceId); + ImGui::PopItemFlag(); + if(ImGui::Checkbox(StringHelper::Sprintf("###instanceId_%d", instanceId).c_str(), ¬Ignored)) { + if (notIgnored) { + connectedDeviceManager->UnignoreInstanceIdForPort(portIndex, instanceId); + } else { + connectedDeviceManager->IgnoreInstanceIdForPort(portIndex, instanceId); + } + }; + ImGui::PushItemFlag(ImGuiItemFlags_Disabled, true); + ImGui::SameLine(); ImGui::Button(StringHelper::Sprintf("%s %s (SDL)", ICON_FA_GAMEPAD, name.c_str()).c_str()); ImGui::PopStyleColor(); ImGui::PopStyleColor(); + ImGui::PopItemFlag(); } - - ImGui::PopItemFlag(); } void SohInputEditorWindow::DrawLinkTab() { @@ -1464,7 +1478,7 @@ void SohInputEditorWindow::DrawLinkTab() { if (ImGui::BeginTabItem(StringHelper::Sprintf("Link (P1)###port%d", portIndex).c_str())) { DrawClearAllButton(portIndex); DrawSetDefaultsButton(portIndex); - DrawDeviceNameButtons(); + DrawDeviceToggles(portIndex); UpdateBitmaskToMappingIds(portIndex); UpdateStickDirectionToMappingIds(portIndex); @@ -1593,7 +1607,7 @@ void SohInputEditorWindow::DrawIvanTab() { if (ImGui::BeginTabItem(StringHelper::Sprintf("Ivan (P2)###port%d", portIndex).c_str())) { DrawClearAllButton(portIndex); DrawSetDefaultsButton(portIndex); - DrawDeviceNameButtons(); + DrawDeviceToggles(portIndex); UpdateBitmaskToMappingIds(portIndex); UpdateStickDirectionToMappingIds(portIndex); @@ -1640,7 +1654,7 @@ void SohInputEditorWindow::DrawDebugPortTab(uint8_t portIndex, std::string custo : customName.c_str())) { DrawClearAllButton(portIndex); DrawSetDefaultsButton(portIndex); - DrawDeviceNameButtons(); + DrawDeviceToggles(portIndex); UpdateBitmaskToMappingIds(portIndex); UpdateStickDirectionToMappingIds(portIndex); diff --git a/soh/soh/Enhancements/controls/SohInputEditorWindow.h b/soh/soh/Enhancements/controls/SohInputEditorWindow.h index 7b5d83ba70..4545f771d6 100644 --- a/soh/soh/Enhancements/controls/SohInputEditorWindow.h +++ b/soh/soh/Enhancements/controls/SohInputEditorWindow.h @@ -96,5 +96,5 @@ class SohInputEditorWindow : public Ship::GuiWindow { void DrawSetDefaultsButton(uint8_t portIndex); void DrawClearAllButton(uint8_t portIndex); - void DrawDeviceNameButtons(); + void DrawDeviceToggles(uint8_t portIndex); }; From 5588be7acd863ad67b1d81cab1f5dd7c15339a88 Mon Sep 17 00:00:00 2001 From: briaguya <70942617+briaguya-ai@users.noreply.github.com> Date: Sun, 19 Jan 2025 19:30:33 -0500 Subject: [PATCH 20/22] update lus --- libultraship | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libultraship b/libultraship index 96e7d20d44..640ef65597 160000 --- a/libultraship +++ b/libultraship @@ -1 +1 @@ -Subproject commit 96e7d20d44d8013983d3633b67aa0189793d90ca +Subproject commit 640ef6559732944370046d54a9309b5a386ff4c1 From 9b89b7afa9182232c1c984d8ed854cdeb76cd07c Mon Sep 17 00:00:00 2001 From: briaguya <70942617+briaguya-ai@users.noreply.github.com> Date: Mon, 20 Jan 2025 12:19:25 -0500 Subject: [PATCH 21/22] upstream LUS --- libultraship | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libultraship b/libultraship index 640ef65597..2e7d1fe6fd 160000 --- a/libultraship +++ b/libultraship @@ -1 +1 @@ -Subproject commit 640ef6559732944370046d54a9309b5a386ff4c1 +Subproject commit 2e7d1fe6fdc8ba7ea6ee0682b8f00f48b38a4e89 From 36a3133575b29fd7bef3e3713db95b64f73ee8f7 Mon Sep 17 00:00:00 2001 From: briaguya <70942617+briaguya-ai@users.noreply.github.com> Date: Mon, 20 Jan 2025 13:12:03 -0500 Subject: [PATCH 22/22] make `Controller_ShouldRumble` make sense --- soh/soh/OTRGlobals.cpp | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/soh/soh/OTRGlobals.cpp b/soh/soh/OTRGlobals.cpp index 7906937fb9..6d5430d699 100644 --- a/soh/soh/OTRGlobals.cpp +++ b/soh/soh/OTRGlobals.cpp @@ -1835,17 +1835,25 @@ extern "C" void AudioPlayer_Play(const uint8_t* buf, uint32_t len) { } extern "C" int Controller_ShouldRumble(size_t slot) { - for (auto [id, mapping] : Ship::Context::GetInstance() - ->GetControlDeck() - ->GetControllerByPort(static_cast(slot)) - ->GetRumble() - ->GetAllRumbleMappings()) { - if (true) { - return 1; - } + // don't rumble if we don't have rumble mappings + if (Ship::Context::GetInstance() + ->GetControlDeck() + ->GetControllerByPort(static_cast(slot)) + ->GetRumble() + ->GetAllRumbleMappings().empty()) { + return 0; } - return 0; + // don't rumble if we don't have connected gamepads + if (Ship::Context::GetInstance() + ->GetControlDeck() + ->GetConnectedPhysicalDeviceManager() + ->GetConnectedSDLGamepadsForPort(slot).empty()) { + return 0; + } + + // rumble + return 1; } extern "C" void* getN64WeirdFrame(s32 i) {