Fixed the infinite rumble problem caused by r4d6056f14625.

This commit is contained in:
skidau 2013-01-07 12:25:18 +11:00
parent 7a95713496
commit 5240e75be2
4 changed files with 23 additions and 11 deletions

View File

@ -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);
}
}
}

View File

@ -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)

View File

@ -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;

View File

@ -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)