mirror of
https://github.com/RetroDECK/Duckstation.git
synced 2024-11-23 14:25:37 +00:00
ControllerInterface: Don't use a minimum strength of 0.01
This commit is contained in:
parent
3096f0953f
commit
67d0bbedb1
|
@ -394,13 +394,12 @@ void SDLControllerInterface::SetControllerRumbleStrength(int controller_index, c
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// we'll update before this duration is elapsed
|
// we'll update before this duration is elapsed
|
||||||
static constexpr float MIN_STRENGTH = 0.01f;
|
|
||||||
static constexpr u32 DURATION = 100000;
|
static constexpr u32 DURATION = 100000;
|
||||||
|
|
||||||
SDL_Haptic* haptic = static_cast<SDL_Haptic*>(it->haptic);
|
SDL_Haptic* haptic = static_cast<SDL_Haptic*>(it->haptic);
|
||||||
if (it->haptic_left_right_effect >= 0 && num_motors > 1)
|
if (it->haptic_left_right_effect >= 0 && num_motors > 1)
|
||||||
{
|
{
|
||||||
if (strengths[0] >= MIN_STRENGTH || strengths[1] >= MIN_STRENGTH)
|
if (strengths[0] > 0.0f || strengths[1] > 0.0f)
|
||||||
{
|
{
|
||||||
SDL_HapticEffect ef;
|
SDL_HapticEffect ef;
|
||||||
ef.type = SDL_HAPTIC_LEFTRIGHT;
|
ef.type = SDL_HAPTIC_LEFTRIGHT;
|
||||||
|
@ -421,7 +420,7 @@ void SDLControllerInterface::SetControllerRumbleStrength(int controller_index, c
|
||||||
for (u32 i = 0; i < num_motors; i++)
|
for (u32 i = 0; i < num_motors; i++)
|
||||||
max_strength = std::max(max_strength, strengths[i]);
|
max_strength = std::max(max_strength, strengths[i]);
|
||||||
|
|
||||||
if (max_strength >= MIN_STRENGTH)
|
if (max_strength > 0.0f)
|
||||||
SDL_HapticRumblePlay(haptic, max_strength, DURATION);
|
SDL_HapticRumblePlay(haptic, max_strength, DURATION);
|
||||||
else
|
else
|
||||||
SDL_HapticRumbleStop(haptic);
|
SDL_HapticRumbleStop(haptic);
|
||||||
|
|
|
@ -296,13 +296,9 @@ void XInputControllerInterface::SetControllerRumbleStrength(int controller_index
|
||||||
{
|
{
|
||||||
DebugAssert(static_cast<u32>(controller_index) < XUSER_MAX_COUNT);
|
DebugAssert(static_cast<u32>(controller_index) < XUSER_MAX_COUNT);
|
||||||
|
|
||||||
// we'll update before this duration is elapsed
|
|
||||||
static constexpr float MIN_STRENGTH = 0.01f;
|
|
||||||
static constexpr u32 DURATION = 100000;
|
|
||||||
|
|
||||||
XINPUT_VIBRATION vib;
|
XINPUT_VIBRATION vib;
|
||||||
vib.wLeftMotorSpeed = (strengths[0] >= MIN_STRENGTH) ? static_cast<u16>(strengths[0] * 65535.0f) : 0;
|
vib.wLeftMotorSpeed = static_cast<u16>(strengths[0] * 65535.0f);
|
||||||
vib.wRightMotorSpeed = (strengths[1] >= MIN_STRENGTH) ? static_cast<u16>(strengths[1] * 65535.0f) : 0;
|
vib.wRightMotorSpeed = static_cast<u16>(strengths[1] * 65535.0f);
|
||||||
m_xinput_set_state(static_cast<u32>(controller_index), &vib);
|
m_xinput_set_state(static_cast<u32>(controller_index), &vib);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue