Skip to content

Commit 640ef65

Browse files
committed
bring over stuff from soh input editor
1 parent 96e7d20 commit 640ef65

File tree

2 files changed

+20
-6
lines changed

2 files changed

+20
-6
lines changed

src/window/gui/InputEditorWindow.cpp

+19-5
Original file line numberDiff line numberDiff line change
@@ -1165,7 +1165,7 @@ void InputEditorWindow::DrawGyroSection(uint8_t port) {
11651165
}
11661166
}
11671167

1168-
void InputEditorWindow::DrawDeviceNameButtons() {
1168+
void InputEditorWindow::DrawDeviceToggles(uint8_t portIndex) {
11691169
ImGui::PushItemFlag(ImGuiItemFlags_Disabled, true);
11701170

11711171
auto keyboardButtonColor = ImGui::GetStyleColorVec4(ImGuiCol_Button);
@@ -1186,17 +1186,31 @@ void InputEditorWindow::DrawDeviceNameButtons() {
11861186
ImGui::PopStyleColor();
11871187
ImGui::PopStyleColor();
11881188

1189-
for (const auto& [instanceId, name] :
1190-
Context::GetInstance()->GetControlDeck()->GetConnectedPhysicalDeviceManager()->GetConnectedSDLGamepadNames()) {
1189+
ImGui::PopItemFlag();
1190+
1191+
auto connectedDeviceManager = Ship::Context::GetInstance()->GetControlDeck()->GetConnectedPhysicalDeviceManager();
1192+
for (const auto& [instanceId, name] : connectedDeviceManager->GetConnectedSDLGamepadNames()) {
1193+
ImGui::PushItemFlag(ImGuiItemFlags_Disabled, true);
11911194
auto buttonColor = ImGui::GetStyleColorVec4(ImGuiCol_Button);
11921195
auto buttonHoveredColor = ImGui::GetStyleColorVec4(ImGuiCol_ButtonHovered);
11931196
GetButtonColorsForPhysicalDeviceType(PhysicalDeviceType::SDLGamepad, buttonColor, buttonHoveredColor);
1194-
11951197
ImGui::PushStyleColor(ImGuiCol_Button, buttonColor);
11961198
ImGui::PushStyleColor(ImGuiCol_ButtonHovered, buttonHoveredColor);
1199+
auto notIgnored = !connectedDeviceManager->PortIsIgnoringInstanceId(portIndex, instanceId);
1200+
ImGui::PopItemFlag();
1201+
if (ImGui::Checkbox(StringHelper::Sprintf("###instanceId_%d", instanceId).c_str(), &notIgnored)) {
1202+
if (notIgnored) {
1203+
connectedDeviceManager->UnignoreInstanceIdForPort(portIndex, instanceId);
1204+
} else {
1205+
connectedDeviceManager->IgnoreInstanceIdForPort(portIndex, instanceId);
1206+
}
1207+
};
1208+
ImGui::PushItemFlag(ImGuiItemFlags_Disabled, true);
1209+
ImGui::SameLine();
11971210
ImGui::Button(StringHelper::Sprintf("%s %s (SDL)", ICON_FA_GAMEPAD, name.c_str()).c_str());
11981211
ImGui::PopStyleColor();
11991212
ImGui::PopStyleColor();
1213+
ImGui::PopItemFlag();
12001214
}
12011215
}
12021216

@@ -1221,7 +1235,7 @@ void InputEditorWindow::DrawPortTab(uint8_t portIndex) {
12211235
if (ImGui::BeginTabItem(StringHelper::Sprintf("Port %d###port%d", portIndex + 1, portIndex).c_str())) {
12221236
DrawClearAllButton(portIndex);
12231237
DrawSetDefaultsButton(portIndex);
1224-
DrawDeviceNameButtons();
1238+
DrawDeviceToggles(portIndex);
12251239

12261240
UpdateBitmaskToMappingIds(portIndex);
12271241
UpdateStickDirectionToMappingIds(portIndex);

src/window/gui/InputEditorWindow.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ class InputEditorWindow : public GuiWindow {
7272
void DrawSetDefaultsButton(uint8_t portIndex);
7373
void DrawClearAllButton(uint8_t portIndex);
7474

75-
void DrawDeviceNameButtons();
75+
void DrawDeviceToggles(uint8_t portIndex);
7676
void OffsetMappingPopup();
7777
};
7878
} // namespace Ship

0 commit comments

Comments
 (0)