diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 18abbda10..8f7d8eee2 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -1,11 +1,15 @@ -24.11.30.1 +24.11.30.2 +========== + + Implement PlayStation Adaptive Trigger support for DualSense controllers + connected using Bluetooth. + +24.11.30.1 ========== + Bring back original slUpgradeInterface / slGetNativeInterface implementation that could handle situations where sl.interposer.dll is loaded late. + Increase default impulse trigger strength modifier to 0.75x, and properly handle the case where setVibration (...) has zero trigger data. - 24.11.30 ======== + For all Unreal Engine games that use GameInput, enable Xbox Emulation by diff --git a/include/SpecialK/DLL_VERSION.H b/include/SpecialK/DLL_VERSION.H index 8d495d5a8..c3d547afa 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 30 -#define SK_REV_N 1 -#define SK_REV 1 +#define SK_REV_N 2 +#define SK_REV 2 #ifndef _A2 #define _A2(a) #a diff --git a/src/input/hid_reports/playstation.cpp b/src/input/hid_reports/playstation.cpp index 6bf6f316a..0f3b6f893 100644 --- a/src/input/hid_reports/playstation.cpp +++ b/src/input/hid_reports/playstation.cpp @@ -2630,7 +2630,9 @@ SK_HID_PlayStationDevice::write_output_report (bool force) const ULONG dwLeftMotor = ReadULongAcquire (&pDevice->_vibration.left); const bool bRumble = - (dwRightMotor != 0 || dwLeftMotor != 0); + (dwRightMotor != 0 || + dwLeftMotor != 0) || (ReadULongAcquire (&pDevice->_vibration.trigger.left) != 0 + || ReadULongAcquire (&pDevice->_vibration.trigger.right) != 0); // 500 msec grace period before allowing controller to use native haptics output->UseRumbleNotHaptics = bRumble || @@ -2666,58 +2668,33 @@ SK_HID_PlayStationDevice::write_output_report (bool force) ); uint8_t effects[3][11] = { - /* Clear trigger effect */ - { 0x05, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - /* Constant resistance across entire trigger pull */ + { 0x05, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, { 0x01, 0, 110, 0, 0, 0, 0, 0, 0, 0, 0 }, - /* Resistance and vibration when trigger is pulled */ { 0x06, 15, 63, 0, 0, 0, 0, 0, 0, 0, 0 }, }; - //static int trigger_effect = 0; - // trigger_effect = (trigger_effect + 1) % 3; - if (pDevice->_vibration.trigger.left != 0) - { - output->AllowLeftTriggerFFB = true; - - const auto trigger_effect = 2; + { output->AllowLeftTriggerFFB = true; + const auto trigger_effect = 2; memcpy (output->LeftTriggerFFB, effects [trigger_effect], sizeof (effects [trigger_effect])); - - output->LeftTriggerFFB [2] = - static_cast (std::clamp ( - static_cast (pDevice->_vibration.trigger.left) * - config.input.gamepad.impulse_strength_l, 0.0f, 1.0f) - ); - } - - else - { - output->AllowLeftTriggerFFB = true; - - const auto trigger_effect = 0; + output->LeftTriggerFFB [2] = + static_cast (std::clamp ( + static_cast (pDevice->_vibration.trigger.left) * + config.input.gamepad.impulse_strength_l, 0.0f, 1.0f) ); + } else { output->AllowLeftTriggerFFB = true; + const auto trigger_effect = 0; memcpy (output->LeftTriggerFFB, effects [trigger_effect], sizeof (effects [trigger_effect])); } - if (pDevice->_vibration.trigger.right != 0) - { - output->AllowRightTriggerFFB = true; - - const auto trigger_effect = 2; + { output->AllowRightTriggerFFB = true; + const auto trigger_effect = 2; memcpy (output->RightTriggerFFB, effects [trigger_effect], sizeof (effects [trigger_effect])); - - output->RightTriggerFFB [2] = - static_cast (std::clamp ( - static_cast (pDevice->_vibration.trigger.right) * - config.input.gamepad.impulse_strength_r, 0.0f, 1.0f) - ); - } - - else - { - output->AllowRightTriggerFFB = true; - - const auto trigger_effect = 0; + output->RightTriggerFFB [2] = + static_cast (std::clamp ( + static_cast (pDevice->_vibration.trigger.right) * + config.input.gamepad.impulse_strength_r, 0.0f, 1.0f) ); + } else { output->AllowRightTriggerFFB = true; + const auto trigger_effect = 0; memcpy (output->RightTriggerFFB, effects [trigger_effect], sizeof (effects [trigger_effect])); } @@ -2840,7 +2817,9 @@ SK_HID_PlayStationDevice::write_output_report (bool force) const ULONG dwLeftMotor = ReadULongAcquire (&pDevice->_vibration.left); const bool bRumble = - (dwRightMotor != 0 || dwLeftMotor != 0); + (dwRightMotor != 0 || + dwLeftMotor != 0) || (ReadULongAcquire (&pDevice->_vibration.trigger.left) != 0 + || ReadULongAcquire (&pDevice->_vibration.trigger.right) != 0); // 500 msec grace period before allowing controller to use native haptics output->UseRumbleNotHaptics = bRumble || @@ -2849,7 +2828,38 @@ SK_HID_PlayStationDevice::write_output_report (bool force) if (bRumble) { WriteULongRelease (&pDevice->_vibration.last_set, SK::ControlPanel::current_time); - output->AllowMotorPowerLevel = true; + output->AllowMotorPowerLevel = true; + } + + uint8_t effects[3][11] = { + { 0x05, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + { 0x01, 0, 110, 0, 0, 0, 0, 0, 0, 0, 0 }, + { 0x06, 15, 63, 0, 0, 0, 0, 0, 0, 0, 0 }, + }; + + if (pDevice->_vibration.trigger.left != 0) + { output->AllowLeftTriggerFFB = true; + const auto trigger_effect = 2; + memcpy (output->LeftTriggerFFB, effects [trigger_effect], sizeof (effects [trigger_effect])); + output->LeftTriggerFFB [2] = + static_cast (std::clamp ( + static_cast (pDevice->_vibration.trigger.left) * + config.input.gamepad.impulse_strength_l, 0.0f, 1.0f) ); + } else { output->AllowLeftTriggerFFB = true; + const auto trigger_effect = 0; + memcpy (output->LeftTriggerFFB, effects [trigger_effect], sizeof (effects [trigger_effect])); + } + if (pDevice->_vibration.trigger.right != 0) + { output->AllowRightTriggerFFB = true; + const auto trigger_effect = 2; + memcpy (output->RightTriggerFFB, effects [trigger_effect], sizeof (effects [trigger_effect])); + output->RightTriggerFFB [2] = + static_cast (std::clamp ( + static_cast (pDevice->_vibration.trigger.right) * + config.input.gamepad.impulse_strength_r, 0.0f, 1.0f) ); + } else { output->AllowRightTriggerFFB = true; + const auto trigger_effect = 0; + memcpy (output->RightTriggerFFB, effects [trigger_effect], sizeof (effects [trigger_effect])); } output->EnableRumbleEmulation = true; @@ -2869,15 +2879,6 @@ SK_HID_PlayStationDevice::write_output_report (bool force) output-> EnableImprovedRumbleEmulation = true; - output->RumbleEmulationRight = - sk::narrow_cast ( - ReadULongAcquire (&pDevice->_vibration.right) - ); - output->RumbleEmulationLeft = - sk::narrow_cast ( - ReadULongAcquire (&pDevice->_vibration.left) - ); - static bool bMuted = SK_IsGameMuted (); static DWORD dwLastMuteCheck = SK_timeGetTime ();