NetPlay: Don't bother with the host's controller settings

Use the pad mapping to calculate the number of devices
we want, and add them on each client when we get the
message.
This commit is contained in:
Jasper St. Pierre 2013-08-23 20:24:45 -04:00
parent b187a38433
commit 22f57cf07a
6 changed files with 18 additions and 13 deletions

View File

@ -262,9 +262,7 @@ void Init()
if (Movie::IsRecordingInput() || Movie::IsPlayingInput())
AddDevice(Movie::IsUsingPad(i) ? (Movie::IsUsingBongo(i) ? SIDEVICE_GC_TARUKONGA : SIDEVICE_GC_CONTROLLER) : SIDEVICE_NONE, i);
else if (NetPlay::IsNetPlayRunning())
AddDevice((SIDevices) g_NetPlaySettings.m_Controllers[i], i);
else
else if (!NetPlay::IsNetPlayRunning())
AddDevice(SConfig::GetInstance().m_SIDevice[i], i);
}
@ -567,7 +565,7 @@ void AddDevice(ISIDevice* pDevice)
void AddDevice(const SIDevices _device, int _iDeviceNumber)
{
ISIDevice* pDevice = SIDevice_Create(_device, _iDeviceNumber);
ISIDevice *pDevice = SIDevice_Create(_device, _iDeviceNumber);
AddDevice(pDevice);
}

View File

@ -8,6 +8,7 @@
#include "IPC_HLE/WII_IPC_HLE_Device_usb.h"
#include "IPC_HLE/WII_IPC_HLE_WiiMote.h"
// for gcpad
#include "HW/SI.h"
#include "HW/SI_DeviceGCController.h"
#include "HW/SI_DeviceGCSteeringWheel.h"
#include "HW/SI_DeviceDanceMat.h"
@ -187,6 +188,8 @@ unsigned int NetPlayClient::OnData(sf::Packet& packet)
for (PadMapping i = 0; i < 4; i++)
packet >> m_pad_map[i];
UpdateDevices();
m_dialog->Update();
}
break;
@ -233,8 +236,6 @@ unsigned int NetPlayClient::OnData(sf::Packet& packet)
packet >> g_NetPlaySettings.m_DSPEnableJIT;
packet >> g_NetPlaySettings.m_DSPHLE;
packet >> g_NetPlaySettings.m_WriteToMemcard;
for (unsigned int i = 0; i < 4; ++i)
packet >> g_NetPlaySettings.m_Controllers[i];
}
m_dialog->OnMsgStartGame();
@ -422,6 +423,8 @@ bool NetPlayClient::StartGame(const std::string &path)
// boot game
m_dialog->BootGame(path);
UpdateDevices();
// temporary
NetWiimote nw;
for (unsigned int i = 0; i<4; ++i)
@ -437,6 +440,16 @@ bool NetPlayClient::ChangeGame(const std::string&)
return true;
}
// called from ---NETPLAY--- thread
void NetPlayClient::UpdateDevices()
{
for (PadMapping i = 0; i < 4; i++)
{
// XXX: add support for other device types? does it matter?
SerialInterface::AddDevice(m_pad_map[i] > 0 ? SIDEVICE_GC_CONTROLLER : SIDEVICE_NONE, i);
}
}
// called from ---NETPLAY--- thread
void NetPlayClient::ClearBuffers()
{

View File

@ -117,6 +117,7 @@ protected:
PadMapping m_pad_map[4];
private:
void UpdateDevices();
void SendPadState(const PadMapping in_game_pad, const NetPad& np);
unsigned int OnData(sf::Packet& packet);

View File

@ -14,7 +14,6 @@ struct NetSettings
bool m_DSPHLE;
bool m_DSPEnableJIT;
bool m_WriteToMemcard;
u8 m_Controllers[4];
};
struct Rpt : public std::vector<u8>

View File

@ -441,8 +441,6 @@ bool NetPlayServer::StartGame(const std::string &path)
spac << m_settings.m_DSPEnableJIT;
spac << m_settings.m_DSPHLE;
spac << m_settings.m_WriteToMemcard;
for (unsigned int i = 0; i < 4; ++i)
spac << m_settings.m_Controllers[i];
std::lock_guard<std::recursive_mutex> lkp(m_crit.players);
std::lock_guard<std::recursive_mutex> lks(m_crit.send);

View File

@ -107,7 +107,6 @@ NetPlaySetupDiag::NetPlaySetupDiag(wxWindow* const parent, const CGameListCtrl*
" - DSP Emulator Engine Must be the same on all computers!\n"
" - DSP on Dedicated Thread [OFF]\n"
" - Framelimit NOT set to [Audio]\n"
" - Manually set the exact number of controllers to be used to [Standard Controller]\n"
"\n"
"All players should use the same Dolphin version and settings.\n"
"All memory cards must be identical between players or disabled.\n"
@ -405,9 +404,6 @@ void NetPlayDiag::GetNetSettings(NetSettings &settings)
settings.m_DSPHLE = instance.m_LocalCoreStartupParameter.bDSPHLE;
settings.m_DSPEnableJIT = instance.m_EnableJIT;
settings.m_WriteToMemcard = m_memcard_write->GetValue();
for (unsigned int i = 0; i < 4; ++i)
settings.m_Controllers[i] = SConfig::GetInstance().m_SIDevice[i];
}
std::string NetPlayDiag::FindGame()