summaryrefslogtreecommitdiff
path: root/Source/Core
diff options
context:
space:
mode:
authormathieui <mathieui@mathieui.net>2016-05-12 02:07:52 +0200
committermathieui <mathieui@mathieui.net>2016-05-12 23:31:51 +0200
commit8f0cbefbe57762de92284ef151e984f52ec8d7e6 (patch)
tree1bb35bb18b299eddaf2c7079ed4f77deca1bb771 /Source/Core
parent8d23ebaa6b532b6d1ad582ee730d25703a669117 (diff)
Disable part of the adapter features for netplay
In order to avoid desyncs
Diffstat (limited to 'Source/Core')
-rw-r--r--Source/Core/Core/HW/SI_DeviceGCAdapter.cpp86
-rw-r--r--Source/Core/Core/HW/SI_DeviceGCAdapter.h2
-rw-r--r--Source/Core/InputCommon/GCAdapter.cpp6
3 files changed, 20 insertions, 74 deletions
diff --git a/Source/Core/Core/HW/SI_DeviceGCAdapter.cpp b/Source/Core/Core/HW/SI_DeviceGCAdapter.cpp
index 947aece30e..e68176ac3e 100644
--- a/Source/Core/Core/HW/SI_DeviceGCAdapter.cpp
+++ b/Source/Core/Core/HW/SI_DeviceGCAdapter.cpp
@@ -8,6 +8,7 @@
#include "Common/MsgHandler.h"
#include "Common/Logging/Log.h"
#include "Core/ConfigManager.h"
+#include "Core/NetPlayProto.h"
#include "Core/HW/GCPad.h"
#include "Core/HW/SI_DeviceGCAdapter.h"
#include "InputCommon/GCAdapter.h"
@@ -33,84 +34,25 @@ GCPadStatus CSIDevice_GCAdapter::GetPadStatus()
return PadStatus;
}
-int CSIDevice_GCAdapter::RunBuffer(u8* _pBuffer, int _iLength)
+int CSIDevice_GCAdapter::RunBuffer(u8* buffer, int length)
{
- // For debug logging only
- ISIDevice::RunBuffer(_pBuffer, _iLength);
-
- // Read the command
- EBufferCommands command = static_cast<EBufferCommands>(_pBuffer[3]);
-
- const u8 numPAD = NetPlay_InGamePadToLocalPad(ISIDevice::m_iDeviceNumber);
- if (numPAD < 4)
+ if (!NetPlay::IsNetPlayRunning())
{
- if (!GCAdapter::DeviceConnected(numPAD))
+ // The previous check is a hack to prevent a netplay desync due to
+ // SI devices being different and returning different values on
+ // RunBuffer(); the corresponding code in GCAdapter.cpp has the same
+ // check.
+
+ // This returns an error value if there is no controller plugged
+ // into this port on the hardware gc adapter, exposing it to the game.
+ if (!GCAdapter::DeviceConnected(ISIDevice::m_iDeviceNumber))
{
- reinterpret_cast<u32*>(_pBuffer)[0] = SI_NONE;
+ TSIDevices device = SI_NONE;
+ memcpy(buffer, &device, sizeof(device));
return 4;
}
}
-
- // Handle it
- switch (command)
- {
- case CMD_RESET:
- case CMD_ID:
- *(u32*)&_pBuffer[0] = SI_GC_CONTROLLER;
- break;
-
- case CMD_DIRECT:
- {
- INFO_LOG(SERIALINTERFACE, "PAD - Direct (Length: %d)", _iLength);
- u32 high, low;
- GetData(high, low);
- for (int i = 0; i < (_iLength - 1) / 2; i++)
- {
- _pBuffer[i + 0] = (high >> (i * 8)) & 0xff;
- _pBuffer[i + 4] = (low >> (i * 8)) & 0xff;
- }
- }
- break;
-
- case CMD_ORIGIN:
- {
- INFO_LOG(SERIALINTERFACE, "PAD - Get Origin");
-
- Calibrate();
-
- u8* pCalibration = reinterpret_cast<u8*>(&m_Origin);
- for (int i = 0; i < (int)sizeof(SOrigin); i++)
- {
- _pBuffer[i ^ 3] = *pCalibration++;
- }
- }
- break;
-
- // Recalibrate (FiRES: i am not 100 percent sure about this)
- case CMD_RECALIBRATE:
- {
- INFO_LOG(SERIALINTERFACE, "PAD - Recalibrate");
-
- Calibrate();
-
- u8* pCalibration = reinterpret_cast<u8*>(&m_Origin);
- for (int i = 0; i < (int)sizeof(SOrigin); i++)
- {
- _pBuffer[i ^ 3] = *pCalibration++;
- }
- }
- break;
-
- // DEFAULT
- default:
- {
- ERROR_LOG(SERIALINTERFACE, "Unknown SI command (0x%x)", command);
- PanicAlert("SI: Unknown command (0x%x)", command);
- }
- break;
- }
-
- return _iLength;
+ return CSIDevice_GCController::RunBuffer(buffer, length);
}
void CSIDevice_GCController::Rumble(u8 numPad, ControlState strength)
diff --git a/Source/Core/Core/HW/SI_DeviceGCAdapter.h b/Source/Core/Core/HW/SI_DeviceGCAdapter.h
index e19527505a..f073f318bf 100644
--- a/Source/Core/Core/HW/SI_DeviceGCAdapter.h
+++ b/Source/Core/Core/HW/SI_DeviceGCAdapter.h
@@ -14,5 +14,5 @@ public:
CSIDevice_GCAdapter(SIDevices device, int _iDeviceNumber);
GCPadStatus GetPadStatus() override;
- int RunBuffer(u8* _pBuffer, int _iLength) override;
+ int RunBuffer(u8* buffer, int length) override;
};
diff --git a/Source/Core/InputCommon/GCAdapter.cpp b/Source/Core/InputCommon/GCAdapter.cpp
index eceed1ed0b..df71a8d846 100644
--- a/Source/Core/InputCommon/GCAdapter.cpp
+++ b/Source/Core/InputCommon/GCAdapter.cpp
@@ -12,6 +12,7 @@
#include "Core/ConfigManager.h"
#include "Core/Core.h"
#include "Core/CoreTiming.h"
+#include "Core/NetPlayProto.h"
#include "Core/HW/SI.h"
#include "Core/HW/SystemTimers.h"
@@ -417,8 +418,11 @@ void Input(int chan, GCPadStatus* pad)
pad->triggerLeft = controller_payload_copy[1 + (9 * chan) + 7];
pad->triggerRight = controller_payload_copy[1 + (9 * chan) + 8];
}
- else
+ else if (!NetPlay::IsNetPlayRunning())
{
+ // This is a hack to prevent a netplay desync due to SI devices
+ // being different and returning different values.
+ // The corresponding code in DeviceGCAdapter has the same check
pad->button = PAD_ERR_STATUS;
}
}