From f9822cdd44636d01112f1f7bc3774487ba051995 Mon Sep 17 00:00:00 2001 From: Arisotura Date: Thu, 21 Feb 2019 03:06:37 +0100 Subject: [PATCH] save LAN settings --- src/Config.cpp | 4 ++++ src/Config.h | 2 ++ src/libui_sdl/DlgWifiSettings.cpp | 20 +++++++++++++++++++- 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/src/Config.cpp b/src/Config.cpp index 9fd3eb8c..bf010dc7 100644 --- a/src/Config.cpp +++ b/src/Config.cpp @@ -54,6 +54,8 @@ int DirectBoot; int Threaded3D; int SocketBindAnyAddr; +char LANDevice[128]; +int DirectLAN; int SavestateRelocSRAM; @@ -125,6 +127,8 @@ ConfigEntry ConfigFile[] = {"Threaded3D", 0, &Threaded3D, 1, NULL, 0}, {"SockBindAnyAddr", 0, &SocketBindAnyAddr, 0, NULL, 0}, + {"LANDevice", 1, LANDevice, 0, "", 127}, + {"DirectLAN", 0, &DirectLAN, 0, NULL, 0}, {"SavStaRelocSRAM", 0, &SavestateRelocSRAM, 0, NULL, 0}, diff --git a/src/Config.h b/src/Config.h index 68ef9d1c..701ea41f 100644 --- a/src/Config.h +++ b/src/Config.h @@ -59,6 +59,8 @@ extern int DirectBoot; extern int Threaded3D; extern int SocketBindAnyAddr; +extern char LANDevice[128]; +extern int DirectLAN; extern int SavestateRelocSRAM; diff --git a/src/libui_sdl/DlgWifiSettings.cpp b/src/libui_sdl/DlgWifiSettings.cpp index c94f1db5..4874c98a 100644 --- a/src/libui_sdl/DlgWifiSettings.cpp +++ b/src/libui_sdl/DlgWifiSettings.cpp @@ -53,6 +53,7 @@ void UpdateAdapterInfo() { int sel = uiComboboxSelected(cmAdapterList); if (sel < 0 || sel >= LAN::NumAdapters) return; + if (LAN::NumAdapters < 1) return; LAN::AdapterData* adapter = &LAN::Adapters[sel]; char tmp[64]; @@ -98,6 +99,19 @@ void OnCancel(uiButton* btn, void* blarg) void OnOk(uiButton* btn, void* blarg) { Config::SocketBindAnyAddr = uiCheckboxChecked(cbBindAnyAddr); + Config::DirectLAN = uiCheckboxChecked(cbDirectLAN); + + int sel = uiComboboxSelected(cmAdapterList); + if (sel < 0 || sel >= LAN::NumAdapters) sel = 0; + if (LAN::NumAdapters < 1) + { + Config::LANDevice[0] = '\0'; + } + else + { + strncpy(Config::LANDevice, LAN::Adapters[sel].DeviceName, 127); + Config::LANDevice[127] = '\0'; + } Config::Save(); @@ -193,11 +207,15 @@ void Open() LAN::AdapterData* adapter = &LAN::Adapters[i]; uiComboboxAppend(cmAdapterList, adapter->FriendlyName); + + if (!strncmp(adapter->DeviceName, Config::LANDevice, 128)) + sel = i; } - // TODO: select the right one! uiComboboxSetSelected(cmAdapterList, sel); UpdateAdapterInfo(); + uiCheckboxSetChecked(cbDirectLAN, Config::DirectLAN); + uiControlShow(uiControl(win)); }