From ab367774d3ba0081501653e3e310aa8c70c7f345 Mon Sep 17 00:00:00 2001 From: SpinDizzy Date: Sat, 30 Jan 2021 09:54:03 +0000 Subject: [PATCH] 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] --- Src/OSD/SDL/Main.cpp | 3 +++ Src/OSD/SDL/SDLInputSystem.cpp | 3 ++- Src/OSD/Windows/DirectInputSystem.cpp | 8 +++++++- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/Src/OSD/SDL/Main.cpp b/Src/OSD/SDL/Main.cpp index 2674541..431a6de 100644 --- a/Src/OSD/SDL/Main.cpp +++ b/Src/OSD/SDL/Main.cpp @@ -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; diff --git a/Src/OSD/SDL/SDLInputSystem.cpp b/Src/OSD/SDL/SDLInputSystem.cpp index 44aa4e0..8f6d8d9 100644 --- a/Src/OSD/SDL/SDLInputSystem.cpp +++ b/Src/OSD/SDL/SDLInputSystem.cpp @@ -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() / 100.0f; + if (force != 0.0f && force > threshold) SDL_HapticRumblePlay(m_SDLHapticDatas[joyNum].SDLhaptic, force, 200); else SDL_HapticRumbleStop(m_SDLHapticDatas[joyNum].SDLhaptic); diff --git a/Src/OSD/Windows/DirectInputSystem.cpp b/Src/OSD/Windows/DirectInputSystem.cpp index 6019146..208cb79 100644 --- a/Src/OSD/Windows/DirectInputSystem.cpp +++ b/Src/OSD/Windows/DirectInputSystem.cpp @@ -1792,7 +1792,8 @@ bool CDirectInputSystem::ProcessForceFeedbackCmd(int joyNum, int axisNum, ForceF break; case FFConstantForce: - { + { + bool bothMotorVib = m_config["XInputStereoVibration"].ValueAs(); // Check if constant force effect is disabled unsigned xInputConstForceMax = m_config["XInputConstForceMax"].ValueAs(); 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) {