Skip to content

Commit

Permalink
Make Impulse Trigger Str. (Left/Right) configruable from SK's control…
Browse files Browse the repository at this point in the history
… panel.
  • Loading branch information
Kaldaien committed Nov 29, 2024
1 parent ea00e1b commit c161e2f
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 9 deletions.
7 changes: 6 additions & 1 deletion CHANGELOG.txt
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
4 changes: 2 additions & 2 deletions include/SpecialK/DLL_VERSION.H
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions include/SpecialK/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 8 additions & 0 deletions src/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
15 changes: 15 additions & 0 deletions src/control_panel/cfg_input.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
31 changes: 25 additions & 6 deletions src/input/game_input.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) );
}
}

Expand Down

0 comments on commit c161e2f

Please sign in to comment.