diff --git a/Source/Core/Core/Core.cpp b/Source/Core/Core/Core.cpp index 08a990542f..29e3181d66 100644 --- a/Source/Core/Core/Core.cpp +++ b/Source/Core/Core/Core.cpp @@ -498,6 +498,9 @@ static void EmuThread(std::unique_ptr boot, WindowSystemInfo wsi { Wiimote::LoadConfig(); } + + if (NetPlay::IsNetPlayRunning()) + NetPlay::SetupWiimotes(); } Common::ScopeGuard controller_guard{[init_controllers] { diff --git a/Source/Core/Core/NetPlayClient.cpp b/Source/Core/Core/NetPlayClient.cpp index 2ba5a4b57c..55d55b2543 100644 --- a/Source/Core/Core/NetPlayClient.cpp +++ b/Source/Core/Core/NetPlayClient.cpp @@ -52,7 +52,9 @@ #include "Core/Movie.h" #include "Core/PowerPC/PowerPC.h" #include "Core/WiiRoot.h" +#include "InputCommon/ControllerEmu/ControlGroup/Extension.h" #include "InputCommon/GCAdapter.h" +#include "InputCommon/InputConfig.h" #include "UICommon/GameFile.h" #include "VideoCommon/OnScreenDisplay.h" #include "VideoCommon/VideoConfig.h" @@ -558,11 +560,12 @@ unsigned int NetPlayClient::OnData(sf::Packet& packet) packet >> m_net_settings.m_OCFactor; packet >> m_net_settings.m_ReducePollingRate; - int tmp; - packet >> tmp; - m_net_settings.m_EXIDevice[0] = static_cast(tmp); - packet >> tmp; - m_net_settings.m_EXIDevice[1] = static_cast(tmp); + for (auto& device : m_net_settings.m_EXIDevice) + { + int tmp; + packet >> tmp; + device = static_cast(tmp); + } packet >> m_net_settings.m_EFBAccessEnable; packet >> m_net_settings.m_BBoxEnable; @@ -611,6 +614,9 @@ unsigned int NetPlayClient::OnData(sf::Packet& packet) packet >> m_net_settings.m_SyncCodes; packet >> m_net_settings.m_SyncAllWiiSaves; + for (int& extension : m_net_settings.m_WiimoteExtension) + packet >> extension; + m_net_settings.m_IsHosting = m_local_player->IsHost(); m_net_settings.m_HostInputAuthority = m_host_input_authority; } @@ -2173,6 +2179,23 @@ bool IsSyncingAllWiiSaves() return false; } +void SetupWiimotes() +{ + ASSERT(IsNetPlayRunning()); + const NetSettings& netplay_settings = netplay_client->GetNetSettings(); + const PadMappingArray& wiimote_map = netplay_client->GetWiimoteMapping(); + for (int i = 0; i < netplay_settings.m_WiimoteExtension.size(); i++) + { + if (wiimote_map[i] > 0) + { + static_cast( + static_cast(Wiimote::GetConfig()->GetController(i)) + ->GetWiimoteGroup(WiimoteEmu::WiimoteGroup::Extension)) + ->switch_extension = netplay_settings.m_WiimoteExtension[i]; + } + } +} + void NetPlay_Enable(NetPlayClient* const np) { std::lock_guard lk(crit_netplay_client); diff --git a/Source/Core/Core/NetPlayProto.h b/Source/Core/Core/NetPlayProto.h index 2e33069930..8934094728 100644 --- a/Source/Core/Core/NetPlayProto.h +++ b/Source/Core/Core/NetPlayProto.h @@ -36,7 +36,7 @@ struct NetSettings bool m_ReducePollingRate; bool m_OCEnable; float m_OCFactor; - ExpansionInterface::TEXIDevices m_EXIDevice[2]; + std::array m_EXIDevice; bool m_EFBAccessEnable; bool m_BBoxEnable; bool m_ForceProgressive; @@ -80,6 +80,7 @@ struct NetSettings bool m_SyncCodes; std::string m_SaveDataRegion; bool m_SyncAllWiiSaves; + std::array m_WiimoteExtension; bool m_IsHosting; bool m_HostInputAuthority; }; @@ -209,4 +210,5 @@ void ClearWiiSyncData(); void SetSIPollBatching(bool state); void SendPowerButtonEvent(); bool IsSyncingAllWiiSaves(); +void SetupWiimotes(); } // namespace NetPlay diff --git a/Source/Core/Core/NetPlayServer.cpp b/Source/Core/Core/NetPlayServer.cpp index e79c396319..70d6ccd189 100644 --- a/Source/Core/Core/NetPlayServer.cpp +++ b/Source/Core/Core/NetPlayServer.cpp @@ -42,12 +42,16 @@ #include "Core/HW/Sram.h" #include "Core/HW/WiiSave.h" #include "Core/HW/WiiSaveStructs.h" +#include "Core/HW/WiimoteEmu/WiimoteEmu.h" +#include "Core/HW/WiimoteReal/WiimoteReal.h" #include "Core/IOS/ES/ES.h" #include "Core/IOS/FS/FileSystem.h" #include "Core/IOS/IOS.h" #include "Core/NetPlayClient.h" //for NetPlayUI #include "DiscIO/Enums.h" +#include "InputCommon/ControllerEmu/ControlGroup/Extension.h" #include "InputCommon/GCPadStatus.h" +#include "InputCommon/InputConfig.h" #include "UICommon/GameFile.h" #if !defined(_WIN32) @@ -1159,8 +1163,10 @@ bool NetPlayServer::StartGame() spac << m_settings.m_OCEnable; spac << m_settings.m_OCFactor; spac << m_settings.m_ReducePollingRate; - spac << m_settings.m_EXIDevice[0]; - spac << m_settings.m_EXIDevice[1]; + + for (auto& device : m_settings.m_EXIDevice) + spac << device; + spac << m_settings.m_EFBAccessEnable; spac << m_settings.m_BBoxEnable; spac << m_settings.m_ForceProgressive; @@ -1206,6 +1212,16 @@ bool NetPlayServer::StartGame() spac << m_settings.m_SyncCodes; spac << m_settings.m_SyncAllWiiSaves; + for (int i = 0; i < m_settings.m_WiimoteExtension.size(); i++) + { + const int extension = + static_cast( + static_cast(Wiimote::GetConfig()->GetController(i)) + ->GetWiimoteGroup(WiimoteEmu::WiimoteGroup::Extension)) + ->switch_extension; + spac << extension; + } + SendAsyncToClients(std::move(spac)); m_start_pending = false;