diff --git a/Source/Core/Core/Src/HW/GCPad.cpp b/Source/Core/Core/Src/HW/GCPad.cpp index 61b666af12..68ba3ab88a 100644 --- a/Source/Core/Core/Src/HW/GCPad.cpp +++ b/Source/Core/Core/Src/HW/GCPad.cpp @@ -105,6 +105,10 @@ void Rumble(u8 _numPAD, unsigned int _uType, unsigned int _uStrength) { ((GCPad*)g_plugin.controllers[ _numPAD ])->SetOutput(255); } + else + { + ((GCPad*)g_plugin.controllers[ _numPAD ])->SetOutput(0); + } } } @@ -123,9 +127,9 @@ void Motor(u8 _numPAD, unsigned int _uType, unsigned int _uStrength) { // TODO: this has potential to not stop rumble if user is messing with GUI at the perfect time // set rumble - if (_uType == 06) + if (_uType == 6) { - ((GCPad*)g_plugin.controllers[ _numPAD ])->SetOutput(_uStrength); + ((GCPad*)g_plugin.controllers[ _numPAD ])->SetMotor(_uStrength); } } } diff --git a/Source/Core/Core/Src/HW/GCPadEmu.cpp b/Source/Core/Core/Src/HW/GCPadEmu.cpp index 5233ed2877..a2c0c2afa9 100644 --- a/Source/Core/Core/Src/HW/GCPadEmu.cpp +++ b/Source/Core/Core/Src/HW/GCPadEmu.cpp @@ -130,13 +130,24 @@ void GCPad::GetInput(SPADStatus* const pad) } } +void GCPad::SetMotor(const u8 on) +{ + float state = (float)on / 255; + float force = abs(state - 0.5) * 2; + if (state < 0.5) + force = -force; + + // only rumble if window has focus or background input is enabled + if (Host_RendererHasFocus() || m_options[0].settings[0]->value) + m_rumble->controls[0]->control_ref->State(force); + else + m_rumble->controls[0]->control_ref->State(0); +} + void GCPad::SetOutput(const u8 on) { // only rumble if window has focus or background input is enabled - if (Host_RendererHasFocus() || m_options[0].settings[0]->value) - m_rumble->controls[0]->control_ref->State((float)on / 255); - else - m_rumble->controls[0]->control_ref->State(0); + m_rumble->controls[0]->control_ref->State(on && (Host_RendererHasFocus() || m_options[0].settings[0]->value)); } void GCPad::LoadDefaults(const ControllerInterface& ciface) diff --git a/Source/Core/Core/Src/HW/GCPadEmu.h b/Source/Core/Core/Src/HW/GCPadEmu.h index cf0940245e..e57e6b0b68 100644 --- a/Source/Core/Core/Src/HW/GCPadEmu.h +++ b/Source/Core/Core/Src/HW/GCPadEmu.h @@ -29,6 +29,7 @@ public: GCPad(const unsigned int index); void GetInput(SPADStatus* const pad); void SetOutput(const u8 on); + void SetMotor(const u8 on); bool GetMicButton() const; diff --git a/Source/Core/InputCommon/Src/ControllerInterface/DInput/DInputJoystick.cpp b/Source/Core/InputCommon/Src/ControllerInterface/DInput/DInputJoystick.cpp index b7ac3bf82e..af6ee7e77c 100644 --- a/Source/Core/InputCommon/Src/ControllerInterface/DInput/DInputJoystick.cpp +++ b/Source/Core/InputCommon/Src/ControllerInterface/DInput/DInputJoystick.cpp @@ -535,11 +535,7 @@ ControlState Joystick::Hat::GetState() const void Joystick::ForceConstant::SetState(const ControlState state) { - float force = abs(state - 0.5) * 2; - if (state < 0.5) - force = -force; - - const LONG new_val = LONG(10000 * force); + const LONG new_val = LONG(10000 * state); LONG &val = params.lMagnitude; if (val != new_val)