Wifi: modify wifi settings dialog, add two modes: Ad-hoc and infrastructure.

Disable Infrastructure as it's just SoftAP, it doesn't work yet and I'm
going to focus on Ad-hoc mode for the moment.
This commit is contained in:
luigi__ 2009-08-08 13:18:35 +00:00
parent aa32f62368
commit c2291bfee6
5 changed files with 85 additions and 21 deletions

View File

@ -400,7 +400,6 @@ extern struct TCommonSettings {
, BootFromFirmware(false)
, DebugConsole(false)
, single_core(true)
, wifiBridgeAdapterNum(0)
, spuInterpolationMode(SPUInterpolation_Linear)
, spuAdpcmCache(false)
, gfx3d_flushMode(0)
@ -409,6 +408,12 @@ extern struct TCommonSettings {
strcpy(ARM9BIOS, "biosnds9.bin");
strcpy(ARM7BIOS, "biosnds7.bin");
strcpy(Firmware, "firmware.bin");
wifi.mode = 0;
wifi.adhocMode = 0;
strcpy(wifi.adhocServerName, "");
wifi.infraBridgeAdapter = 0;
for(int i=0;i<16;i++)
spu_muteChannels[i] = false;
}
@ -427,7 +432,14 @@ extern struct TCommonSettings {
bool single_core;
int wifiBridgeAdapterNum;
struct _Wifi {
int mode;
int adhocMode;
char adhocServerName[64];
int infraBridgeAdapter;
} wifi;
SPUInterpolationMode spuInterpolationMode;
bool spuAdpcmCache;

View File

@ -209,10 +209,16 @@ FW_WFCProfile FW_WFCProfile3 = {"",
// 5: highest logging, for debugging, shows everything, may slow down a lot
#define WIFI_LOGGING_LEVEL 3
#define WIFI_LOG_USE_LOGC 0
#if (WIFI_LOGGING_LEVEL >= 1)
#define WIFI_LOG(level, ...) if(level <= WIFI_LOGGING_LEVEL) LOGC(8, "WIFI: "__VA_ARGS__);
#if WIFI_LOG_USE_LOGC
#define WIFI_LOG(level, ...) if(level <= WIFI_LOGGING_LEVEL) LOGC(8, "WIFI: "__VA_ARGS__);
#else
#define WIFI_LOG(level, ...) if(level <= WIFI_LOGGING_LEVEL) printf("WIFI: "__VA_ARGS__);
#endif
#else
#define WIFI_LOG(level, ...)
#define WIFI_LOG(level, ...) {}
#endif
/*******************************************************************************
@ -1271,6 +1277,7 @@ int WIFI_SoftAP_Init(wifimac_t *wifi)
wifi->SoftAP.curPacketPos = 0;
wifi->SoftAP.curPacketSending = FALSE;
#if 0
if(wifi_netEnabled)
{
if(desmume_pcap_findalldevs(&alldevs, errbuf) == -1)
@ -1279,7 +1286,7 @@ int WIFI_SoftAP_Init(wifimac_t *wifi)
return 0;
}
wifi_bridge = desmume_pcap_open(WIFI_index_device(alldevs,CommonSettings.wifiBridgeAdapterNum)->name, PACKET_SIZE, 0, 1, errbuf);
wifi_bridge = desmume_pcap_open(WIFI_index_device(alldevs,CommonSettings.wifi.infraBridgeAdapter)->name, PACKET_SIZE, 0, 1, errbuf);
if(wifi_bridge == NULL)
{
printf("SoftAP: PCAP error with pcap_open(): %s\n", errbuf);
@ -1288,6 +1295,7 @@ int WIFI_SoftAP_Init(wifimac_t *wifi)
desmume_pcap_freealldevs(alldevs);
}
#endif
return 1;
}

View File

@ -1823,7 +1823,10 @@ int _main()
GetPrivateProfileString("Firmware", "FirmwareFile", "firmware.bin", CommonSettings.Firmware, 256, IniName);
CommonSettings.BootFromFirmware = GetPrivateProfileBool("Firmware", "BootFromFirmware", FALSE, IniName);
CommonSettings.wifiBridgeAdapterNum = GetPrivateProfileInt("Wifi", "BridgeAdapter", 0, IniName);
CommonSettings.wifi.mode = GetPrivateProfileInt("Wifi", "Mode", 0, IniName);
CommonSettings.wifi.adhocMode = GetPrivateProfileInt("Wifi", "AdhocMode", 0, IniName);
GetPrivateProfileString("Wifi", "AdhocServerName", "", CommonSettings.wifi.adhocServerName, 64, IniName);
CommonSettings.wifi.infraBridgeAdapter = GetPrivateProfileInt("Wifi", "BridgeAdapter", 0, IniName);
video.currentfilter = GetPrivateProfileInt("Video", "Filter", video.NONE, IniName);
FilterUpdate(MainWindow->getHWnd(),false);
@ -2653,7 +2656,7 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM
DesEnableMenuItem(mainMenu, IDM_SHUT_UP, romloaded);
DesEnableMenuItem(mainMenu, IDM_CHEATS_LIST, romloaded);
DesEnableMenuItem(mainMenu, IDM_CHEATS_SEARCH, romloaded);
DesEnableMenuItem(mainMenu, IDM_WIFISETTINGS, romloaded);
//DesEnableMenuItem(mainMenu, IDM_WIFISETTINGS, romloaded);
DesEnableMenuItem(mainMenu, IDM_RECORD_MOVIE, (romloaded && movieMode == MOVIEMODE_INACTIVE));
DesEnableMenuItem(mainMenu, IDM_PLAY_MOVIE, (romloaded && movieMode == MOVIEMODE_INACTIVE));
@ -4254,12 +4257,22 @@ LRESULT CALLBACK WifiSettingsDlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM
{
case WM_INITDIALOG:
{
#if 0
char errbuf[PCAP_ERRBUF_SIZE];
pcap_if_t *alldevs;
pcap_if_t *d;
int i;
#endif
HWND cur;
CheckRadioButton(hDlg, IDC_WIFIMODE0, IDC_WIFIMODE1, IDC_WIFIMODE0 + CommonSettings.wifi.mode);
CheckRadioButton(hDlg, IDC_ADHOC_SERVER, IDC_ADHOC_CLIENT, CommonSettings.wifi.adhocMode ? IDC_ADHOC_CLIENT:IDC_ADHOC_SERVER);
cur = GetDlgItem(hDlg, IDC_ADHOC_SERVERNAME);
SetWindowText(cur, CommonSettings.wifi.adhocServerName);
EnableWindow(cur, (CommonSettings.wifi.adhocMode == 1) ? TRUE:FALSE);
#if 0
if(PCAP::pcap_findalldevs_ex(PCAP_SRC_IF_STRING, NULL, &alldevs, errbuf) == -1)
{
EndDialog(hDlg, TRUE);
@ -4271,7 +4284,8 @@ LRESULT CALLBACK WifiSettingsDlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM
{
ComboBox_AddString(cur, d->description);
}
ComboBox_SetCurSel(cur, CommonSettings.wifiBridgeAdapterNum);
ComboBox_SetCurSel(cur, CommonSettings.wifi.infraBridgeAdapter);
#endif
}
return TRUE;
@ -4279,6 +4293,14 @@ LRESULT CALLBACK WifiSettingsDlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM
{
switch(LOWORD(wParam))
{
case IDC_ADHOC_SERVER:
case IDC_ADHOC_CLIENT:
{
HWND cur = GetDlgItem(hDlg, IDC_ADHOC_SERVERNAME);
EnableWindow(cur, (LOWORD(wParam) == IDC_ADHOC_CLIENT) ? TRUE:FALSE);
}
return TRUE;
case IDOK:
{
int val = 0;
@ -4286,19 +4308,36 @@ LRESULT CALLBACK WifiSettingsDlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM
if(romloaded)
val = MessageBox(hDlg, "The current ROM needs to be reset to apply changes.\nReset now ?", "DeSmuME", (MB_YESNO | MB_ICONQUESTION));
if((!romloaded) || (val == IDYES))
HWND cur;
#if 0
if (IsDlgButtonChecked(hDlg, IDC_WIFIMODE0))
CommonSettings.wifi.mode = 0;
else
CommonSettings.wifi.mode = 1;
WritePrivateProfileInt("Wifi", "Mode", CommonSettings.wifi.mode, IniName);
cur = GetDlgItem(hDlg, IDC_BRIDGEADAPTER);
CommonSettings.wifi.infraBridgeAdapter = ComboBox_GetCurSel(cur);
WritePrivateProfileInt("Wifi", "BridgeAdapter", CommonSettings.wifi.infraBridgeAdapter, IniName);
#else
CommonSettings.wifi.mode = 0;
WritePrivateProfileInt("Wifi", "Mode", CommonSettings.wifi.mode, IniName);
#endif
if (IsDlgButtonChecked(hDlg, IDC_ADHOC_SERVER))
CommonSettings.wifi.adhocMode = 0;
else
CommonSettings.wifi.adhocMode = 1;
WritePrivateProfileInt("Wifi", "AdhocMode", CommonSettings.wifi.adhocMode, IniName);
cur = GetDlgItem(hDlg, IDC_ADHOC_SERVERNAME);
GetWindowText(cur, CommonSettings.wifi.adhocServerName, 64);
WritePrivateProfileString("Wifi", "AdhocServerName", CommonSettings.wifi.adhocServerName, IniName);
if(val == IDYES)
{
HWND cur;
cur = GetDlgItem(hDlg, IDC_BRIDGEADAPTER);
CommonSettings.wifiBridgeAdapterNum = ComboBox_GetCurSel(cur);
WritePrivateProfileInt("Wifi", "BridgeAdapter", CommonSettings.wifiBridgeAdapterNum, IniName);
if(romloaded)
{
NDS_Reset();
}
NDS_Reset();
}
}
case IDCANCEL:

View File

@ -311,20 +311,25 @@
#define IDC_ROTATE270 1006
#define IDC_SPU_CACHE 1006
#define IDC_GRED 1006
#define IDC_WIFIMODE0 1006
#define IDC_ARM7BIOSBROWSE 1007
#define IDC_EDIT06 1007
#define IDC_GYELLOW 1007
#define IDC_WIFIMODE1 1007
#define IDC_EDIT09 1008
#define IDC_MEMVIEWBOX 1008
#define IDC_GBLUE 1008
#define IDC_ADHOC_SERVER 1008
#define IDC_ADDRESS 1009
#define IDC_BIOSSWIS 1009
#define IDC_EDIT10 1009
#define IDC_FORCERATIO 1009
#define IDC_ADHOC_CLIENT 1009
#define IDC_AUTO_UPDATE_SPIN 1010
#define IDC_EDIT15 1010
#define IDC_TEXTDUMP 1010
#define IDC_WINDOW1X 1010
#define IDC_ADHOC_SERVERNAME 1010
#define IDC_AUTO_UPDATE_SECS 1011
#define IDC_USEEXTFIRMWARE 1011
#define IDC_WINDOW2X 1011
@ -801,7 +806,7 @@
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 105
#define _APS_NEXT_COMMAND_VALUE 40008
#define _APS_NEXT_CONTROL_VALUE 1006
#define _APS_NEXT_CONTROL_VALUE 1011
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif

Binary file not shown.