mirror of
https://github.com/melonDS-emu/melonDS.git
synced 2025-07-23 14:19:55 -06:00
rework wifi settings dialog.
fail gracefully if pcap isn't loaded successfully.
This commit is contained in:
@ -30,6 +30,13 @@
|
|||||||
#include "DlgWifiSettings.h"
|
#include "DlgWifiSettings.h"
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef __WIN32__
|
||||||
|
#define PCAP_NAME "winpcap/npcap"
|
||||||
|
#else
|
||||||
|
#define PCAP_NAME "libpcap"
|
||||||
|
#endif // __WIN32__
|
||||||
|
|
||||||
|
|
||||||
void ApplyNewSettings(int type);
|
void ApplyNewSettings(int type);
|
||||||
|
|
||||||
|
|
||||||
@ -43,6 +50,7 @@ bool haspcap;
|
|||||||
|
|
||||||
uiCheckbox* cbBindAnyAddr;
|
uiCheckbox* cbBindAnyAddr;
|
||||||
|
|
||||||
|
uiLabel* lbAdapterList;
|
||||||
uiCombobox* cmAdapterList;
|
uiCombobox* cmAdapterList;
|
||||||
uiCheckbox* cbDirectLAN;
|
uiCheckbox* cbDirectLAN;
|
||||||
|
|
||||||
@ -52,8 +60,30 @@ uiLabel* lbAdapterDNS0;
|
|||||||
uiLabel* lbAdapterDNS1;
|
uiLabel* lbAdapterDNS1;
|
||||||
|
|
||||||
|
|
||||||
|
void UpdateAdapterControls()
|
||||||
|
{
|
||||||
|
bool enable = haspcap && uiCheckboxChecked(cbDirectLAN);
|
||||||
|
|
||||||
|
if (enable)
|
||||||
|
{
|
||||||
|
uiControlEnable(uiControl(lbAdapterList));
|
||||||
|
uiControlEnable(uiControl(cmAdapterList));
|
||||||
|
uiControlEnable(uiControl(lbAdapterMAC));
|
||||||
|
uiControlEnable(uiControl(lbAdapterIP));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
uiControlDisable(uiControl(lbAdapterList));
|
||||||
|
uiControlDisable(uiControl(cmAdapterList));
|
||||||
|
uiControlDisable(uiControl(lbAdapterMAC));
|
||||||
|
uiControlDisable(uiControl(lbAdapterIP));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void UpdateAdapterInfo()
|
void UpdateAdapterInfo()
|
||||||
{
|
{
|
||||||
|
if (!haspcap) return;
|
||||||
|
|
||||||
int sel = uiComboboxSelected(cmAdapterList);
|
int sel = uiComboboxSelected(cmAdapterList);
|
||||||
if (sel < 0 || sel >= LAN_PCap::NumAdapters) return;
|
if (sel < 0 || sel >= LAN_PCap::NumAdapters) return;
|
||||||
if (LAN_PCap::NumAdapters < 1) return;
|
if (LAN_PCap::NumAdapters < 1) return;
|
||||||
@ -71,7 +101,7 @@ void UpdateAdapterInfo()
|
|||||||
adapter->IP_v4[2], adapter->IP_v4[3]);
|
adapter->IP_v4[2], adapter->IP_v4[3]);
|
||||||
uiLabelSetText(lbAdapterIP, tmp);
|
uiLabelSetText(lbAdapterIP, tmp);
|
||||||
|
|
||||||
sprintf(tmp, "Primary DNS: %d.%d.%d.%d",
|
/*sprintf(tmp, "Primary DNS: %d.%d.%d.%d",
|
||||||
adapter->DNS[0][0], adapter->DNS[0][1],
|
adapter->DNS[0][0], adapter->DNS[0][1],
|
||||||
adapter->DNS[0][2], adapter->DNS[0][3]);
|
adapter->DNS[0][2], adapter->DNS[0][3]);
|
||||||
uiLabelSetText(lbAdapterDNS0, tmp);
|
uiLabelSetText(lbAdapterDNS0, tmp);
|
||||||
@ -79,7 +109,7 @@ void UpdateAdapterInfo()
|
|||||||
sprintf(tmp, "Secondary DNS: %d.%d.%d.%d",
|
sprintf(tmp, "Secondary DNS: %d.%d.%d.%d",
|
||||||
adapter->DNS[1][0], adapter->DNS[1][1],
|
adapter->DNS[1][0], adapter->DNS[1][1],
|
||||||
adapter->DNS[1][2], adapter->DNS[1][3]);
|
adapter->DNS[1][2], adapter->DNS[1][3]);
|
||||||
uiLabelSetText(lbAdapterDNS1, tmp);
|
uiLabelSetText(lbAdapterDNS1, tmp);*/
|
||||||
}
|
}
|
||||||
|
|
||||||
int OnCloseWindow(uiWindow* window, void* blarg)
|
int OnCloseWindow(uiWindow* window, void* blarg)
|
||||||
@ -88,6 +118,11 @@ int OnCloseWindow(uiWindow* window, void* blarg)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void OnDirectModeToggle(uiCheckbox* c, void* blarg)
|
||||||
|
{
|
||||||
|
UpdateAdapterControls();
|
||||||
|
}
|
||||||
|
|
||||||
void OnAdapterSelect(uiCombobox* c, void* blarg)
|
void OnAdapterSelect(uiCombobox* c, void* blarg)
|
||||||
{
|
{
|
||||||
UpdateAdapterInfo();
|
UpdateAdapterInfo();
|
||||||
@ -166,24 +201,25 @@ void Open()
|
|||||||
uiBox* in_ctrl = uiNewVerticalBox();
|
uiBox* in_ctrl = uiNewVerticalBox();
|
||||||
uiGroupSetChild(grp, uiControl(in_ctrl));
|
uiGroupSetChild(grp, uiControl(in_ctrl));
|
||||||
|
|
||||||
lbl = uiNewLabel("Network adapter:");
|
cbDirectLAN = uiNewCheckbox("Direct mode (requires " PCAP_NAME " and ethernet connection)");
|
||||||
uiBoxAppend(in_ctrl, uiControl(lbl), 0);
|
uiCheckboxOnToggled(cbDirectLAN, OnDirectModeToggle, NULL);
|
||||||
|
uiBoxAppend(in_ctrl, uiControl(cbDirectLAN), 0);
|
||||||
|
|
||||||
|
lbAdapterList = uiNewLabel("Network adapter:");
|
||||||
|
uiBoxAppend(in_ctrl, uiControl(lbAdapterList), 0);
|
||||||
|
|
||||||
cmAdapterList = uiNewCombobox();
|
cmAdapterList = uiNewCombobox();
|
||||||
uiComboboxOnSelected(cmAdapterList, OnAdapterSelect, NULL);
|
uiComboboxOnSelected(cmAdapterList, OnAdapterSelect, NULL);
|
||||||
uiBoxAppend(in_ctrl, uiControl(cmAdapterList), 0);
|
uiBoxAppend(in_ctrl, uiControl(cmAdapterList), 0);
|
||||||
|
|
||||||
lbAdapterMAC = uiNewLabel("MAC");
|
lbAdapterMAC = uiNewLabel("MAC: ??");
|
||||||
uiBoxAppend(in_ctrl, uiControl(lbAdapterMAC), 0);
|
uiBoxAppend(in_ctrl, uiControl(lbAdapterMAC), 0);
|
||||||
lbAdapterIP = uiNewLabel("IP");
|
lbAdapterIP = uiNewLabel("IP: ??");
|
||||||
uiBoxAppend(in_ctrl, uiControl(lbAdapterIP), 0);
|
uiBoxAppend(in_ctrl, uiControl(lbAdapterIP), 0);
|
||||||
lbAdapterDNS0 = uiNewLabel("DNS0");
|
/*lbAdapterDNS0 = uiNewLabel("DNS0");
|
||||||
uiBoxAppend(in_ctrl, uiControl(lbAdapterDNS0), 0);
|
uiBoxAppend(in_ctrl, uiControl(lbAdapterDNS0), 0);
|
||||||
lbAdapterDNS1 = uiNewLabel("DNS1");
|
lbAdapterDNS1 = uiNewLabel("DNS1");
|
||||||
uiBoxAppend(in_ctrl, uiControl(lbAdapterDNS1), 0);
|
uiBoxAppend(in_ctrl, uiControl(lbAdapterDNS1), 0);*/
|
||||||
|
|
||||||
cbDirectLAN = uiNewCheckbox("Direct mode (requires ethernet connection)");
|
|
||||||
uiBoxAppend(in_ctrl, uiControl(cbDirectLAN), 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
@ -217,8 +253,10 @@ void Open()
|
|||||||
}
|
}
|
||||||
uiComboboxSetSelected(cmAdapterList, sel);
|
uiComboboxSetSelected(cmAdapterList, sel);
|
||||||
UpdateAdapterInfo();
|
UpdateAdapterInfo();
|
||||||
|
UpdateAdapterControls();
|
||||||
|
|
||||||
uiCheckboxSetChecked(cbDirectLAN, Config::DirectLAN);
|
uiCheckboxSetChecked(cbDirectLAN, Config::DirectLAN);
|
||||||
|
if (!haspcap) uiControlDisable(uiControl(cbDirectLAN));
|
||||||
|
|
||||||
uiControlShow(uiControl(win));
|
uiControlShow(uiControl(win));
|
||||||
}
|
}
|
||||||
|
@ -111,6 +111,8 @@ bool Init()
|
|||||||
PacketLen = 0;
|
PacketLen = 0;
|
||||||
RXNum = 0;
|
RXNum = 0;
|
||||||
|
|
||||||
|
NumAdapters = 0;
|
||||||
|
|
||||||
for (int i = 0; PCapLibNames[i]; i++)
|
for (int i = 0; PCapLibNames[i]; i++)
|
||||||
{
|
{
|
||||||
void* lib = SDL_LoadObject(PCapLibNames[i]);
|
void* lib = SDL_LoadObject(PCapLibNames[i]);
|
||||||
|
Reference in New Issue
Block a user