JKA Weapon Haptics & Fix for unresponsive menu after training in JKA

This commit is contained in:
Simon 2023-04-19 22:53:48 +01:00
parent 4bea59c543
commit abedc8d96c
4 changed files with 68 additions and 9 deletions

View file

@ -18,6 +18,8 @@ extern "C" {
}
#include <client/client.h>
#include <weapons.h>
#include <client_ui.h>
//#define ENABLE_GL_DEBUG
@ -48,7 +50,8 @@ JKXR Stuff
bool VR_UseScreenLayer()
{
vr.using_screen_layer = (bool)((vr.cin_camera && !vr.immersive_cinematics) ||
vr.using_screen_layer = _UI_IsFullscreen() ||
(bool)((vr.cin_camera && !vr.immersive_cinematics) ||
vr.misc_camera ||
(CL_IsRunningInGameCinematic() || CL_InGameCinematicOnStandBy()) ||
(cls.state == CA_CINEMATIC) ||
@ -497,8 +500,14 @@ void VR_HapticEvent(const char* event, int position, int flags, int intensity, f
//Pass on to any external services
VR_ExternalHapticEvent(event, position, flags, intensity, angle, yHeight);
float fIntensity = intensity / 100.0f;
//Controller Haptic Support
int weaponFireChannel = vr.weapon_stabilised ? 3 : (vr_control_scheme->integer ? 2 : 1);
if (cl.frame.ps.weapon == WP_SABER && vr.dualsabers)
{
weaponFireChannel = 3;
}
if (flags != 0)
{
weaponFireChannel = flags;
@ -515,37 +524,37 @@ void VR_HapticEvent(const char* event, int position, int flags, int intensity, f
}
else if (strcmp(event, "shotgun") == 0 || strcmp(event, "fireball") == 0)
{
TBXR_Vibrate(400, 3, 1.0);
TBXR_Vibrate(400, 3, fIntensity);
}
else if (strcmp(event, "bullet") == 0)
{
TBXR_Vibrate(150, 3, 1.0);
TBXR_Vibrate(150, 3, fIntensity);
}
else if (strcmp(event, "chainsaw_fire") == 0 ||
strcmp(event, "RTCWQuest:fire_tesla") == 0)
{
TBXR_Vibrate(500, weaponFireChannel, 1.0);
TBXR_Vibrate(500, weaponFireChannel, fIntensity);
}
else if (strcmp(event, "machinegun_fire") == 0 || strcmp(event, "plasmagun_fire") == 0)
{
TBXR_Vibrate(90, weaponFireChannel, 0.8);
TBXR_Vibrate(90, weaponFireChannel, fIntensity);
}
else if (strcmp(event, "shotgun_fire") == 0)
{
TBXR_Vibrate(250, weaponFireChannel, 1.0);
TBXR_Vibrate(250, weaponFireChannel, fIntensity);
}
else if (strcmp(event, "rocket_fire") == 0 ||
strcmp(event, "RTCWQuest:fire_sniper") == 0 ||
strcmp(event, "bfg_fire") == 0 ||
strcmp(event, "handgrenade_fire") == 0 )
{
TBXR_Vibrate(400, weaponFireChannel, 1.0);
TBXR_Vibrate(400, weaponFireChannel, fIntensity);
}
else if (strcmp(event, "selector_icon") == 0 ||
strcmp(event, "use_button") == 0 )
{
//Quick blip
TBXR_Vibrate(50, flags, 1.0);
TBXR_Vibrate(50, flags, fIntensity);
}
}

View file

@ -204,7 +204,7 @@ void HandleInput_Default( ovrInputStateTrackedRemote *pDominantTrackedRemoteNew,
handleTrackedControllerButton(&rightTrackedRemoteState_new, &rightTrackedRemoteState_old, xrButton_Enter, A_ESCAPE);
static float menuYaw = 0;
if (VR_UseScreenLayer() && !vr.misc_camera && !vr.cin_camera /*bit of a fiddle, but if we are in a misc camera or cin camera, we are in the game and shouldn't be in here*/)
if (VR_UseScreenLayer())
{
bool controlsLeftHanded = vr_control_scheme->integer >= 10;
if (controlsLeftHanded == vr.menu_right_handed) {

View file

@ -1460,6 +1460,9 @@ void CG_AddViewWeapon( playerState_t *ps )
val = 1.0f;
}
int position = vr->weapon_stabilised ? 4 : (vr->right_handed ? 1 : 2);
cgi_HapticEvent("chainsaw_fire", position, 0, 60 * val, 0, 0);
val += Q_flrand(0.0f, 1.0f) * 0.5f;
FX_AddSprite( flash.origin, NULL, NULL, 3.0f * val * scale, 0.0f, 0.7f, 0.7f, WHITE, WHITE, Q_flrand(0.0f, 1.0f) * 360, 0.0f, 1.0f, shader, FX_USE_ALPHA | FX_DEPTH_HACK );
@ -3448,6 +3451,50 @@ void CG_FireWeapon( centity_t *cent, qboolean alt_fire )
}
}
//Are we the player?
if (cent->gent->client->ps.clientNum == 0)
{
int position = vr->weapon_stabilised ? 4 : (vr->right_handed ? 1 : 2);
//Haptics
switch (ent->weapon) {
case WP_SABER:
if (cent->gent->client->ps.dualSabers) position = 4;
cgi_HapticEvent("chainsaw_fire", position, 0, 40, 0, 0);
break;
case WP_BRYAR_PISTOL:
case WP_BOWCASTER:
case WP_BLASTER:
case WP_ATST_MAIN:
cgi_HapticEvent("machinegun_fire", position, 0, (ent->weapon == WP_BRYAR_PISTOL) ? 60 : 100, 0, 0);
break;
case WP_BLASTER_PISTOL:
cgi_HapticEvent("shotgun_fire", position, 0, 100, 0, 0);
break;
case WP_THERMAL:
case WP_DET_PACK:
case WP_TRIP_MINE:
cgi_HapticEvent("handgrenade_fire", position, 0, 80, 0, 0);
break;
case WP_ROCKET_LAUNCHER:
case WP_ATST_SIDE:
cgi_HapticEvent("rocket_fire", position, 0, 100, 0, 0);
break;
case WP_DISRUPTOR:
cgi_HapticEvent("RTCWQuest:fire_sniper", position, 0, 100, 0, 0);
break;
case WP_FLECHETTE:
case WP_REPEATER:
cgi_HapticEvent("plasmagun_fire", position, 0, 100, 0, 0);
break;
case WP_DEMP2:
case WP_EMPLACED_GUN:
cgi_HapticEvent("bfg_fire", position, 0, 100, 0, 0);
break;
}
}
// Do overcharge sound that get's added to the top
/* if (( ent->powerups & ( 1<<PW_WEAPON_OVERCHARGE )))
{

View file

@ -1349,6 +1349,9 @@ void CG_AddViewWeapon( playerState_t *ps )
val = 1.0f;
}
int position = vr->weapon_stabilised ? 4 : (vr->right_handed ? 1 : 2);
cgi_HapticEvent("chainsaw_fire", position, 0, 60 * val, 0, 0);
val += Q_flrand(0.0f, 1.0f) * 0.5f;
FX_AddSprite( flash.origin, NULL, NULL, 3.0f * val * scale, 0.0f, 0.7f, 0.7f, WHITE, WHITE, Q_flrand(0.0f, 1.0f) * 360, 0.0f, 1.0f, shader, FX_USE_ALPHA | FX_DEPTH_HACK );