Skip to content

Commit e28dcaf

Browse files
committed
Integrate ProTube events for weapon firing
1 parent f48e5c4 commit e28dcaf

File tree

6 files changed

+59
-0
lines changed

6 files changed

+59
-0
lines changed

Code/Shotgun.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -379,6 +379,7 @@ bool CShotgun::Shoot(bool resetAnimation, bool autoreload/* =true */, bool noSou
379379
// gEnv->pInput->ForceFeedbackEvent( SFFOutputEvent(eDI_XI, eFF_Rumble_Basic, 0.15f, 0.0f, fabsf(m_recoilparams.back_impulse)*3.0f) );
380380
gXR->GetInput()->SendHapticEvent(WEAPON_HAND, 0.15f, fabsf(m_recoilparams.back_impulse)*3.0f);
381381
gHaptics->TriggerBHapticsEffectForSide(WEAPON_HAND, "shotgun_l_vest", "shotgun_r_vest", 0.4f);
382+
gHaptics->TriggerProtubeEffectWeapon(0.8f, 0.8f, 0.5f);
382383
if (gVR->IsOffHandGrabbingWeapon())
383384
gXR->GetInput()->SendHapticEvent(OFF_HAND, 0.15f, fabsf(m_recoilparams.back_impulse)*3.0f);
384385
}

Code/Single.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2972,6 +2972,8 @@ void CSingle::RecoilImpulse(const Vec3& firingPos, const Vec3& firingDir)
29722972
{
29732973
gXR->GetInput()->SendHapticEvent(m_pWeapon->IsDualWieldMaster() ? RIGHT_HAND : LEFT_HAND, 0.05f, max(0.35f, fabsf(m_recoilparams.back_impulse) * 2.0f));
29742974
gHaptics->TriggerBHapticsEffectForSide(m_pWeapon->IsDualWieldMaster() ? RIGHT_HAND : LEFT_HAND, "shoot_l_vest", "shoot_r_vest", 0.2f * max(0.35f, fabsf(m_recoilparams.back_impulse) * 2.0f));
2975+
bool protubeOffHand = g_pGameCVars->vr_weapon_hand == 1 ? m_pWeapon->IsDualWieldSlave() : m_pWeapon->IsDualWieldMaster();
2976+
gHaptics->TriggerProtubeEffect(0.3f, 0.f, 0.f, protubeOffHand);
29752977
}
29762978
else
29772979
{
@@ -2987,22 +2989,27 @@ void CSingle::RecoilImpulse(const Vec3& firingPos, const Vec3& firingDir)
29872989
else if (strcmp(weaponClass, "GaussRifle") == 0)
29882990
{
29892991
gHaptics->TriggerBHapticsEffectForSide(WEAPON_HAND, "shotgun_l_vest", "shotgun_r_vest", 0.3f);
2992+
gHaptics->TriggerProtubeEffectWeapon(0.6f, 0.5f, 0.5f);
29902993
}
29912994
else if (strcmp(weaponClass, "DSG1") == 0)
29922995
{
29932996
gHaptics->TriggerBHapticsEffectForSide(WEAPON_HAND, "shotgun_l_vest", "shotgun_r_vest", 0.3f);
2997+
gHaptics->TriggerProtubeEffectWeapon(0.6f, 0.5f, 0.5f);
29942998
}
29952999
else if (strcmp(weaponClass, "LAW") == 0)
29963000
{
29973001
gHaptics->TriggerBHapticsEffectForSide(WEAPON_HAND, "rpg_l_vest", "rpg_r_vest", 0.5f);
3002+
gHaptics->TriggerProtubeEffectWeapon(1.f, 1.f, 1.f);
29983003
}
29993004
else if (strcmp(weaponClass, "TACGun") == 0 || strcmp(weaponClass, "TACGun_Fleet") == 0)
30003005
{
30013006
gHaptics->TriggerBHapticsEffectForSide(WEAPON_HAND, "rpg_l_vest", "rpg_r_vest", 0.5f);
3007+
gHaptics->TriggerProtubeEffectWeapon(1.f, 1.f, 1.f);
30023008
}
30033009
else
30043010
{
30053011
gHaptics->TriggerBHapticsEffectForSide(WEAPON_HAND, "shoot_l_vest", "shoot_r_vest", 0.15f * max(0.35f, fabsf(m_recoilparams.back_impulse) * 2.0f));
3012+
gHaptics->TriggerProtubeEffectWeapon(0.4f, 0.0f, 0.0f);
30063013
}
30073014
}
30083015
}
Binary file not shown.
Binary file not shown.

