Revert "Revert "NetPlay: Use the correct pad mappings for rumble""

This reverts commit 06140e8083.
This commit is contained in:
Rachel Bryk 2013-09-09 03:09:45 -04:00
parent 06140e8083
commit 772046647a
8 changed files with 36 additions and 18 deletions

View File

@ -231,7 +231,7 @@ void CSIDevice_DanceMat::SendCommand(u32 _Cmd, u8 _Poll)
unsigned int uStrength = command.Parameter2; unsigned int uStrength = command.Parameter2;
// get the correct pad number that should rumble locally when using netplay // get the correct pad number that should rumble locally when using netplay
const u8 numPAD = NetPlay_GetPadNum(ISIDevice::m_iDeviceNumber); const u8 numPAD = NetPlay_InGamePadToLocalPad(ISIDevice::m_iDeviceNumber);
if (numPAD < 4) if (numPAD < 4)
Pad::Rumble(numPAD, uType, uStrength); Pad::Rumble(numPAD, uType, uStrength);

View File

@ -90,7 +90,7 @@ public:
// Send and Receive pad input from network // Send and Receive pad input from network
static bool NetPlay_GetInput(u8 numPAD, SPADStatus status, u32 *PADStatus); static bool NetPlay_GetInput(u8 numPAD, SPADStatus status, u32 *PADStatus);
static u8 NetPlay_GetPadNum(u8 numPAD); static u8 NetPlay_InGamePadToLocalPad(u8 numPAD);
// Return true on new data // Return true on new data
virtual bool GetData(u32& _Hi, u32& _Low); virtual bool GetData(u32& _Hi, u32& _Low);

View File

@ -249,7 +249,7 @@ void CSIDevice_GCController::SendCommand(u32 _Cmd, u8 _Poll)
unsigned int uStrength = command.Parameter2; unsigned int uStrength = command.Parameter2;
// get the correct pad number that should rumble locally when using netplay // get the correct pad number that should rumble locally when using netplay
const u8 numPAD = NetPlay_GetPadNum(ISIDevice::m_iDeviceNumber); const u8 numPAD = NetPlay_InGamePadToLocalPad(ISIDevice::m_iDeviceNumber);
if (numPAD < 4) if (numPAD < 4)
Pad::Rumble(numPAD, uType, uStrength); Pad::Rumble(numPAD, uType, uStrength);

View File

@ -90,7 +90,7 @@ public:
// Send and Receive pad input from network // Send and Receive pad input from network
static bool NetPlay_GetInput(u8 numPAD, SPADStatus status, u32 *PADStatus); static bool NetPlay_GetInput(u8 numPAD, SPADStatus status, u32 *PADStatus);
static u8 NetPlay_GetPadNum(u8 numPAD); static u8 NetPlay_InGamePadToLocalPad(u8 numPAD);
// Return true on new data // Return true on new data
virtual bool GetData(u32& _Hi, u32& _Low); virtual bool GetData(u32& _Hi, u32& _Low);

View File

@ -254,7 +254,7 @@ void CSIDevice_GCSteeringWheel::SendCommand(u32 _Cmd, u8 _Poll)
unsigned int uType = command.Parameter2; // 06 = motor on, 04 = motor off unsigned int uType = command.Parameter2; // 06 = motor on, 04 = motor off
// get the correct pad number that should rumble locally when using netplay // get the correct pad number that should rumble locally when using netplay
const u8 numPAD = NetPlay_GetPadNum(ISIDevice::m_iDeviceNumber); const u8 numPAD = NetPlay_InGamePadToLocalPad(ISIDevice::m_iDeviceNumber);
if (numPAD < 4) if (numPAD < 4)
Pad::Motor(numPAD, uType, uStrength); Pad::Motor(numPAD, uType, uStrength);
@ -273,7 +273,7 @@ void CSIDevice_GCSteeringWheel::SendCommand(u32 _Cmd, u8 _Poll)
unsigned int uStrength = command.Parameter2; unsigned int uStrength = command.Parameter2;
// get the correct pad number that should rumble locally when using netplay // get the correct pad number that should rumble locally when using netplay
const u8 numPAD = NetPlay_GetPadNum(ISIDevice::m_iDeviceNumber); const u8 numPAD = NetPlay_InGamePadToLocalPad(ISIDevice::m_iDeviceNumber);
if (numPAD < 4) if (numPAD < 4)
Pad::Rumble(numPAD, uType, uStrength); Pad::Rumble(numPAD, uType, uStrength);

View File

