Merge pull request #3569 from mathieui/netplay-gcpad-position

[netplay] Fix a regression
This commit is contained in:
Pierre Bourdon 2016-01-30 11:54:31 +01:00
commit 9da8593cf4
3 changed files with 37 additions and 11 deletions

View File

@ -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;

View File

@ -16,6 +16,7 @@ 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);
if (numPAD < 4)
m_simulate_konga = SConfig::GetInstance().m_AdapterKonga[numPAD];
}
@ -39,13 +40,15 @@ int CSIDevice_GCAdapter::RunBuffer(u8* _pBuffer, int _iLength)
// Read the command
EBufferCommands command = static_cast<EBufferCommands>(_pBuffer[3]);
// get the correct pad number that should rumble locally when using netplay
const u8 numPAD = NetPlay_InGamePadToLocalPad(ISIDevice::m_iDeviceNumber);
if (numPAD < 4)
{
if (!GCAdapter::DeviceConnected(numPAD))
{
reinterpret_cast<u32*>(_pBuffer)[0] = SI_NONE;
return 4;
}
}
// Handle it
switch (command)

View File

@ -758,13 +758,36 @@ 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);
if (player_id == m_local_player->pid)
{
if (SConfig::GetInstance().m_SIDevice[local_pad] != SIDEVICE_NONE)
{
SerialInterface::AddDevice(SConfig::GetInstance().m_SIDevice[local_pad], local_pad);
}
else
SerialInterface::AddDevice(m_pad_map[i] > 0 ? SIDEVICE_GC_CONTROLLER : SIDEVICE_NONE, i);
{
SerialInterface::AddDevice(SIDEVICE_GC_CONTROLLER, 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++;
}
}
}