mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-02-02 11:02:28 +02:00
Fixed the infinite rumble problem caused by r4d6056f14625.
This commit is contained in:
parent
7a95713496
commit
5240e75be2
@ -105,6 +105,10 @@ void Rumble(u8 _numPAD, unsigned int _uType, unsigned int _uStrength)
|
|||||||
{
|
{
|
||||||
((GCPad*)g_plugin.controllers[ _numPAD ])->SetOutput(255);
|
((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
|
// TODO: this has potential to not stop rumble if user is messing with GUI at the perfect time
|
||||||
// set rumble
|
// set rumble
|
||||||
if (_uType == 06)
|
if (_uType == 6)
|
||||||
{
|
{
|
||||||
((GCPad*)g_plugin.controllers[ _numPAD ])->SetOutput(_uStrength);
|
((GCPad*)g_plugin.controllers[ _numPAD ])->SetMotor(_uStrength);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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)
|
void GCPad::SetOutput(const u8 on)
|
||||||
{
|
{
|
||||||
// only rumble if window has focus or background input is enabled
|
// 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(on && (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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void GCPad::LoadDefaults(const ControllerInterface& ciface)
|
void GCPad::LoadDefaults(const ControllerInterface& ciface)
|
||||||
|
@ -29,6 +29,7 @@ public:
|
|||||||
GCPad(const unsigned int index);
|
GCPad(const unsigned int index);
|
||||||
void GetInput(SPADStatus* const pad);
|
void GetInput(SPADStatus* const pad);
|
||||||
void SetOutput(const u8 on);
|
void SetOutput(const u8 on);
|
||||||
|
void SetMotor(const u8 on);
|
||||||
|
|
||||||
bool GetMicButton() const;
|
bool GetMicButton() const;
|
||||||
|
|
||||||
|
@ -535,11 +535,7 @@ ControlState Joystick::Hat::GetState() const
|
|||||||
|
|
||||||
void Joystick::ForceConstant::SetState(const ControlState state)
|
void Joystick::ForceConstant::SetState(const ControlState state)
|
||||||
{
|
{
|
||||||
float force = abs(state - 0.5) * 2;
|
const LONG new_val = LONG(10000 * state);
|
||||||
if (state < 0.5)
|
|
||||||
force = -force;
|
|
||||||
|
|
||||||
const LONG new_val = LONG(10000 * force);
|
|
||||||
|
|
||||||
LONG &val = params.lMagnitude;
|
LONG &val = params.lMagnitude;
|
||||||
if (val != new_val)
|
if (val != new_val)
|
||||||
|
Loading…
Reference in New Issue
Block a user