@ -91,7 +91,7 @@ public:
// Send and Receive pad input from network // Send and Receive pad input from network
static bool NetPlay_GetInput(u8 numPAD, SPADStatus status, u32 *PADStatus); static bool NetPlay_GetInput(u8 numPAD, SPADStatus status, u32 *PADStatus);
static u8 NetPlay_GetPadNum(u8 numPAD); static u8 NetPlay_InGamePadToLocalPad(u8 numPAD);
// Return true on new data // Return true on new data
virtual bool GetData(u32& _Hi, u32& _Low); virtual bool GetData(u32& _Hi, u32& _Low);

View File

@ -515,7 +515,7 @@ bool NetPlayClient::GetNetPads(const u8 pad_nb, const SPADStatus* const pad_stat
// We should add this split between "in-game" pads and "local" // We should add this split between "in-game" pads and "local"
// pads higher up. // pads higher up.
int in_game_num = GetPadNum(pad_nb); int in_game_num = InGamePadToLocalPad(pad_nb);
// If this in-game pad is one of ours, then update from the // If this in-game pad is one of ours, then update from the
// information given. // information given.
@ -623,8 +623,25 @@ void NetPlayClient::Stop()
} }
} }
// called from ---CPU--- thread u8 NetPlayClient::InGamePadToLocalPad(u8 ingame_pad)
u8 NetPlayClient::GetPadNum(u8 numPAD) {
// not our pad
if (m_pad_map[ingame_pad] != m_local_player->pid)
return 4;
int local_pad = 0;
int pad = 0;
for (; pad < ingame_pad; pad++)
{
if (m_pad_map[pad] == m_local_player->pid)
local_pad++;
}
return local_pad;
}
u8 NetPlayClient::LocalPadToInGamePad(u8 local_pad)
{ {
// Figure out which in-game pad maps to which local pad. // Figure out which in-game pad maps to which local pad.
// The logic we have here is that the local slots always // The logic we have here is that the local slots always
@ -636,7 +653,7 @@ u8 NetPlayClient::GetPadNum(u8 numPAD)
if (m_pad_map[ingame_pad] == m_local_player->pid) if (m_pad_map[ingame_pad] == m_local_player->pid)
local_pad_count++; local_pad_count++;
if (local_pad_count == numPAD) if (local_pad_count == local_pad)
break; break;
} }
@ -681,24 +698,24 @@ u32 CEXIIPL::NetPlay_GetGCTime()
// called from ---CPU--- thread // called from ---CPU--- thread
// return the local pad num that should rumble given a ingame pad num // return the local pad num that should rumble given a ingame pad num
u8 CSIDevice_GCController::NetPlay_GetPadNum(u8 numPAD) u8 CSIDevice_GCController::NetPlay_InGamePadToLocalPad(u8 numPAD)
{ {
std::lock_guard<std::mutex> lk(crit_netplay_client); std::lock_guard<std::mutex> lk(crit_netplay_client);
if (netplay_client) if (netplay_client)
return netplay_client->GetPadNum(numPAD); return netplay_client->InGamePadToLocalPad(numPAD);
else else
return numPAD; return numPAD;
} }
u8 CSIDevice_GCSteeringWheel::NetPlay_GetPadNum(u8 numPAD) u8 CSIDevice_GCSteeringWheel::NetPlay_InGamePadToLocalPad(u8 numPAD)
{ {
return CSIDevice_GCController::NetPlay_GetPadNum(numPAD); return CSIDevice_GCController::NetPlay_InGamePadToLocalPad(numPAD);
} }
u8 CSIDevice_DanceMat::NetPlay_GetPadNum(u8 numPAD) u8 CSIDevice_DanceMat::NetPlay_InGamePadToLocalPad(u8 numPAD)
{ {
return CSIDevice_GCController::NetPlay_GetPadNum(numPAD); return CSIDevice_GCController::NetPlay_InGamePadToLocalPad(numPAD);
} }
// called from ---CPU--- thread // called from ---CPU--- thread

View File

@ -82,7 +82,8 @@ public:
void WiimoteUpdate(int _number); void WiimoteUpdate(int _number);
bool GetNetPads(const u8 pad_nb, const SPADStatus* const, NetPad* const netvalues); bool GetNetPads(const u8 pad_nb, const SPADStatus* const, NetPad* const netvalues);
u8 GetPadNum(u8 numPAD); u8 LocalPadToInGamePad(u8 localPad);
u8 InGamePadToLocalPad(u8 localPad);
protected: protected:
void ClearBuffers(); void ClearBuffers();