diff --git a/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE.cpp b/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE.cpp index ab5a6a6df8..50d8eff382 100644 --- a/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE.cpp +++ b/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE.cpp @@ -215,7 +215,7 @@ IWII_IPC_HLE_Device* CreateDevice(u32 _DeviceID, const std::string& _rDeviceName else { ERROR_LOG(WII_IPC_FILEIO, "Unknown device: %s", _rDeviceName.c_str()); - PanicAlert("Unknown device: %s", _rDeviceName.c_str()); + PanicAlert("Unknown device: %s", _rDeviceName.c_str()); pDevice = new CWII_IPC_HLE_Device_Error(u32(-1), _rDeviceName); } } diff --git a/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_net.cpp b/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_net.cpp index fd21c2b750..9cc204e902 100644 --- a/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_net.cpp +++ b/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_net.cpp @@ -56,6 +56,13 @@ #endif #include "WII_IPC_HLE_Device_net.h" +#include +#include +#include +#include +#include + + extern std::queue > g_ReplyQueueLater; @@ -100,32 +107,32 @@ bool CWII_IPC_HLE_Device_net_kd_request::IOCtl(u32 _CommandAddress) switch(Parameter) { case IOCTL_NWC24_SUSPEND_SCHEDULAR: // NWC24iResumeForCloseLib from NWC24SuspendScheduler (Input: none, Output: 32 bytes) - ERROR_LOG(WII_IPC_NET, "NET_KD_REQ: IOCTL_NWC24_SUSPEND_SCHEDULAR - NI"); + INFO_LOG(WII_IPC_NET, "NET_KD_REQ: IOCTL_NWC24_SUSPEND_SCHEDULAR - NI"); ReturnValue = 0; break; case IOCTL_NWC24_EXEC_TRY_SUSPEND_SCHEDULAR: // NWC24iResumeForCloseLib - ERROR_LOG(WII_IPC_NET, "NET_KD_REQ: IOCTL_NWC24_EXEC_TRY_SUSPEND_SCHEDULAR - NI"); + INFO_LOG(WII_IPC_NET, "NET_KD_REQ: IOCTL_NWC24_EXEC_TRY_SUSPEND_SCHEDULAR - NI"); ReturnValue = 0; break; case IOCTL_NWC24_UNK_3: // NWC24iResumeForCloseLib - ERROR_LOG(WII_IPC_NET, "NET_KD_REQ: IOCTL_NWC24_UNK_3 - NI"); + INFO_LOG(WII_IPC_NET, "NET_KD_REQ: IOCTL_NWC24_UNK_3 - NI"); ReturnValue = 0; break; case IOCTL_NWC24_STARTUP_SOCKET: - ERROR_LOG(WII_IPC_NET, "NET_KD_REQ: IOCTL_NWC24_STARTUP_SOCKET - NI"); + INFO_LOG(WII_IPC_NET, "NET_KD_REQ: IOCTL_NWC24_STARTUP_SOCKET - NI"); ReturnValue = 0; break; case IOCTL_NWC24_LOCK_SOCKET: // WiiMenu - ERROR_LOG(WII_IPC_NET, "NET_KD_REQ: IOCTL_NWC24_LOCK_SOCKET - NI"); + INFO_LOG(WII_IPC_NET, "NET_KD_REQ: IOCTL_NWC24_LOCK_SOCKET - NI"); ReturnValue = 0; break; case IOCTL_NWC24_UNLOCK_SOCKET: - ERROR_LOG(WII_IPC_NET, "NET_KD_REQ: IOCTL_NWC24_UNLOCK_SOCKET - NI"); + INFO_LOG(WII_IPC_NET, "NET_KD_REQ: IOCTL_NWC24_UNLOCK_SOCKET - NI"); ReturnValue = 0; break; @@ -135,22 +142,22 @@ bool CWII_IPC_HLE_Device_net_kd_request::IOCtl(u32 _CommandAddress) break; case IOCTL_NWC24_GET_SCHEDULAR_STAT: - ERROR_LOG(WII_IPC_NET, "NET_KD_REQ: IOCTL_NWC24_GET_SCHEDULAR_STAT - NI"); + INFO_LOG(WII_IPC_NET, "NET_KD_REQ: IOCTL_NWC24_GET_SCHEDULAR_STAT - NI"); ReturnValue = 0; break; case IOCTL_NWC24_SAVE_MAIL_NOW: - ERROR_LOG(WII_IPC_NET, "NET_KD_REQ: IOCTL_NWC24_SAVE_MAIL_NOW - NI"); + INFO_LOG(WII_IPC_NET, "NET_KD_REQ: IOCTL_NWC24_SAVE_MAIL_NOW - NI"); ReturnValue = 0; break; case IOCTL_NWC24_REQUEST_SHUTDOWN: - ERROR_LOG(WII_IPC_NET, "NET_KD_REQ: IOCTL_NWC24_REQUEST_SHUTDOWN - NI"); // if ya set the IOS version to a very high value this happens ... + INFO_LOG(WII_IPC_NET, "NET_KD_REQ: IOCTL_NWC24_REQUEST_SHUTDOWN - NI"); // if ya set the IOS version to a very high value this happens ... ReturnValue = 0; break; default: - _dbg_assert_msg_(WII_IPC_NET, 0, "/dev/net/kd/request::IOCtl request 0x%x (BufferIn: (%08x, %i), BufferOut: (%08x, %i)", + INFO_LOG(WII_IPC_NET, "/dev/net/kd/request::IOCtl request 0x%x (BufferIn: (%08x, %i), BufferOut: (%08x, %i)", Parameter, BufferIn, BufferInSize, BufferOut, BufferOutSize); break; } @@ -195,21 +202,18 @@ bool CWII_IPC_HLE_Device_net_ncd_manage::IOCtlV(u32 _CommandAddress) switch (CommandBuffer.Parameter) { // WiiMenu - case 0x03: + case 0x07: // //NCDGetLinkStatus + case 0x03: // ??? It seems that is related to Write and Read information case 0x04: case 0x05: case 0x06: - case 0x07: case 0x08: - break; + //break; default: - _dbg_assert_msg_(WII_IPC_NET, 0, "NET_NCD_MANAGE IOCtlV: %i", CommandBuffer.Parameter); + INFO_LOG(WII_IPC_NET,"NET_NCD_MANAGE IOCtlV: %i", CommandBuffer.Parameter); break; } - - INFO_LOG(WII_IPC_NET, "NET_NCD_MANAGE IOCtlV: %i", CommandBuffer.Parameter); - Memory::Write_U32(ReturnValue, _CommandAddress+4); return true; @@ -247,27 +251,98 @@ bool CWII_IPC_HLE_Device_net_ip_top::IOCtl(u32 _CommandAddress) u32 BufferOutSize = Memory::Read_U32(_CommandAddress + 0x1C); u32 Command = Memory::Read_U32(_CommandAddress + 0x0C); -// printf("%s - Command(0x%08x) BufferIn(0x%08x, 0x%x) BufferOut(0x%08x, 0x%x)\n", GetDeviceName().c_str(), Command, BufferIn, BufferInSize, BufferOut, BufferOutSize); +// INFO_LOG(WII_IPC_NET,"%s - Command(0x%08x) BufferIn(0x%08x, 0x%x) BufferOut(0x%08x, 0x%x)\n", GetDeviceName().c_str(), Command, BufferIn, BufferInSize, BufferOut, BufferOutSize); u32 ReturnValue = ExecuteCommand(Command, BufferIn, BufferInSize, BufferOut, BufferOutSize); Memory::Write_U32(ReturnValue, _CommandAddress + 0x4); return true; } - -s32 CWII_IPC_HLE_Device_net_ip_top::ExecuteCommand(u32 _Command, u32 _BufferIn, u32 BufferInSize, u32 BufferOut, u32 BufferOutSize) +struct bind_params { + u32 socket; + u32 has_name; + u8 name[28]; +}; +struct GC_sockaddr { + u8 sa_len; + u8 sa_family; + s8 sa_data[14]; +}; +struct GC_in_addr { + u32 s_addr; +}; +struct GC_sockaddr_in { + u8 sin_len; + u8 sin_family; + u16 sin_port; + struct GC_in_addr sin_addr; + s8 sin_zero[8]; +}; +u32 CWII_IPC_HLE_Device_net_ip_top::ExecuteCommand(u32 _Command, u32 _BufferIn, u32 BufferInSize, u32 BufferOut, u32 BufferOutSize) { // Clean the location of the output buffer to zeroes as a safety precaution */ Memory::Memset(BufferOut, 0, BufferOutSize); - INFO_LOG(WII_IPC_NET, "NET_IP_TOP IOCtlV: %i", _Command); - switch(_Command) { - case IOCTL_SO_GETHOSTID: return 127 << 24 | 1; + case IOCTL_SO_STARTUP: + break; + case IOCTL_SO_SOCKET: + { + u32 AF = Memory::Read_U32(_BufferIn); + u32 TYPE = Memory::Read_U32(_BufferIn + 0x04); + u32 PROT = Memory::Read_U32(_BufferIn + 0x04 * 2); + u32 Unk1 = Memory::Read_U32(_BufferIn + 0x04 * 3); + u32 Socket = socket(AF,TYPE,PROT); + return Common::swap32(Socket); // So it doesn't get mangled later on + } + break; + case IOCTL_SO_BIND: + { + bind_params *addr = (bind_params*)Memory::GetPointer(_BufferIn); + GC_sockaddr_in addrPC; + memcpy(&addrPC, addr->name, sizeof(GC_sockaddr_in)); + sockaddr_in address; + address.sin_family = addrPC.sin_family; + address.sin_addr.s_addr = addrPC.sin_addr.s_addr; + address.sin_port = htons(addrPC.sin_port); + int Return = bind(addr->socket, (sockaddr*)&address, sizeof(address)); + return Return; + //int bind(int s, struct sockaddr *addr, int addrlen); + } + break; + case IOCTL_SO_LISTEN: + { + u32 S = Memory::Read_U32(_BufferIn); + u32 BACKLOG = Memory::Read_U32(_BufferIn + 0x04); + u32 Return = listen(S, BACKLOG); + return Return; + } + break; + case IOCTL_SO_ACCEPT: + { + //TODO: (Sonic)Check if this is correct + u32 S = Memory::Read_U32(_BufferIn); + socklen_t addrlen; + struct sockaddr_in address; + int Return = accept(S, (struct sockaddr *)&address, &addrlen); + GC_sockaddr_in *addr = (GC_sockaddr_in*)Memory::GetPointer(BufferOut); + addr->sin_family = address.sin_family; + addr->sin_addr.s_addr = address.sin_addr.s_addr; + addr->sin_port = address.sin_port; + socklen_t *Len = (socklen_t *)Memory::GetPointer(BufferOut + 0x04); + *Len = addrlen; + return Return; + //int accept(int s, struct sockaddr *addr, int *addrlen); + ///dev/net/ip/top::IOCtl request 0x1 (BufferIn: (000318c0, 4), BufferOut: (00058a4c, 8) + } + break; + case IOCTL_SO_GETHOSTID: + return 127 << 24 | 1; + break; default: - _dbg_assert_msg_(WII_IPC_NET, 0, "/dev/net/ip/top::IOCtl request 0x%x (BufferIn: (%08x, %i), BufferOut: (%08x, %i)", + INFO_LOG(WII_IPC_NET,"/dev/net/ip/top::IOCtl request 0x%x (BufferIn: (%08x, %i), BufferOut: (%08x, %i)", _Command, _BufferIn, BufferInSize, BufferOut, BufferOutSize); break; } @@ -281,13 +356,16 @@ bool CWII_IPC_HLE_Device_net_ip_top::IOCtlV(u32 _CommandAddress) u32 ReturnValue = 0; SIOCtlVBuffer CommandBuffer(_CommandAddress); - - INFO_LOG(WII_IPC_NET, "NET_IP_TOP IOCtlV: %i", CommandBuffer.Parameter); - switch(CommandBuffer.Parameter) { - default: - INFO_LOG(WII_IPC_NET, "NET_IP_TOP IOCtlV: %i", CommandBuffer.Parameter); + case 2: + case 12: + case 15: + case 16: + case 31: + //break; + default: + INFO_LOG(WII_IPC_NET, "NET_IP_TOP IOCtlV: 0x%08X\n", CommandBuffer.Parameter); break; } diff --git a/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_net.h b/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_net.h index 4d3d7bd2fc..702fea73b1 100644 --- a/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_net.h +++ b/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_net.h @@ -199,7 +199,7 @@ private: IOCTL_SO_ICMPCLOSE // todo }; - s32 ExecuteCommand(u32 _Parameter, u32 _BufferIn, u32 _BufferInSize, u32 _BufferOut, u32 _BufferOutSize); + u32 ExecuteCommand(u32 _Parameter, u32 _BufferIn, u32 _BufferInSize, u32 _BufferOut, u32 _BufferOutSize); }; // ************************************************************************************** diff --git a/Source/Plugins/Plugin_Wiimote/Src/wiimote_real.cpp b/Source/Plugins/Plugin_Wiimote/Src/wiimote_real.cpp index f2fa82c1c7..8392102cae 100644 --- a/Source/Plugins/Plugin_Wiimote/Src/wiimote_real.cpp +++ b/Source/Plugins/Plugin_Wiimote/Src/wiimote_real.cpp @@ -349,6 +349,12 @@ int Initialize() g_NumberOfWiiMotes = wiiuse_find(g_WiiMotesFromWiiUse, MAX_WIIMOTES, 5); if (g_NumberOfWiiMotes > 0) g_RealWiiMotePresent = true; INFO_LOG(CONSOLE, "Found No of Wiimotes: %i\n", g_NumberOfWiiMotes); + // WiiUse initializes the Wiimotes in Windows right from the wiiuse_find function + // The Functionality should REALLY be changed + #ifndef _WIN32 + int Connect = wiiuse_connect(g_WiiMotesFromWiiUse, MAX_WIIMOTES); + INFO_LOG(CONSOLE, "Connected: %i\n", Connect); + #endif for (int i = 0; i < g_NumberOfWiiMotes; i++) { @@ -361,11 +367,6 @@ int Initialize() // Set flags //wiiuse_set_flags(g_WiiMotesFromWiiUse[i], NULL, WIIUSE_SMOOTHING); } - // I don't seem to need wiiuse_connect() in Windows. But Linux needs it. - #ifndef _WIN32 - int Connect = wiiuse_connect(g_WiiMotesFromWiiUse, MAX_WIIMOTES); - INFO_LOG(CONSOLE, "Connected: %i\n", Connect); - #endif // If we are connecting from the config window without a game running we flash the lights if (!g_EmulatorRunning && g_RealWiiMotePresent) FlashLights(true);