From 24cb6487d4e5f4a0f9bc50f3bc356175e57465b7 Mon Sep 17 00:00:00 2001 From: mathieui Date: Tue, 26 Jan 2016 00:21:13 +0100 Subject: [PATCH 1/5] [netplay] Fix a regression Introduced in 6e13496d8, pads would get assigned to their netplay position, which breaks assumptions. With this behavior, the SI devices should be mapped properly. --- Source/Core/Core/NetPlayClient.cpp | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/Source/Core/Core/NetPlayClient.cpp b/Source/Core/Core/NetPlayClient.cpp index ff94151f2b..de5e8a901a 100644 --- a/Source/Core/Core/NetPlayClient.cpp +++ b/Source/Core/Core/NetPlayClient.cpp @@ -758,13 +758,29 @@ bool NetPlayClient::ChangeGame(const std::string&) // called from ---NETPLAY--- thread void NetPlayClient::UpdateDevices() { - for (PadMapping i = 0; i < 4; i++) + u8 local_pad = 0; + // Add local pads first: + // As stated in the comment in NetPlayClient::GetNetPads, the pads pertaining + // to the local user are always locally mapped to the first gamecube ports, + // so they should be added first. + for (auto player_id : m_pad_map) { // Use local controller types for local controllers - if (m_pad_map[i] == m_local_player->pid) - SerialInterface::AddDevice(SConfig::GetInstance().m_SIDevice[i], i); - else - SerialInterface::AddDevice(m_pad_map[i] > 0 ? SIDEVICE_GC_CONTROLLER : SIDEVICE_NONE, i); + if (player_id == m_local_player->pid) + { + SerialInterface::AddDevice(SConfig::GetInstance().m_SIDevice[local_pad], local_pad); + local_pad++; + } + } + for (auto player_id : m_pad_map) + { + if (player_id != m_local_player->pid) + { + // Only GCController-like controllers are supported, GBA and similar + // exotic devices are not supported on netplay. + SerialInterface::AddDevice(player_id > 0 ? SIDEVICE_GC_CONTROLLER : SIDEVICE_NONE, local_pad); + local_pad++; + } } } From aaf2be2044a0ba0256c6583d1a4e095a32db00c5 Mon Sep 17 00:00:00 2001 From: mathieui Date: Wed, 27 Jan 2016 00:57:02 +0100 Subject: [PATCH 2/5] bootmanager: update the supposed-end-of-enum fixes a bug where gcadapter would fuck up netplay --- Source/Core/Core/BootManager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Core/Core/BootManager.cpp b/Source/Core/Core/BootManager.cpp index d2e3819651..0e059bd2ab 100644 --- a/Source/Core/Core/BootManager.cpp +++ b/Source/Core/Core/BootManager.cpp @@ -269,7 +269,7 @@ bool BootCore(const std::string& _rFilename) { int source; controls_section->Get(StringFromFormat("PadType%u", i), &source, -1); - if (source >= (int) SIDEVICE_NONE && source <= (int) SIDEVICE_AM_BASEBOARD) + if (source >= (int) SIDEVICE_NONE && source <= (int) SIDEVICE_WIIU_ADAPTER) { SConfig::GetInstance().m_SIDevice[i] = (SIDevices) source; config_cache.bSetPads[i] = true; From b9b4a0c530db82ea532abe51481f1a1edb0ef0ef Mon Sep 17 00:00:00 2001 From: mathieui Date: Thu, 28 Jan 2016 02:39:55 +0100 Subject: [PATCH 3/5] gcadapter: set the konga setting properly if it was used in netplay, it would read memory out of bounds (due to the mapping method returning 4 if the device was remote) which was 0 more often than not, causing the device in this position to be a konga. (which may or not be the gcadapter due to the swap between local and ingame controllers) --- Source/Core/Core/HW/SI_DeviceGCAdapter.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Source/Core/Core/HW/SI_DeviceGCAdapter.cpp b/Source/Core/Core/HW/SI_DeviceGCAdapter.cpp index 339130405b..9d96fadc3e 100644 --- a/Source/Core/Core/HW/SI_DeviceGCAdapter.cpp +++ b/Source/Core/Core/HW/SI_DeviceGCAdapter.cpp @@ -16,7 +16,8 @@ CSIDevice_GCAdapter::CSIDevice_GCAdapter(SIDevices device, int _iDeviceNumber) { // get the correct pad number that should rumble locally when using netplay const u8 numPAD = NetPlay_InGamePadToLocalPad(ISIDevice::m_iDeviceNumber); - m_simulate_konga = SConfig::GetInstance().m_AdapterKonga[numPAD]; + if (numPAD < 4) + m_simulate_konga = SConfig::GetInstance().m_AdapterKonga[numPAD]; } GCPadStatus CSIDevice_GCAdapter::GetPadStatus() From 4529930f914c1a2ba52f7d0c0df73097a92f5bfa Mon Sep 17 00:00:00 2001 From: mathieui Date: Thu, 28 Jan 2016 02:46:58 +0100 Subject: [PATCH 4/5] gcadapter: fix an incorrect mapping for non-local devices Remote devices would always enter an error path and get disconnected from the gamecube, breaking netplay in the process. Culprit is still InGamePadToLocalPad --- Source/Core/Core/HW/SI_DeviceGCAdapter.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/Source/Core/Core/HW/SI_DeviceGCAdapter.cpp b/Source/Core/Core/HW/SI_DeviceGCAdapter.cpp index 9d96fadc3e..974a8d79b4 100644 --- a/Source/Core/Core/HW/SI_DeviceGCAdapter.cpp +++ b/Source/Core/Core/HW/SI_DeviceGCAdapter.cpp @@ -40,12 +40,14 @@ int CSIDevice_GCAdapter::RunBuffer(u8* _pBuffer, int _iLength) // Read the command EBufferCommands command = static_cast(_pBuffer[3]); - // get the correct pad number that should rumble locally when using netplay const u8 numPAD = NetPlay_InGamePadToLocalPad(ISIDevice::m_iDeviceNumber); - if (!GCAdapter::DeviceConnected(numPAD)) + if (numPAD < 4) { - reinterpret_cast(_pBuffer)[0] = SI_NONE; - return 4; + if (!GCAdapter::DeviceConnected(numPAD)) + { + reinterpret_cast(_pBuffer)[0] = SI_NONE; + return 4; + } } // Handle it From c7750b287d5106b1f660393c6d2b9d058f8fbceb Mon Sep 17 00:00:00 2001 From: mathieui Date: Thu, 28 Jan 2016 20:24:18 +0100 Subject: [PATCH 5/5] netplay: default the local pad to a gc controller MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit if the configured local pad is none, it will make dolphin behave incorrectly (due to the game expecting inputs from the device while it doesn’t exist). --- Source/Core/Core/NetPlayClient.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Source/Core/Core/NetPlayClient.cpp b/Source/Core/Core/NetPlayClient.cpp index de5e8a901a..f76b097aa1 100644 --- a/Source/Core/Core/NetPlayClient.cpp +++ b/Source/Core/Core/NetPlayClient.cpp @@ -768,7 +768,14 @@ void NetPlayClient::UpdateDevices() // Use local controller types for local controllers if (player_id == m_local_player->pid) { - SerialInterface::AddDevice(SConfig::GetInstance().m_SIDevice[local_pad], local_pad); + if (SConfig::GetInstance().m_SIDevice[local_pad] != SIDEVICE_NONE) + { + SerialInterface::AddDevice(SConfig::GetInstance().m_SIDevice[local_pad], local_pad); + } + else + { + SerialInterface::AddDevice(SIDEVICE_GC_CONTROLLER, local_pad); + } local_pad++; } }