Code/VR/VRHaptics.cpp

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#include "VRHaptics.h"
44
#include "VRManager.h"
55
#include <HapticLibrary.h>
6+
#include <protubevr.h>
67

78
#include "GameCVars.h"
89
#include "OpenXRRuntime.h"
@@ -18,6 +19,7 @@ VRHaptics* gHaptics = &haptics;
1819
void VRHaptics::Init()
1920
{
2021
InitialiseSync("crysisvr", "Crysis VR");
22+
InitRifle();
2123
InitEffects();
2224
CryLogAlways("Initialised bHaptics support");
2325
}
@@ -104,6 +106,28 @@ void VRHaptics::StopBHapticsEffect(const char* key)
104106
TurnOffKey(key);
105107
}
106108

109+
void VRHaptics::TriggerProtubeEffect(float kickPower, float rumblePower, float rumbleSeconds, bool offHand)
110+
{
111+
if (kickPower > 0)
112+
{
113+
if (rumblePower > 0 && rumbleSeconds > 0)
114+
ProtubeShot(kickPower, rumblePower, rumbleSeconds, offHand);
115+
else
116+
ProtubeKick(kickPower, offHand);
117+
}
118+
else if (rumblePower > 0 && rumbleSeconds > 0)
119+
{
120+
ProtubeRumble(rumblePower, rumbleSeconds, offHand);
121+
}
122+
}
123+
124+
void VRHaptics::TriggerProtubeEffectWeapon(float kickPower, float rumblePower, float rumbleSeconds)
125+
{
126+
TriggerProtubeEffect(kickPower, rumblePower, rumbleSeconds);
127+
if (gVR->IsOffHandGrabbingWeapon())
128+
TriggerProtubeEffect(kickPower, rumblePower, rumbleSeconds, true);
129+
}
130+
107131
void VRHaptics::InitEffects()
108132
{
109133
RegisterBHapticsEffect("jump_vest", "bhaptics/vest/Jumping.tact");
@@ -130,3 +154,25 @@ void VRHaptics::InitEffects()
130154
RegisterBHapticsEffect("speedsprintwater_vest", "bhaptics/vest/SpeedSprintWater.tact");
131155
RegisterBHapticsEffect("vehicle_vest", "bhaptics/vest/VehicleRumble.tact");
132156
}
157+
158+
void VRHaptics::ProtubeKick(float power, bool offHand)
159+
{
160+
uint8 pw = clamp_tpl(power, 0.f, 1.f) * 255;
161+
ForceTubeVRChannel channel = offHand ? rifleBolt : rifleButt;
162+
KickChannel(pw, channel);
163+
}
164+
165+
void VRHaptics::ProtubeRumble(float power, float seconds, bool offHand)
166+
{
167+
uint8 pw = clamp_tpl(power, 0.f, 1.f) * 255;
168+
ForceTubeVRChannel channel = offHand ? rifleBolt : rifleButt;
169+
RumbleChannel(pw, seconds, channel);
170+
}
171+
172+
void VRHaptics::ProtubeShot(float kickPower, float rumblePower, float rumbleSeconds, bool offHand)
173+
{
174+
uint8 kpw = clamp_tpl(kickPower, 0.f, 1.f) * 255;
175+
uint8 rpw = clamp_tpl(rumblePower, 0.f, 1.f) * 255;
176+
ForceTubeVRChannel channel = offHand ? rifleBolt : rifleButt;
177+
ShotChannel(kpw, rpw, rumbleSeconds, channel);
178+
}

Code/VR/VRHaptics.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,14 @@ class VRHaptics
1414
void TriggerBHapticsEffectForSide(EVRHand hand, const char* keyLeft, const char* keyRight, float intensity = 1.0f);
1515
bool IsBHapticsEffectPlaying(const char* key) const;
1616
void StopBHapticsEffect(const char* key);
17+
void TriggerProtubeEffect(float kickPower, float rumblePower, float rumbleSeconds, bool offHand = false);
18+
void TriggerProtubeEffectWeapon(float kickPower, float rumblePower, float rumbleSeconds);
1719

1820
private:
1921
void InitEffects();
22+
void ProtubeKick(float power, bool offHand = false);
23+
void ProtubeRumble(float power, float seconds, bool offHand = false);
24+
void ProtubeShot(float kickPower, float rumblePower, float rumbleSeconds, bool offHand = false);
2025
};
2126

2227
extern VRHaptics* gHaptics;

0 commit comments

Comments
 (0)