From 8d23ebaa6b532b6d1ad582ee730d25703a669117 Mon Sep 17 00:00:00 2001 From: mathieui Date: Thu, 12 May 2016 02:01:35 +0200 Subject: [PATCH] Revert "Fix netplay desync when using wii-u adapter." This reverts commit 429ae8fb01162ee861caaf46ca2e5c7ea2b80706. Conflicts: Source/Core/Core/HW/SI_DeviceGCAdapter.cpp Source/Core/Core/HW/SI_DeviceGCAdapter.h --- Source/Core/Core/HW/SI_DeviceGCAdapter.cpp | 80 ++++++++++++++++++++++ Source/Core/Core/HW/SI_DeviceGCAdapter.h | 1 + 2 files changed, 81 insertions(+) diff --git a/Source/Core/Core/HW/SI_DeviceGCAdapter.cpp b/Source/Core/Core/HW/SI_DeviceGCAdapter.cpp index c9b766c467..947aece30e 100644 --- a/Source/Core/Core/HW/SI_DeviceGCAdapter.cpp +++ b/Source/Core/Core/HW/SI_DeviceGCAdapter.cpp @@ -33,6 +33,86 @@ GCPadStatus CSIDevice_GCAdapter::GetPadStatus() return PadStatus; } +int CSIDevice_GCAdapter::RunBuffer(u8* _pBuffer, int _iLength) +{ + // For debug logging only + ISIDevice::RunBuffer(_pBuffer, _iLength); + + // Read the command + EBufferCommands command = static_cast(_pBuffer[3]); + + const u8 numPAD = NetPlay_InGamePadToLocalPad(ISIDevice::m_iDeviceNumber); + if (numPAD < 4) + { + if (!GCAdapter::DeviceConnected(numPAD)) + { + reinterpret_cast(_pBuffer)[0] = SI_NONE; + 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(&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(&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; +} + void CSIDevice_GCController::Rumble(u8 numPad, ControlState strength) { SIDevices device = SConfig::GetInstance().m_SIDevice[numPad]; diff --git a/Source/Core/Core/HW/SI_DeviceGCAdapter.h b/Source/Core/Core/HW/SI_DeviceGCAdapter.h index 16b94bf2ff..e19527505a 100644 --- a/Source/Core/Core/HW/SI_DeviceGCAdapter.h +++ b/Source/Core/Core/HW/SI_DeviceGCAdapter.h @@ -14,4 +14,5 @@ public: CSIDevice_GCAdapter(SIDevices device, int _iDeviceNumber); GCPadStatus GetPadStatus() override; + int RunBuffer(u8* _pBuffer, int _iLength) override; };