diff --git a/Source/Core/Core/HW/GCPad.cpp b/Source/Core/Core/HW/GCPad.cpp index 55d5c3a62d..ba3aa28cde 100644 --- a/Source/Core/Core/HW/GCPad.cpp +++ b/Source/Core/Core/HW/GCPad.cpp @@ -78,54 +78,14 @@ void GetStatus(u8 _numPAD, GCPadStatus* _pPADStatus) ((GCPad*)s_config.controllers[_numPAD])->GetInput(_pPADStatus); } -// __________________________________________________________________________________________________ -// Function: Rumble -// Purpose: Pad rumble! -// input: _numPad - Which pad to rumble. -// _uType - Command type (Stop=0, Rumble=1, Stop Hard=2). -// _uStrength - Strength of the Rumble -// output: none -// -void Rumble(u8 _numPAD, unsigned int _uType, unsigned int _uStrength) +void Rumble(u8 _numPAD, const ControlState strength) { std::unique_lock lk(s_config.controls_lock, std::try_to_lock); - if (lk.owns_lock()) - { - // TODO: this has potential to not stop rumble if user is messing with GUI at the perfect time - // set rumble - if (1 == _uType && _uStrength > 2) - { - ((GCPad*)s_config.controllers[ _numPAD ])->SetOutput(255); - } - else - { - ((GCPad*)s_config.controllers[ _numPAD ])->SetOutput(0); - } - } -} + if (!lk.owns_lock()) + return; -// __________________________________________________________________________________________________ -// Function: Motor -// Purpose: For devices with constant Force feedback -// input: _numPAD - The pad to operate on -// _uType - 06 = Motor On, 04 = Motor Off -// _uStrength - 00 = Left Strong, 127 = Left Weak, 128 = Right Weak, 255 = Right Strong -// output: none -// -void Motor(u8 _numPAD, unsigned int _uType, unsigned int _uStrength) -{ - std::unique_lock lk(s_config.controls_lock, std::try_to_lock); - - if (lk.owns_lock()) - { - // TODO: this has potential to not stop rumble if user is messing with GUI at the perfect time - // set rumble - if (_uType == 6) - { - ((GCPad*)s_config.controllers[ _numPAD ])->SetMotor(_uStrength); - } - } + ((GCPad*)s_config.controllers[ _numPAD ])->SetOutput(strength); } bool GetMicButton(u8 pad) diff --git a/Source/Core/Core/HW/GCPad.h b/Source/Core/Core/HW/GCPad.h index 6146891942..d9da72e9fc 100644 --- a/Source/Core/Core/HW/GCPad.h +++ b/Source/Core/Core/HW/GCPad.h @@ -17,8 +17,7 @@ void Initialize(void* const hwnd); InputConfig* GetConfig(); void GetStatus(u8 _numPAD, GCPadStatus* _pPADStatus); -void Rumble(u8 _numPAD, unsigned int _uType, unsigned int _uStrength); -void Motor(u8 _numPAD, unsigned int _uType, unsigned int _uStrength); +void Rumble(u8 _numPAD, const ControlState strength); bool GetMicButton(u8 pad); } diff --git a/Source/Core/Core/HW/GCPadEmu.cpp b/Source/Core/Core/HW/GCPadEmu.cpp index da58c44af3..57af144311 100644 --- a/Source/Core/Core/HW/GCPadEmu.cpp +++ b/Source/Core/Core/HW/GCPadEmu.cpp @@ -120,16 +120,9 @@ void GCPad::GetInput(GCPadStatus* const pad) pad->triggerRight = static_cast(triggers[1] * 0xFF); } -void GCPad::SetMotor(const u8 on) +void GCPad::SetOutput(const ControlState strength) { - // map 0..255 to -1.0..1.0 - ControlState force = on / 127.5 - 1; - m_rumble->controls[0]->control_ref->State(force); -} - -void GCPad::SetOutput(const u8 on) -{ - m_rumble->controls[0]->control_ref->State(on); + m_rumble->controls[0]->control_ref->State(strength); } void GCPad::LoadDefaults(const ControllerInterface& ciface) diff --git a/Source/Core/Core/HW/GCPadEmu.h b/Source/Core/Core/HW/GCPadEmu.h index dc8bd835fd..9007cd5829 100644 --- a/Source/Core/Core/HW/GCPadEmu.h +++ b/Source/Core/Core/HW/GCPadEmu.h @@ -14,8 +14,7 @@ public: GCPad(const unsigned int index); void GetInput(GCPadStatus* const pad); - void SetOutput(const u8 on); - void SetMotor(const u8 on); + void SetOutput(const ControlState strength); bool GetMicButton() const; diff --git a/Source/Core/Core/HW/SI_DeviceGCController.cpp b/Source/Core/Core/HW/SI_DeviceGCController.cpp index fa01873adf..667df524ae 100644 --- a/Source/Core/Core/HW/SI_DeviceGCController.cpp +++ b/Source/Core/Core/HW/SI_DeviceGCController.cpp @@ -249,7 +249,12 @@ void CSIDevice_GCController::SendCommand(u32 _Cmd, u8 _Poll) const u8 numPAD = NetPlay_InGamePadToLocalPad(ISIDevice::m_iDeviceNumber); if (numPAD < 4) - Pad::Rumble(numPAD, uType, uStrength); + { + if (uType == 1 && uStrength > 2) + Pad::Rumble(numPAD, 1.0); + else + Pad::Rumble(numPAD, 0.0); + } if (!_Poll) { diff --git a/Source/Core/Core/HW/SI_DeviceGCSteeringWheel.cpp b/Source/Core/Core/HW/SI_DeviceGCSteeringWheel.cpp index 61f8150de4..cd13c3fd55 100644 --- a/Source/Core/Core/HW/SI_DeviceGCSteeringWheel.cpp +++ b/Source/Core/Core/HW/SI_DeviceGCSteeringWheel.cpp @@ -22,7 +22,18 @@ void CSIDevice_GCSteeringWheel::SendCommand(u32 _Cmd, u8 _Poll) const u8 numPAD = NetPlay_InGamePadToLocalPad(ISIDevice::m_iDeviceNumber); if (numPAD < 4) - Pad::Motor(numPAD, uType, uStrength); + { + if (uType == 0x06) + { + // map 0..255 to -1.0..1.0 + ControlState strength = uStrength / 127.5 - 1; + Pad::Rumble(numPAD, strength); + } + else + { + Pad::Rumble(numPAD, 0); + } + } if (!_Poll) {