Merge pull request #3792 from mathieui/netplay-rumble

Fix netplay rumble
This commit is contained in:
Matthew Parlane 2016-04-30 23:06:37 +12:00
commit e629727572
4 changed files with 13 additions and 43 deletions

View File

@ -8,6 +8,7 @@
#include "Common/MsgHandler.h"
#include "Common/Logging/Log.h"
#include "Core/ConfigManager.h"
#include "Core/HW/GCPad.h"
#include "Core/HW/SI_DeviceGCAdapter.h"
#include "InputCommon/GCAdapter.h"
@ -32,45 +33,11 @@ GCPadStatus CSIDevice_GCAdapter::GetPadStatus()
return PadStatus;
}
void CSIDevice_GCAdapter::SendCommand(u32 _Cmd, u8 _Poll)
void CSIDevice_GCController::Rumble(u8 numPad, ControlState strength)
{
UCommand command(_Cmd);
switch (command.Command)
{
// Costis sent it in some demos :)
case 0x00:
break;
case CMD_WRITE:
{
unsigned int uType = command.Parameter1; // 0 = stop, 1 = rumble, 2 = stop hard
unsigned int uStrength = command.Parameter2;
// get the correct pad number that should rumble locally when using netplay
const u8 numPAD = NetPlay_InGamePadToLocalPad(ISIDevice::m_iDeviceNumber);
if (numPAD < 4)
{
if (uType == 1 && uStrength > 2)
GCAdapter::Output(numPAD, 1);
else
GCAdapter::Output(numPAD, 0);
SIDevices device = SConfig::GetInstance().m_SIDevice[numPad];
if (device == SIDEVICE_WIIU_ADAPTER)
GCAdapter::Output(numPad, static_cast<u8>(strength));
else if (SIDevice_IsGCController(device))
Pad::Rumble(numPad, strength);
}
if (!_Poll)
{
m_Mode = command.Parameter2;
INFO_LOG(SERIALINTERFACE, "PAD %i set to mode %i", ISIDevice::m_iDeviceNumber, m_Mode);
}
}
break;
default:
{
ERROR_LOG(SERIALINTERFACE, "Unknown direct command (0x%x)", _Cmd);
PanicAlert("SI: Unknown direct command");
}
break;
}
}

View File

@ -14,5 +14,4 @@ public:
CSIDevice_GCAdapter(SIDevices device, int _iDeviceNumber);
GCPadStatus GetPadStatus() override;
void SendCommand(u32 _Cmd, u8 _Poll) override;
};

View File

@ -290,9 +290,9 @@ void CSIDevice_GCController::SendCommand(u32 _Cmd, u8 _Poll)
if (numPAD < 4)
{
if (uType == 1 && uStrength > 2)
Pad::Rumble(numPAD, 1.0);
CSIDevice_GCController::Rumble(numPAD, 1.0);
else
Pad::Rumble(numPAD, 0.0);
CSIDevice_GCController::Rumble(numPAD, 0.0);
}
if (!_Poll)

View File

@ -4,6 +4,7 @@
#pragma once
#include "Core/HW/GCPad.h"
#include "Core/HW/SI_Device.h"
#include "InputCommon/GCPadStatus.h"
@ -107,6 +108,9 @@ public:
static bool NetPlay_GetInput(u8 numPAD, GCPadStatus* status);
static u8 NetPlay_InGamePadToLocalPad(u8 numPAD);
// Direct rumble to the right GC Controller
static void Rumble(u8 numPad, ControlState strength);
protected:
void Calibrate();
void HandleMoviePadStatus(GCPadStatus* PadStatus);