Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fixed the infinite rumble problem caused by r4d6056f14625.
  • Loading branch information
skidau committed Jan 7, 2013
1 parent 7a95713 commit 5240e75
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 9 deletions.
8 changes: 6 additions & 2 deletions Source/Core/Core/Src/HW/GCPad.cpp
Expand Up @@ -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);
}
}
}

Expand All @@ -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);
}
}
}
Expand Down
15 changes: 13 additions & 2 deletions Source/Core/Core/Src/HW/GCPadEmu.cpp
Expand Up @@ -130,15 +130,26 @@ void GCPad::GetInput(SPADStatus* const pad)
}
}

void GCPad::SetOutput(const u8 on)
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((float)on / 255);
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
m_rumble->controls[0]->control_ref->State(on && (Host_RendererHasFocus() || m_options[0].settings[0]->value));
}

void GCPad::LoadDefaults(const ControllerInterface& ciface)
{
#define set_control(group, num, str) (group)->controls[num]->control_ref->expression = (str)
Expand Down
1 change: 1 addition & 0 deletions Source/Core/Core/Src/HW/GCPadEmu.h
Expand Up @@ -29,6 +29,7 @@ class GCPad : public ControllerEmu
GCPad(const unsigned int index);
void GetInput(SPADStatus* const pad);
void SetOutput(const u8 on);
void SetMotor(const u8 on);

bool GetMicButton() const;

Expand Down
Expand Up @@ -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)
Expand Down

0 comments on commit 5240e75

Please sign in to comment.