From f1b92329339760f44be48391481a6d5fa1759a57 Mon Sep 17 00:00:00 2001 From: Andrea Odetti Date: Sun, 18 Apr 2021 19:01:05 +0100 Subject: [PATCH] Add Uthernet configuration. Signed-off-by: Andrea Odetti --- source/frontends/sdl/imgui/sdlsettings.cpp | 38 +++++++++++++++++++ source/frontends/sdl/imgui/settingshelper.cpp | 19 ++++++---- 2 files changed, 50 insertions(+), 7 deletions(-) diff --git a/source/frontends/sdl/imgui/sdlsettings.cpp b/source/frontends/sdl/imgui/sdlsettings.cpp index 589330f0..44547986 100644 --- a/source/frontends/sdl/imgui/sdlsettings.cpp +++ b/source/frontends/sdl/imgui/sdlsettings.cpp @@ -21,6 +21,9 @@ #include "Debugger/Debug.h" #include "Debugger/DebugDefs.h" +#include "Tfe/tfe.h" +#include "Tfe/tfesupp.h" + #include "imgui_internal.h" namespace @@ -548,6 +551,41 @@ namespace sa2 ImGui::EndTabItem(); } + if (ImGui::BeginTabItem("Uthernet")) + { + standardLabelText("Status", tfe_enabled ? "enabled" : "disabled"); + if (ImGui::BeginCombo("Interface", static_cast(get_tfe_interface()))) + { + if (tfe_enumadapter_open()) + { + char *pname; + char *pdescription; + + while (tfe_enumadapter(&pname, &pdescription)) + { + // must call it each time + // as update_tfe_interface() will invalidate it + const char * current = static_cast(get_tfe_interface()); + const bool isSelected = strcmp(pname, current) == 0; + if (ImGui::Selectable(pname, isSelected)) + { + update_tfe_interface(pname, nullptr); + RegSaveString(TEXT(REG_CONFIG), TEXT(REGVALUE_UTHERNET_INTERFACE), 1, pname); + } + if (isSelected) + { + ImGui::SetItemDefaultFocus(); + } + lib_free(pname); + lib_free(pdescription); + } + tfe_enumadapter_close(); + } + ImGui::EndCombo(); + } + ImGui::EndTabItem(); + } + if (ImGui::BeginTabItem("Debugger")) { if (ImGui::RadioButton("Color", g_iColorScheme == SCHEME_COLOR)) { g_iColorScheme = SCHEME_COLOR; } ImGui::SameLine(); diff --git a/source/frontends/sdl/imgui/settingshelper.cpp b/source/frontends/sdl/imgui/settingshelper.cpp index 9c4ebf5d..25e82b34 100644 --- a/source/frontends/sdl/imgui/settingshelper.cpp +++ b/source/frontends/sdl/imgui/settingshelper.cpp @@ -153,21 +153,26 @@ namespace sa2 switch (slot) { + case 3: + { + const bool enabled = card == CT_Uthernet; + REGSAVE(REGVALUE_UTHERNET_ACTIVE, enabled); + // needs a reboot anyway + break; + } case 7: { const bool enabled = card == CT_GenericHDD; REGSAVE(REGVALUE_HDD_ENABLED, enabled); HD_SetEnabled(enabled); - } - default: - { - // we do not use REGVALUE_SLOT5 as they are not "runtime friendly" - const std::string label = "Slot " + std::to_string(slot); - REGSAVE(label.c_str(), (DWORD)card); - cardManager.Insert(slot, card); break; } }; + + // we do not use REGVALUE_SLOT5 as they are not "runtime friendly" + const std::string label = "Slot " + std::to_string(slot); + REGSAVE(label.c_str(), (DWORD)card); + cardManager.Insert(slot, card); } void setVideoStyle(Video & video, const VideoStyle_e style, const bool enabled)