Make a generic rumble function

Call the appropriate rumble function for each SI Device, Should fix #9331.
Ideally we wouldn’t have to do this, but since the way things are wired,
fixing the root cause it out of the picture for now.
This commit is contained in:
mathieui 2016-04-22 20:30:43 +02:00
parent 3df4b09a94
commit 542e7ba158
4 changed files with 13 additions and 43 deletions

View File

@ -8,6 +8,7 @@
#include "Common/MsgHandler.h" #include "Common/MsgHandler.h"
#include "Common/Logging/Log.h" #include "Common/Logging/Log.h"
#include "Core/ConfigManager.h" #include "Core/ConfigManager.h"
#include "Core/HW/GCPad.h"
#include "Core/HW/SI_DeviceGCAdapter.h" #include "Core/HW/SI_DeviceGCAdapter.h"
#include "InputCommon/GCAdapter.h" #include "InputCommon/GCAdapter.h"
@ -32,45 +33,11 @@ GCPadStatus CSIDevice_GCAdapter::GetPadStatus()
return PadStatus; return PadStatus;
} }
void CSIDevice_GCAdapter::SendCommand(u32 _Cmd, u8 _Poll) void CSIDevice_GCController::Rumble(u8 numPad, ControlState strength)
{ {
UCommand command(_Cmd); SIDevices device = SConfig::GetInstance().m_SIDevice[numPad];
if (device == SIDEVICE_WIIU_ADAPTER)
switch (command.Command) GCAdapter::Output(numPad, static_cast<u8>(strength));
{ else if (SIDevice_IsGCController(device))
// Costis sent it in some demos :) Pad::Rumble(numPad, strength);
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);
}
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); CSIDevice_GCAdapter(SIDevices device, int _iDeviceNumber);
GCPadStatus GetPadStatus() override; 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 (numPAD < 4)
{ {
if (uType == 1 && uStrength > 2) if (uType == 1 && uStrength > 2)
Pad::Rumble(numPAD, 1.0); CSIDevice_GCController::Rumble(numPAD, 1.0);
else else
Pad::Rumble(numPAD, 0.0); CSIDevice_GCController::Rumble(numPAD, 0.0);
} }
if (!_Poll) if (!_Poll)

View File

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