Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Revert "Revert "NetPlay: Use the correct pad mappings for rumble""
This reverts commit 06140e8.
  • Loading branch information
RachelBryk committed Sep 9, 2013
1 parent 06140e8 commit 7720466
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 18 deletions.
2 changes: 1 addition & 1 deletion Source/Core/Core/Src/HW/SI_DeviceDanceMat.cpp
Expand Up @@ -231,7 +231,7 @@ void CSIDevice_DanceMat::SendCommand(u32 _Cmd, u8 _Poll)
unsigned int uStrength = command.Parameter2;

// 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)
Pad::Rumble(numPAD, uType, uStrength);
Expand Down
2 changes: 1 addition & 1 deletion Source/Core/Core/Src/HW/SI_DeviceDanceMat.h
Expand Up @@ -90,7 +90,7 @@ class CSIDevice_DanceMat : public ISIDevice

// Send and Receive pad input from network
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
virtual bool GetData(u32& _Hi, u32& _Low);
Expand Down
2 changes: 1 addition & 1 deletion Source/Core/Core/Src/HW/SI_DeviceGCController.cpp
Expand Up @@ -249,7 +249,7 @@ void CSIDevice_GCController::SendCommand(u32 _Cmd, u8 _Poll)
unsigned int uStrength = command.Parameter2;

// 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)
Pad::Rumble(numPAD, uType, uStrength);
Expand Down
2 changes: 1 addition & 1 deletion Source/Core/Core/Src/HW/SI_DeviceGCController.h
Expand Up @@ -90,7 +90,7 @@ class CSIDevice_GCController : public ISIDevice

// Send and Receive pad input from network
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
virtual bool GetData(u32& _Hi, u32& _Low);
Expand Down
4 changes: 2 additions & 2 deletions Source/Core/Core/Src/HW/SI_DeviceGCSteeringWheel.cpp
Expand Up @@ -254,7 +254,7 @@ void CSIDevice_GCSteeringWheel::SendCommand(u32 _Cmd, u8 _Poll)
unsigned int uType = command.Parameter2; // 06 = motor on, 04 = motor off

// 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)
Pad::Motor(numPAD, uType, uStrength);
Expand All @@ -273,7 +273,7 @@ void CSIDevice_GCSteeringWheel::SendCommand(u32 _Cmd, u8 _Poll)
unsigned int uStrength = command.Parameter2;

// 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)
Pad::Rumble(numPAD, uType, uStrength);
Expand Down
2 changes: 1 addition & 1 deletion Source/Core/Core/Src/HW/SI_DeviceGCSteeringWheel.h
Expand Up @@ -91,7 +91,7 @@ class CSIDevice_GCSteeringWheel : public ISIDevice

// Send and Receive pad input from network
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
virtual bool GetData(u32& _Hi, u32& _Low);
Expand Down
37 changes: 27 additions & 10 deletions Source/Core/Core/Src/NetPlayClient.cpp
Expand Up @@ -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"
// 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
// information given.
Expand Down Expand Up @@ -623,8 +623,25 @@ void NetPlayClient::Stop()
}
}

// called from ---CPU--- thread
u8 NetPlayClient::GetPadNum(u8 numPAD)
u8 NetPlayClient::InGamePadToLocalPad(u8 ingame_pad)
{
// 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.
// The logic we have here is that the local slots always
Expand All @@ -636,7 +653,7 @@ u8 NetPlayClient::GetPadNum(u8 numPAD)
if (m_pad_map[ingame_pad] == m_local_player->pid)
local_pad_count++;

if (local_pad_count == numPAD)
if (local_pad_count == local_pad)
break;
}

Expand Down Expand Up @@ -681,24 +698,24 @@ u32 CEXIIPL::NetPlay_GetGCTime()

// called from ---CPU--- thread
// 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);

if (netplay_client)
return netplay_client->GetPadNum(numPAD);
return netplay_client->InGamePadToLocalPad(numPAD);
else
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
Expand Down
3 changes: 2 additions & 1 deletion Source/Core/Core/Src/NetPlayClient.h
Expand Up @@ -82,7 +82,8 @@ class NetPlayClient
void WiimoteUpdate(int _number);
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:
void ClearBuffers();
Expand Down

0 comments on commit 7720466

Please sign in to comment.