From c161e2f3084a3ce19ceaac013f6f89f04b1587c1 Mon Sep 17 00:00:00 2001 From: Kaldaien Date: Fri, 29 Nov 2024 02:15:49 -0500 Subject: [PATCH] Make Impulse Trigger Str. (Left/Right) configruable from SK's control panel. --- CHANGELOG.txt | 7 ++++++- include/SpecialK/DLL_VERSION.H | 4 ++-- include/SpecialK/config.h | 2 ++ src/config.cpp | 8 ++++++++ src/control_panel/cfg_input.cpp | 15 +++++++++++++++ src/input/game_input.cpp | 31 +++++++++++++++++++++++++------ 6 files changed, 58 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.txt b/CHANGELOG.txt index a24010f83..8dfe0bbd1 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -1,4 +1,9 @@ -24.11.29.2 +24.11.29.3 +========== + + Make Impulse Trigger Str. (Left/Right) configruable from SK's control panel. + + Correctly clear rumble when games pass a nullptr to SetRumbleState (...). + +24.11.29.2 ========== + Added preliminary Xbox Impulse Triggers -> DualSense Haptics, in STALKER 2; think of it more as supplementary rumble for the time being. diff --git a/include/SpecialK/DLL_VERSION.H b/include/SpecialK/DLL_VERSION.H index cd5523755..b57577da5 100644 --- a/include/SpecialK/DLL_VERSION.H +++ b/include/SpecialK/DLL_VERSION.H @@ -3,8 +3,8 @@ #define SK_YEAR 24 #define SK_MONTH 11 #define SK_DATE 29 -#define SK_REV_N 2 -#define SK_REV 2 +#define SK_REV_N 3 +#define SK_REV 3 #ifndef _A2 #define _A2(a) #a diff --git a/include/SpecialK/config.h b/include/SpecialK/config.h index 2111d3c8a..b7a3c02f6 100644 --- a/include/SpecialK/config.h +++ b/include/SpecialK/config.h @@ -1083,6 +1083,8 @@ struct sk_config_t bool native_ps4 = false; bool bt_input_only = false; float low_battery_percent = 25.0f; + float impulse_strength_l = 1.0f; + float impulse_strength_r = 1.0f; struct xinput_s { unsigned diff --git a/src/config.cpp b/src/config.cpp index 47eb4f3ca..56fa8760d 100644 --- a/src/config.cpp +++ b/src/config.cpp @@ -1114,6 +1114,8 @@ struct { sk::ParameterBool* bt_input_only = nullptr; sk::ParameterFloat* low_battery_warning = nullptr; sk::ParameterBool* blocks_screensaver = nullptr; + sk::ParameterFloat* left_impulse_strength = nullptr; + sk::ParameterFloat* right_impulse_strength = nullptr; } gamepad; } input; @@ -1699,6 +1701,8 @@ auto DeclKeybind = ConfigEntry (input.gamepad.allow_steam_winmm, L"Use Steam-manipulated version of WinMM input", dll_ini, L"Input.Gamepad", L"AllowSteamWinMM"), ConfigEntry (input.gamepad.disable_rumble, L"Disable Rumble from ALL SOURCES (across all APIs)", dll_ini, L"Input.Gamepad", L"DisableRumble"), ConfigEntry (input.gamepad.blocks_screensaver, L"Gamepad activity will block screensaver activation", dll_ini, L"Input.Gamepad", L"BlocksScreenSaver"), + ConfigEntry (input.gamepad.right_impulse_strength, L"Scale the Right Impulse Triggers in GameInput games", dll_ini, L"Input.Gamepad", L"RightImpulseStrength"), + ConfigEntry (input.gamepad.left_impulse_strength, L"Scale the Right Impulse Triggers in GameInput games", dll_ini, L"Input.Gamepad", L"LeftImpulseStrength"), ConfigEntry (input.gamepad.bt_input_only, L"Prevent Bluetooth Output (PlayStation DirectInput compat.)",dll_ini, L"Input.Gamepad", L"BluetoothInputOnly"), ConfigEntry (input.gamepad.hid.max_allowed_buffers, L"Maximum allowed HID buffers; 32=NS default, 8=SK default," L" this will lower latency at the expense of possibly missed" @@ -4670,6 +4674,8 @@ auto DeclKeybind = input.gamepad.bt_input_only->load (config.input.gamepad.bt_input_only); input.gamepad.disable_rumble->load (config.input.gamepad.disable_rumble); input.gamepad.blocks_screensaver->load (config.input.gamepad.blocks_screensaver); + input.gamepad.left_impulse_strength->load (config.input.gamepad.impulse_strength_l); + input.gamepad.right_impulse_strength->load (config.input.gamepad.impulse_strength_r); input.gamepad.xinput.hook_setstate->load (config.input.gamepad.xinput.hook_setstate); input.gamepad.xinput.auto_slot_assign->load (config.input.gamepad.xinput.auto_slot_assign); input.gamepad.xinput.blackout_api->load (config.input.gamepad.xinput.blackout_api); @@ -6166,6 +6172,8 @@ SK_SaveConfig ( std::wstring name, input.gamepad.bt_input_only->store (config.input.gamepad.bt_input_only); input.gamepad.disable_rumble->store (config.input.gamepad.disable_rumble); input.gamepad.blocks_screensaver->store (config.input.gamepad.blocks_screensaver); + input.gamepad.left_impulse_strength->store (config.input.gamepad.impulse_strength_l); + input.gamepad.right_impulse_strength->store (config.input.gamepad.impulse_strength_r); input.gamepad.xinput.hook_setstate->store (config.input.gamepad.xinput.hook_setstate); input.gamepad.xinput.auto_slot_assign->store (config.input.gamepad.xinput.auto_slot_assign); input.gamepad.xinput.blackout_api->store (config.input.gamepad.xinput.blackout_api); diff --git a/src/control_panel/cfg_input.cpp b/src/control_panel/cfg_input.cpp index 33b326f6a..8263df860 100644 --- a/src/control_panel/cfg_input.cpp +++ b/src/control_panel/cfg_input.cpp @@ -2077,6 +2077,21 @@ SK::ControlPanel::Input::Draw (void) } #endif + static bool has_gameinput = + GetModuleHandleW (L"GameInput.dll") != nullptr; + + if (has_gameinput && SK_GameInput_Backend->reads [2] > 0) + { + ImGui::TreePush (""); bool changed = + ImGui::SliderFloat ("Left Trigger", &config.input.gamepad.impulse_strength_l, 0.0f, 1.5f, "%3.1fx Impulse Strength"); + ImGui::SameLine ( ); changed |= + ImGui::SliderFloat ("Right Trigger", &config.input.gamepad.impulse_strength_r, 0.0f, 1.5f, "%3.1fx Impulse Strength"); + ImGui::TreePop ( ); + + if (changed) + config.utility.save_async (); + } + ImGui::BeginGroup (); bool compat_expanded = ImGui::TreeNode ("Compatibility Options"); diff --git a/src/input/game_input.cpp b/src/input/game_input.cpp index 361d58f9a..f180040ac 100644 --- a/src/input/game_input.cpp +++ b/src/input/game_input.cpp @@ -964,21 +964,40 @@ SK_IGameInputDevice::SetRumbleState (GameInputRumbleParams const *params) noexce { SK_LOG_FIRST_CALL + if (config.input.gamepad.disable_rumble) + { + SK_XInput_ZeroHaptics (0); + return; + } + if (! params) + { + if (! SK_ImGui_WantGamepadCapture ()) + { + if (config.input.gamepad.xinput.emulate && (! config.input.gamepad.xinput.blackout_api)) + { + SK_XInput_ZeroHaptics (0); + } + } + return; + } GameInputRumbleParams params_ = *params; - if (config.input.gamepad.disable_rumble || SK_ImGui_WantGamepadCapture ()) + if (config.input.gamepad.disable_rumble) { - params_.highFrequency = params_.lowFrequency = 0.0f; - params_.leftTrigger = params_.rightTrigger = 0.0f; + SK_XInput_ZeroHaptics (0); + return; } - if (config.input.gamepad.xinput.emulate && (! config.input.gamepad.xinput.blackout_api)) + if (config.input.gamepad.xinput.emulate && (! config.input.gamepad.xinput.blackout_api) && (! SK_ImGui_WantGamepadCapture ())) { - SK_XInput_PulseController ( 0, params_.lowFrequency + params_.leftTrigger, - params_.highFrequency + params_.rightTrigger ); + float left = (params_.lowFrequency + params_.leftTrigger * config.input.gamepad.impulse_strength_l); + float right = (params_.highFrequency + params_.rightTrigger * config.input.gamepad.impulse_strength_r); + + SK_XInput_PulseController ( 0, std::clamp (left, 0.0f, 1.0f), + std::clamp (right, 0.0f, 1.0f) ); } }