From c2291bfee65ce5c4f4b34cc6e2e591636506f4c0 Mon Sep 17 00:00:00 2001 From: luigi__ Date: Sat, 8 Aug 2009 13:18:35 +0000 Subject: [PATCH] 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. --- desmume/src/NDSSystem.h | 16 ++++++- desmume/src/wifi.cpp | 14 +++++-- desmume/src/windows/main.cpp | 69 ++++++++++++++++++++++++------- desmume/src/windows/resource.h | 7 +++- desmume/src/windows/resources.rc | Bin 688412 -> 689430 bytes 5 files changed, 85 insertions(+), 21 deletions(-) diff --git a/desmume/src/NDSSystem.h b/desmume/src/NDSSystem.h index 87a470618..aff930b41 100644 --- a/desmume/src/NDSSystem.h +++ b/desmume/src/NDSSystem.h @@ -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; diff --git a/desmume/src/wifi.cpp b/desmume/src/wifi.cpp index c19ec2385..3d1dc1e88 100644 --- a/desmume/src/wifi.cpp +++ b/desmume/src/wifi.cpp @@ -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; } diff --git a/desmume/src/windows/main.cpp b/desmume/src/windows/main.cpp index f4461778d..5f8a541cf 100644 --- a/desmume/src/windows/main.cpp +++ b/desmume/src/windows/main.cpp @@ -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: diff --git a/desmume/src/windows/resource.h b/desmume/src/windows/resource.h index 6459abffc..b48f1d717 100644 --- a/desmume/src/windows/resource.h +++ b/desmume/src/windows/resource.h @@ -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 diff --git a/desmume/src/windows/resources.rc b/desmume/src/windows/resources.rc index 7b284be14615835b65107e0776fd89bc58062e22..fbae4c7e6af254f6d938a236fd2e2fb819afde98 100644 GIT binary patch delta 2672 zcmbtWZA=tL7@oV`*_*vP&btFS!1O!~9|r+)d>vn6L4l$uUsANxTC9lL610dIZ6w$< z*4U;YZp*7Jv642FkcLvIjuIudp~j}BYLn7GiqNVtw6>5mP1Kb3-GlRJa@#-6Wp8KR znP=YTeP-v`?Rq_-^H{>beX2BfML~yMwhY;&9$ldKlffegdMj*qo*i1g!`TL5b-Bl;4|#9(y`yp>(YfIlA5oFzmqF8h4aA% z7OmsUHwb-2p%r8m*+5>zYdtB)Uo|P=H%}+>5H;{EqjXv^5<#;~%}6j*OK1R3}VxnU|vwkp<@$uOQSGG1k&jSi@Ym7`%ShOXew zSo-oJzm66@m_fY(Gf?-TR?iy?XwFjfgfJbyu$5Yl_?$u6bhnouyHBee>V5$32RqXz z^^~eU(W3v~_RtywQ*lN!A2=xwB)Y-3BnT0;vlnn}EYXdX;V z8bn6}X(n6AUebd1ePkQn_hD;0OfC@}aIlMoFP_7s`mkxZW;U*oq0Aggfu@IS?V`Cv z=_DP)X~d&+{~QYa52+hwA2O$HZZu;a>>*yTO$w!OG+SrxoYq^Ru2o1jY$Ur#1K9$X4k7MOZ4&EtrYBx!Wr_V9N(I zI(|D+Yeibk{~}d@B9x#Msx%u=jw(_Ef5%FBCf~z=X|i#LZXe8r{FkU$x(o45zC=kV zt_xASvEPKzx%4gA&%yXY!53y&P1d3GMWl>W`(zJM_bY{XeD!B3Gba|qrOl!{Z6Ri! zm5*B)DZq^@S^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