From 926ccfee7a9fe4f1706e40ba3a88d83ba2e98f97 Mon Sep 17 00:00:00 2001 From: Holger Frydrych Date: Sun, 3 Sep 2023 07:29:17 +0200 Subject: [PATCH] Add functionality to trigger bHaptics from scripts --- .../Solution1/CryGame/CryGame.vcxproj | 30 ++++++------- .../Solution1/CryGame/ScriptObjectGame.cpp | 15 +++++++ .../Solution1/CryGame/ScriptObjectGame.h | 2 + .../Solution1/CryGame/ScriptObjectPlayer.cpp | 26 +++++++++++ .../Solution1/CryGame/ScriptObjectPlayer.h | 1 + .../Solution1/CryGame/VRHaptics.cpp | 44 +++++++++++++++++++ .../CryGame C++/Solution1/CryGame/VRHaptics.h | 4 ++ .../Solution1/CryGame/VRManager.cpp | 2 + .../CryGame C++/Solution1/CryGame/XPlayer.cpp | 8 ++++ .../CryGame C++/Solution1/CryGame/XPlayer.h | 1 + 10 files changed, 118 insertions(+), 15 deletions(-) diff --git a/Sources/CryGame C++/Solution1/CryGame/CryGame.vcxproj b/Sources/CryGame C++/Solution1/CryGame/CryGame.vcxproj index b82e2d1..7a7e88c 100644 --- a/Sources/CryGame C++/Solution1/CryGame/CryGame.vcxproj +++ b/Sources/CryGame C++/Solution1/CryGame/CryGame.vcxproj @@ -115,7 +115,7 @@ Disabled - ..\STLPORT\stlport;..\CryCommon;..\..\..\ThirdParty\dxvk\src\d3d9;..\..\..\ThirdParty\dxvk\include\vulkan\include;..\..\..\ThirdParty\minhook\include;..\..\..\ThirdParty\openvr\headers;..\..\..\ThirdParty\ffmpeg\include;%(AdditionalIncludeDirectories) + ..\STLPORT\stlport;..\CryCommon;..\..\..\ThirdParty\dxvk\src\d3d9;..\..\..\ThirdParty\dxvk\include\vulkan\include;..\..\..\ThirdParty\minhook\include;..\..\..\ThirdParty\openvr\headers;..\..\..\ThirdParty\ffmpeg\include;..\..\..\ThirdParty\bhaptics\include\shared;%(AdditionalIncludeDirectories) _DEBUG;WIN32;_WINDOWS;_USRDLL;CRYGAME_EXPORTS;_SILENCE_STDEXT_HASH_DEPRECATION_WARNINGS;%(PreprocessorDefinitions) true EnableFastChecks @@ -136,9 +136,9 @@ /MACHINE:I386 %(AdditionalOptions) - d3d9.lib;dsound.lib;openvr_api.lib;avcodec.lib;avformat.lib;avutil.lib;swscale.lib;swresample.lib;Shlwapi.lib;wininet.lib;Wsock32.lib;%(AdditionalDependencies) + d3d9.lib;dsound.lib;openvr_api.lib;avcodec.lib;avformat.lib;avutil.lib;swscale.lib;swresample.lib;haptic_library.lib;Shlwapi.lib;wininet.lib;Wsock32.lib;%(AdditionalDependencies) true - ..\..\..\ThirdParty\dxvk\lib;..\..\..\ThirdParty\openvr\lib\win32;..\..\..\ThirdParty\ffmpeg\lib;..\BinkSDK;..\CryNetwork\Debug;.\..\ubisoft.com\GSServices\sdks/gs-sdk-regserver/lib_win32;.\..\ubisoft.com\GSServices\sdks/gs-sdk-msclient/lib_win32;.\..\ubisoft.com\GSServices\sdks/gs-sdk-common/lib_win32;.\..\ubisoft.com\GSServices\sdks/gs-sdk-base/lib_win32;..\ubisoft.com\GSServices\sdks\gs-sdk-cdkey\lib_win32;%(AdditionalLibraryDirectories) + ..\..\..\ThirdParty\dxvk\lib;..\..\..\ThirdParty\openvr\lib\win32;..\..\..\ThirdParty\bhaptics\bin\win32;..\..\..\ThirdParty\ffmpeg\lib;..\BinkSDK;..\CryNetwork\Debug;.\..\ubisoft.com\GSServices\sdks/gs-sdk-regserver/lib_win32;.\..\ubisoft.com\GSServices\sdks/gs-sdk-msclient/lib_win32;.\..\ubisoft.com\GSServices\sdks/gs-sdk-common/lib_win32;.\..\ubisoft.com\GSServices\sdks/gs-sdk-base/lib_win32;..\ubisoft.com\GSServices\sdks\gs-sdk-cdkey\lib_win32;%(AdditionalLibraryDirectories) libcmt.lib;%(IgnoreSpecificDefaultLibraries) true $(IntDir)$(TargetName).lib @@ -167,7 +167,7 @@ Size true false - ..\STLPORT\stlport;..\CryCommon;..\..\..\ThirdParty\dxvk\src\d3d9;..\..\..\ThirdParty\dxvk\include\vulkan\include;..\..\..\ThirdParty\minhook\include;..\..\..\ThirdParty\openvr\headers;..\..\..\ThirdParty\ffmpeg\include;%(AdditionalIncludeDirectories) + ..\STLPORT\stlport;..\CryCommon;..\..\..\ThirdParty\dxvk\src\d3d9;..\..\..\ThirdParty\dxvk\include\vulkan\include;..\..\..\ThirdParty\minhook\include;..\..\..\ThirdParty\openvr\headers;..\..\..\ThirdParty\ffmpeg\include;..\..\..\ThirdParty\bhaptics\include\shared;%(AdditionalIncludeDirectories) _RELEASE;NDEBUG;USE_GAME_DLL;WIN32;_WINDOWS;_USRDLL;CRYGAME_EXPORTS;_SILENCE_STDEXT_HASH_DEPRECATION_WARNINGS;%(PreprocessorDefinitions) true MultiThreadedDLL @@ -190,10 +190,10 @@ /MACHINE:I386 %(AdditionalOptions) - d3d9.lib;dsound.lib;openvr_api.lib;avcodec.lib;avformat.lib;avutil.lib;swscale.lib;swresample.lib;Shlwapi.lib;wininet.lib;Ws2_32.lib;%(AdditionalDependencies) + d3d9.lib;dsound.lib;openvr_api.lib;avcodec.lib;avformat.lib;avutil.lib;swscale.lib;swresample.lib;haptic_library.lib;Shlwapi.lib;wininet.lib;Ws2_32.lib;%(AdditionalDependencies) .\Release/CryGame.dll true - ..\..\..\ThirdParty\dxvk\lib;..\..\..\ThirdParty\openvr\lib\win32;..\..\..\ThirdParty\ffmpeg\lib;..\BinkSDK;..\CryNetwork\Release;.\..\ubisoft.com\GSServices\sdks/gs-sdk-regserver/lib_win32;.\..\ubisoft.com\GSServices\sdks/gs-sdk-msclient/lib_win32;.\..\ubisoft.com\GSServices\sdks/gs-sdk-common/lib_win32;.\..\ubisoft.com\GSServices\sdks/gs-sdk-base/lib_win32;..\ubisoft.com\GSServices\sdks\gs-sdk-cdkey\lib_win32;%(AdditionalLibraryDirectories) + ..\..\..\ThirdParty\dxvk\lib;..\..\..\ThirdParty\openvr\lib\win32;..\..\..\ThirdParty\bhaptics\bin\win32;..\..\..\ThirdParty\ffmpeg\lib;..\BinkSDK;..\CryNetwork\Release;.\..\ubisoft.com\GSServices\sdks/gs-sdk-regserver/lib_win32;.\..\ubisoft.com\GSServices\sdks/gs-sdk-msclient/lib_win32;.\..\ubisoft.com\GSServices\sdks/gs-sdk-common/lib_win32;.\..\ubisoft.com\GSServices\sdks/gs-sdk-base/lib_win32;..\ubisoft.com\GSServices\sdks\gs-sdk-cdkey\lib_win32;%(AdditionalLibraryDirectories) .\Release/CryGame.pdb $(IntDir)$(TargetName).lib false @@ -221,7 +221,7 @@ Size true false - ..\STLPORT\stlport;..\CryCommon;..\..\..\ThirdParty\dxvk\src\d3d9;..\..\..\ThirdParty\dxvk\include\vulkan\include;..\..\..\ThirdParty\minhook\include;..\..\..\ThirdParty\openvr\headers;..\..\..\ThirdParty\ffmpeg\include;%(AdditionalIncludeDirectories) + ..\STLPORT\stlport;..\CryCommon;..\..\..\ThirdParty\dxvk\src\d3d9;..\..\..\ThirdParty\dxvk\include\vulkan\include;..\..\..\ThirdParty\minhook\include;..\..\..\ThirdParty\openvr\headers;..\..\..\ThirdParty\ffmpeg\include;..\..\..\ThirdParty\bhaptics\include\shared;%(AdditionalIncludeDirectories) NDEBUG;USE_GAME_DLL;WIN32;_WINDOWS;_USRDLL;CRYGAME_EXPORTS;%(PreprocessorDefinitions) true MultiThreadedDLL @@ -243,9 +243,9 @@ /MACHINE:I386 /OPT:ref,icf %(AdditionalOptions) - d3d9.lib;dsound.lib;openvr_api.lib;avcodec.lib;avformat.lib;avutil.lib;swscale.lib;swresample.lib;Shlwapi.lib;wininet.lib;Ws2_32.lib;%(AdditionalDependencies) + d3d9.lib;dsound.lib;openvr_api.lib;avcodec.lib;avformat.lib;avutil.lib;swscale.lib;swresample.lib;haptic_library.lib;Shlwapi.lib;wininet.lib;Ws2_32.lib;%(AdditionalDependencies) true - ..\..\..\ThirdParty\dxvk\lib;..\..\..\ThirdParty\openvr\lib\win32;..\..\..\ThirdParty\ffmpeg\lib;..\BinkSDK;..\CryNetwork\Release;.\..\ubisoft.com\GSServices\sdks/gs-sdk-regserver/lib_win32;.\..\ubisoft.com\GSServices\sdks/gs-sdk-msclient/lib_win32;.\..\ubisoft.com\GSServices\sdks/gs-sdk-result/lib_win32;.\..\ubisoft.com\GSServices\sdks/gs-sdk-cdkey/lib_win32;.\..\ubisoft.com\GSServices\sdks/gs-sdk-common/lib_win32;.\..\ubisoft.com\GSServices\sdks/gs-sdk-base/lib_win32;%(AdditionalLibraryDirectories) + ..\..\..\ThirdParty\dxvk\lib;..\..\..\ThirdParty\openvr\lib\win32;..\..\..\ThirdParty\bhaptics\bin\win32;..\..\..\ThirdParty\ffmpeg\lib;..\BinkSDK;..\CryNetwork\Release;.\..\ubisoft.com\GSServices\sdks/gs-sdk-regserver/lib_win32;.\..\ubisoft.com\GSServices\sdks/gs-sdk-msclient/lib_win32;.\..\ubisoft.com\GSServices\sdks/gs-sdk-result/lib_win32;.\..\ubisoft.com\GSServices\sdks/gs-sdk-cdkey/lib_win32;.\..\ubisoft.com\GSServices\sdks/gs-sdk-common/lib_win32;.\..\ubisoft.com\GSServices\sdks/gs-sdk-base/lib_win32;%(AdditionalLibraryDirectories) false true true @@ -270,7 +270,7 @@ Disabled - ..\STLPORT\stlport;..\CryCommon;..\..\..\ThirdParty\dxvk\src\d3d9;..\..\..\ThirdParty\dxvk\include\vulkan\include;..\..\..\ThirdParty\minhook\include;..\..\..\ThirdParty\openvr\headers;..\..\..\ThirdParty\ffmpeg\include;%(AdditionalIncludeDirectories) + ..\STLPORT\stlport;..\CryCommon;..\..\..\ThirdParty\dxvk\src\d3d9;..\..\..\ThirdParty\dxvk\include\vulkan\include;..\..\..\ThirdParty\minhook\include;..\..\..\ThirdParty\openvr\headers;..\..\..\ThirdParty\ffmpeg\include;..\..\..\ThirdParty\bhaptics\include\shared;%(AdditionalIncludeDirectories) _AMD64_;_DEBUG;WIN64;WIN32;_WINDOWS;_USRDLL;CRYGAME_EXPORTS;DIVX;%(PreprocessorDefinitions) Default MultiThreadedDebug @@ -290,7 +290,7 @@ /MACHINE:AMD64 %(AdditionalOptions) - d3d9.lib;dsound.lib;openvr_api.lib;avcodec.lib;avformat.lib;avutil.lib;swscale.lib;swresample.lib;Shlwapi.lib;wininet.lib;Ws2_32.lib;../CryCommon/fSinCos64.lib;%(AdditionalDependencies) + d3d9.lib;dsound.lib;openvr_api.lib;avcodec.lib;avformat.lib;avutil.lib;swscale.lib;swresample.lib;haptic_library.lib;Shlwapi.lib;wininet.lib;Ws2_32.lib;../CryCommon/fSinCos64.lib;%(AdditionalDependencies) $(OutDir)$(ProjectName).dll true libcmt.lib;%(IgnoreSpecificDefaultLibraries) @@ -298,7 +298,7 @@ $(OutDir)$(ProjectName).pdb true $(OutDir)$(ProjectName).lib - ..\..\..\ThirdParty\dxvk\lib;..\..\..\ThirdParty\openvr\lib\win32;..\..\..\ThirdParty\ffmpeg\lib; + ..\..\..\ThirdParty\dxvk\lib;..\..\..\ThirdParty\openvr\lib\win32;..\..\..\ThirdParty\bhaptics\bin\win32;..\..\..\ThirdParty\ffmpeg\lib; false @@ -323,7 +323,7 @@ AnySuitable true Speed - ..\STLPORT\stlport;..\CryCommon;..\..\..\ThirdParty\dxvk\src\d3d9;..\..\..\ThirdParty\dxvk\include\vulkan\include;..\..\..\ThirdParty\minhook\include;..\..\..\ThirdParty\openvr\headers;..\..\..\ThirdParty\ffmpeg\include;%(AdditionalIncludeDirectories) + ..\STLPORT\stlport;..\CryCommon;..\..\..\ThirdParty\dxvk\src\d3d9;..\..\..\ThirdParty\dxvk\include\vulkan\include;..\..\..\ThirdParty\minhook\include;..\..\..\ThirdParty\openvr\headers;..\..\..\ThirdParty\ffmpeg\include;..\..\..\ThirdParty\bhaptics\include\shared;%(AdditionalIncludeDirectories) _RELEASE;NDEBUG;WIN64;WIN32;_AMD64_;_WINDOWS;_USRDLL;CRYGAME_EXPORTS;DIVX;%(PreprocessorDefinitions) Default MultiThreadedDLL @@ -341,7 +341,7 @@ Default - d3d9.lib;dsound.lib;openvr_api.lib;avcodec.lib;avformat.lib;avutil.lib;swscale.lib;swresample.lib;Shlwapi.lib;wininet.lib;Ws2_32.lib;../CryCommon/fSinCos64.lib;%(AdditionalDependencies) + d3d9.lib;dsound.lib;openvr_api.lib;avcodec.lib;avformat.lib;avutil.lib;swscale.lib;swresample.lib;haptic_library.lib;Shlwapi.lib;wininet.lib;Ws2_32.lib;../CryCommon/fSinCos64.lib;%(AdditionalDependencies) $(OutDir)$(ProjectName).dll true libcmt.lib;%(IgnoreSpecificDefaultLibraries) @@ -349,7 +349,7 @@ $(OutDir)$(ProjectName).pdb true $(OutDir)$(ProjectName).lib - ..\..\..\ThirdParty\dxvk\lib;..\..\..\ThirdParty\openvr\lib\win32;..\..\..\ThirdParty\ffmpeg\lib; + ..\..\..\ThirdParty\dxvk\lib;..\..\..\ThirdParty\openvr\lib\win32;..\..\..\ThirdParty\bhaptics\bin\win32;..\..\..\ThirdParty\ffmpeg\lib; false diff --git a/Sources/CryGame C++/Solution1/CryGame/ScriptObjectGame.cpp b/Sources/CryGame C++/Solution1/CryGame/ScriptObjectGame.cpp index f662482..4170430 100644 --- a/Sources/CryGame C++/Solution1/CryGame/ScriptObjectGame.cpp +++ b/Sources/CryGame C++/Solution1/CryGame/ScriptObjectGame.cpp @@ -324,6 +324,7 @@ void CScriptObjectGame::InitializeTemplate(IScriptSystem *pSS) REG_FUNC(CScriptObjectGame,IsStopVideoRequested); REG_FUNC(CScriptObjectGame, CreateHapticsEffectFlat); REG_FUNC(CScriptObjectGame, CreateHapticsEffectCustom); + REG_FUNC(CScriptObjectGame, RegisterBHapticsEffect); } ////////////////////////////////////////////////////////////////////// @@ -3901,6 +3902,20 @@ int CScriptObjectGame::CreateHapticsEffectCustom(IFunctionHandler* pH) return pH->EndFunction(); } +int CScriptObjectGame::RegisterBHapticsEffect(IFunctionHandler* pH) +{ + CHECK_PARAMETERS(2); + const char* key = nullptr; + const char* fileName = nullptr; + pH->GetParam(1, key); + pH->GetParam(2, fileName); + + if (key != nullptr && fileName != nullptr) + gVR->GetHaptics()->RegisterBHapticsEffect(key, fileName); + + return pH->EndFunction(); +} + ////////////////////////////////////////////////////////////////////////// int CScriptObjectGame::EnableQuicksave(IFunctionHandler * pH) { diff --git a/Sources/CryGame C++/Solution1/CryGame/ScriptObjectGame.h b/Sources/CryGame C++/Solution1/CryGame/ScriptObjectGame.h index 627fe8e..ff71fde 100644 --- a/Sources/CryGame C++/Solution1/CryGame/ScriptObjectGame.h +++ b/Sources/CryGame C++/Solution1/CryGame/ScriptObjectGame.h @@ -214,6 +214,8 @@ public _ScriptableEx int CreateHapticsEffectFlat(IFunctionHandler* pH); int CreateHapticsEffectCustom(IFunctionHandler* pH); + int RegisterBHapticsEffect(IFunctionHandler* pH); + private: CXGame * m_pGame; diff --git a/Sources/CryGame C++/Solution1/CryGame/ScriptObjectPlayer.cpp b/Sources/CryGame C++/Solution1/CryGame/ScriptObjectPlayer.cpp index 8eae33b..b1cbf38 100644 --- a/Sources/CryGame C++/Solution1/CryGame/ScriptObjectPlayer.cpp +++ b/Sources/CryGame C++/Solution1/CryGame/ScriptObjectPlayer.cpp @@ -186,6 +186,7 @@ void CScriptObjectPlayer::InitializeTemplate(IScriptSystem *pSS) REG_FUNC(CScriptObjectPlayer,SetSmoothInput); REG_FUNC(CScriptObjectPlayer, TriggerWeaponHapticEffect); REG_FUNC(CScriptObjectPlayer, TriggerHapticEffect); + REG_FUNC(CScriptObjectPlayer, TriggerBHapticsEffect); pSS->SetGlobalValue("BITMASK_PLAYER",BITMASK_PLAYER); pSS->SetGlobalValue("BITMASK_WEAPON",BITMASK_WEAPON); @@ -2150,6 +2151,31 @@ int CScriptObjectPlayer::TriggerHapticEffect(IFunctionHandler* pH) return pH->EndFunction(); } +int CScriptObjectPlayer::TriggerBHapticsEffect(IFunctionHandler* pH) +{ + const char* keyRight = nullptr; + const char* keyLeft = nullptr; + float intensity = 1.0f; + float offsetAngleX = 0; + float offsetY = 0; + if (pH->GetParamCount() >= 2) + { + pH->GetParam(1, keyRight); + pH->GetParam(2, keyLeft); + } + if (pH->GetParamCount() >= 3) + pH->GetParam(3, intensity); + if (pH->GetParamCount() >= 4) + pH->GetParam(4, offsetAngleX); + if (pH->GetParamCount() >= 5) + pH->GetParam(5, offsetY); + + if (keyRight != nullptr && keyLeft != nullptr) + m_pPlayer->TriggerBHapticsEffect(keyRight, keyLeft, intensity, offsetAngleX, offsetY); + + return pH->EndFunction(); +} + ////////////////////////////////////////////////////////////////////// IEntityRender * CScriptObjectPlayer::GetIEntityRender(const pe_params_foreign_data & fd) { diff --git a/Sources/CryGame C++/Solution1/CryGame/ScriptObjectPlayer.h b/Sources/CryGame C++/Solution1/CryGame/ScriptObjectPlayer.h index 59566cc..6e3eff6 100644 --- a/Sources/CryGame C++/Solution1/CryGame/ScriptObjectPlayer.h +++ b/Sources/CryGame C++/Solution1/CryGame/ScriptObjectPlayer.h @@ -184,6 +184,7 @@ public IScriptObjectSink // controller haptics int TriggerWeaponHapticEffect(IFunctionHandler* pH); int TriggerHapticEffect(IFunctionHandler* pH); + int TriggerBHapticsEffect(IFunctionHandler* pH); private: diff --git a/Sources/CryGame C++/Solution1/CryGame/VRHaptics.cpp b/Sources/CryGame C++/Solution1/CryGame/VRHaptics.cpp index 8cc97b4..740328b 100644 --- a/Sources/CryGame C++/Solution1/CryGame/VRHaptics.cpp +++ b/Sources/CryGame C++/Solution1/CryGame/VRHaptics.cpp @@ -4,11 +4,16 @@ #include "VRInput.h" #include "VRManager.h" +#include + +#include "ICryPak.h" + void VRHaptics::Init(CXGame* game, VRInput* vrInput) { m_pGame = game; m_vrInput = vrInput; + InitialiseSync("farcryvr", "Far Cry VR"); InitEffects(); } @@ -45,6 +50,33 @@ void VRHaptics::Update() } } +void VRHaptics::RegisterBHapticsEffect(const char* key, const char* file) +{ + if (IsFeedbackRegistered(key)) + { + CryLogAlways("BHaptics effect already registered: %s", key); + return; + } + + ICryPak* pak = m_pGame->GetSystem()->GetIPak(); + FILE* f = pak->FOpen(file, "rb"); + if (!f) + { + CryLogAlways("BHaptics effect file not found: %s", file); + return; + } + pak->FSeek(f, 0, SEEK_END); + int size = pak->FTell(f); + pak->FSeek(f, 0, SEEK_SET); + + char* buffer = new char[size]; + pak->FRead(buffer, size, 1, f); + pak->FClose(f); + + RegisterFeedbackFromTactFile(key, buffer); + delete[] buffer; +} + void VRHaptics::TriggerEffect(int hand, const char* effectName, float amplitudeModifier) { if (m_activeEffects[hand].size() >= 20) @@ -60,12 +92,24 @@ void VRHaptics::TriggerEffect(int hand, const char* effectName, float amplitudeM m_activeEffects[hand].push_back(ActiveHapticEffect{ &it->second, 0, amplitudeModifier }); } +void VRHaptics::TriggerBHapticsEffect(const char* key, float intensity, float offsetAngleX, float offsetY) +{ + SubmitRegisteredWithOption(key, key, intensity, 1.0f, offsetAngleX, offsetY); +} + void VRHaptics::StopEffects(int hand) { m_activeEffects[hand].clear(); m_vrInput->TriggerHaptics(hand, 0, 0, 0); } +void VRHaptics::StopAllEffects() +{ + StopEffects(0); + StopEffects(1); + TurnOff(); +} + void VRHaptics::CreateFlatEffect(const char* effectName, float duration, float amplitude, float easeInTime, float easeOutTime) { HapticEffect& effect = m_effects[effectName]; diff --git a/Sources/CryGame C++/Solution1/CryGame/VRHaptics.h b/Sources/CryGame C++/Solution1/CryGame/VRHaptics.h index b1a7b75..48868d3 100644 --- a/Sources/CryGame C++/Solution1/CryGame/VRHaptics.h +++ b/Sources/CryGame C++/Solution1/CryGame/VRHaptics.h @@ -24,8 +24,12 @@ class VRHaptics void Init(CXGame* game, VRInput* vrInput); void Update(); + void RegisterBHapticsEffect(const char* key, const char* file); + void TriggerEffect(int hand, const char* effectName, float amplitudeModifier = 1.0f); + void TriggerBHapticsEffect(const char* key, float intensity = 1.0f, float offsetAngleX = 0, float offsetY = 0); void StopEffects(int hand); + void StopAllEffects(); void CreateFlatEffect(const char* effectName, float duration, float amplitude, float easeInTime = 0.0f, float easeOutTime = 0.0f); void CreateCustomEffect(const char* effectName, float* amplitudes, int count); diff --git a/Sources/CryGame C++/Solution1/CryGame/VRManager.cpp b/Sources/CryGame C++/Solution1/CryGame/VRManager.cpp index 2874de7..21234b6 100644 --- a/Sources/CryGame C++/Solution1/CryGame/VRManager.cpp +++ b/Sources/CryGame C++/Solution1/CryGame/VRManager.cpp @@ -629,6 +629,8 @@ void VRManager::ProcessInput() vr::VROverlay()->SetOverlayFlag(m_hudOverlay, vr::VROverlayFlags_MakeOverlaysInteractiveIfVisible, true); vr::VROverlay()->SetOverlayFlag(m_hudOverlay, vr::VROverlayFlags_HideLaserIntersection, true); RecalibrateView(); + + m_vrHaptics.StopAllEffects(); } SetHudInFrontOfPlayer(); ProcessMenuInput(); diff --git a/Sources/CryGame C++/Solution1/CryGame/XPlayer.cpp b/Sources/CryGame C++/Solution1/CryGame/XPlayer.cpp index 61f7361..36f6f9c 100644 --- a/Sources/CryGame C++/Solution1/CryGame/XPlayer.cpp +++ b/Sources/CryGame C++/Solution1/CryGame/XPlayer.cpp @@ -2749,6 +2749,14 @@ void CPlayer::TriggerWeaponHapticEffect(const char* effectName, float amplitudeM } } +void CPlayer::TriggerBHapticsEffect(const char* keyRight, const char* keyLeft, float intensity, float offsetAngleX, float offsetY) +{ + if (IsMyPlayer()) + { + gVR->GetHaptics()->TriggerBHapticsEffect(m_mainHand == 1 ? keyRight : keyLeft, intensity, offsetAngleX, offsetY); + } +} + void CPlayer::ModifyVehicleWeaponAim(Vec3& aimPos, Vec3& aimAngles) { if (!m_usesMotionControls) diff --git a/Sources/CryGame C++/Solution1/CryGame/XPlayer.h b/Sources/CryGame C++/Solution1/CryGame/XPlayer.h index 2916ee9..3543962 100644 --- a/Sources/CryGame C++/Solution1/CryGame/XPlayer.h +++ b/Sources/CryGame C++/Solution1/CryGame/XPlayer.h @@ -299,6 +299,7 @@ enum eInVehiclestate void TriggerHapticEffectOnMainHand(const char* effectName, float amplitudeModifier = 1.0f); void TriggerHapticEffectOnOffHand(const char* effectName, float amplitudeModifier = 1.0f); void TriggerWeaponHapticEffect(const char* effectName, float amplitudeModifier = 1.0f); + void TriggerBHapticsEffect(const char* keyRight, const char* keyLeft, float intensity = 1.0f, float offsetAngleX = 0, float offsetY = 0); void ModifyVehicleWeaponAim(Vec3& aimPos, Vec3& aimAngles); void UpdateMountedGunAnglesFromController();