Fix and simplify GCPad::SetMotor()

abs() takes an int argument. Casting -0.5..0.5 to int always resulted in
zero.
This commit is contained in:
Tillmann Karras 2014-09-18 21:34:07 +02:00
parent d7b7487405
commit e35db54454
1 changed files with 2 additions and 5 deletions

View File

@ -122,11 +122,8 @@ void GCPad::GetInput(GCPadStatus* const pad)
void GCPad::SetMotor(const u8 on) void GCPad::SetMotor(const u8 on)
{ {
ControlState state = static_cast<ControlState>(on) / 255; // map 0..255 to -1.0..1.0
ControlState force = abs(state - 0.5) * 2; ControlState force = on / 127.5 - 1;
if (state < 0.5)
force = -force;
m_rumble->controls[0]->control_ref->State(force); m_rumble->controls[0]->control_ref->State(force);
} }