Skip to content
Permalink
Browse files

Merge pull request #8407 from jordan-woyak/dj-turntable-fix

ControllerEmu: Clamp results of trigger/slider states to prevent integer overflow later on.
  • Loading branch information...
JMC47 committed Oct 16, 2019
2 parents 4425d05 + b120b08 commit a1405f70a251cb21763d9f9a3be84cb6650d6957
@@ -48,7 +48,7 @@ void MixedTriggers::GetState(u16* const digital, const u16* bitmasks, ControlSta
{
const ControlState button_value = ApplyDeadzone(controls[i]->control_ref->State(), deadzone);
ControlState analog_value =
ApplyDeadzone(controls[trigger_count + i]->control_ref->State(), deadzone);
std::min(ApplyDeadzone(controls[trigger_count + i]->control_ref->State(), deadzone), 1.0);

// Apply threshold:
if (button_value > threshold)
@@ -34,6 +34,6 @@ Slider::StateData Slider::GetState()
const ControlState deadzone = m_deadzone_setting.GetValue() / 100;
const ControlState state = controls[1]->control_ref->State() - controls[0]->control_ref->State();

return {ApplyDeadzone(state, deadzone)};
return {std::clamp(ApplyDeadzone(state, deadzone), -1.0, 1.0)};
}
} // namespace ControllerEmu
@@ -28,7 +28,7 @@ Triggers::StateData Triggers::GetState()

StateData result(trigger_count);
for (size_t i = 0; i < trigger_count; ++i)
result.data[i] = ApplyDeadzone(controls[i]->control_ref->State(), deadzone);
result.data[i] = std::min(ApplyDeadzone(controls[i]->control_ref->State(), deadzone), 1.0);

return result;
}

0 comments on commit a1405f7

Please sign in to comment.
You can’t perform that action at this time.