Introduce new config keywords.

In xinput mode, lets the choice to have left and right gamepad motors vibrate together.
XInputStereoVibration = 1 (both motors) [default]
XInputStereoVibration = 0 (separate motors)

In sdl input mode, new control option to set minimum strength above which a Model 3 constant force command will be simulated on an sdl gamepad device.
SDLConstForceThreshold = 30 [default]
note : the vibration strength can be mod with SDLConstForceMax = [val]
This commit is contained in:
SpinDizzy 2021-01-30 09:54:03 +00:00
parent 6627b1e95f
commit ab367774d3
3 changed files with 12 additions and 2 deletions

View file

@ -1416,11 +1416,13 @@ static Util::Config::Node DefaultConfig()
config.Set("XInputConstForceThreshold", "30");
config.Set("XInputConstForceMax", "100");
config.Set("XInputVibrateMax", "100");
config.Set("XInputStereoVibration", true);
// SDL ForceFeedback
config.Set("SDLConstForceMax", "100");
config.Set("SDLSelfCenterMax", "100");
config.Set("SDLFrictionMax", "100");
config.Set("SDLVibrateMax", "100");
config.Set("SDLConstForceThreshold", "30");
#ifdef NET_BOARD
// NetBoard
config.Set("EmulateNet", false);
@ -1432,6 +1434,7 @@ static Util::Config::Node DefaultConfig()
config.Set("SDLSelfCenterMax", "100");
config.Set("SDLFrictionMax", "100");
config.Set("SDLVibrateMax", "100");
config.Set("SDLConstForceThreshold", "30");
#endif
config.Set("Outputs", "none");
return config;

View file

@ -755,7 +755,8 @@ void CSDLInputSystem::ConstantForceEffect(float force, int dir, int length, int
}
else
{
if (force != 0.0f)
float threshold = (float)m_config["SDLConstForceThreshold"].ValueAs<unsigned>() / 100.0f;
if (force != 0.0f && force > threshold)
SDL_HapticRumblePlay(m_SDLHapticDatas[joyNum].SDLhaptic, force, 200);
else
SDL_HapticRumbleStop(m_SDLHapticDatas[joyNum].SDLhaptic);

View file

@ -1792,7 +1792,8 @@ bool CDirectInputSystem::ProcessForceFeedbackCmd(int joyNum, int axisNum, ForceF
break;
case FFConstantForce:
{
{
bool bothMotorVib = m_config["XInputStereoVibration"].ValueAs<bool>();
// Check if constant force effect is disabled
unsigned xInputConstForceMax = m_config["XInputConstForceMax"].ValueAs<unsigned>();
if (xInputConstForceMax == 0)
@ -1807,6 +1808,11 @@ bool CDirectInputSystem::ProcessForceFeedbackCmd(int joyNum, int axisNum, ForceF
// If so, stop vibration due to force effect
pInfo->xiConstForceLeft = 0;
pInfo->xiConstForceRight = 0;
pInfo->xiVibrateBoth = 0;
}
else if (bothMotorVib)
{
pInfo->xiVibrateBoth = (WORD)(absForce * (float)(xInputConstForceMax * XI_VIBRATE_SCALE));
}
else if (negForce)
{