mirror of
https://github.com/DrBeef/JKXR.git
synced 2024-11-22 20:21:21 +00:00
Add use haptic feedback; Fix use in 3rd person mode
This commit is contained in:
parent
da501166fa
commit
0a09cfba0d
5 changed files with 42 additions and 12 deletions
|
@ -515,7 +515,8 @@ void VR_HapticEvent(const char* event, int position, int flags, int intensity, f
|
|||
{
|
||||
TBXR_Vibrate(400, weaponFireChannel, 1.0);
|
||||
}
|
||||
else if (strcmp(event, "selector_icon") == 0)
|
||||
else if (strcmp(event, "selector_icon") == 0 ||
|
||||
strcmp(event, "use_button") == 0 )
|
||||
{
|
||||
//Quick blip
|
||||
TBXR_Vibrate(50, flags, 1.0);
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
|
||||
#define USE_GESTURE_OFF_HAND 1
|
||||
#define USE_GESTURE_WEAPON_HAND 2
|
||||
#define USE_HAPTIC_FEEDBACK_DELAY 500
|
||||
|
||||
typedef struct {
|
||||
bool cin_camera; // cinematic camera taken over
|
||||
|
@ -92,6 +93,7 @@ typedef struct {
|
|||
float maxHeight;
|
||||
float curHeight;
|
||||
int useGestureState;
|
||||
int useHapticFeedbackTime[2];
|
||||
|
||||
//////////////////////////////////////
|
||||
// Test stuff for weapon alignment
|
||||
|
|
|
@ -825,7 +825,7 @@ void ClientImpacts( gentity_t *ent, pmove_t *pm ) {
|
|||
const float TOUCH_DISTANCE = 1.0f;
|
||||
const vec3_t TOUCH_RANGE = { 4, 4, 4 };
|
||||
|
||||
void G_TouchTriggersWithHand( gentity_t *ent, vec3_t src, vec3_t vf ) {
|
||||
void G_TouchTriggersWithHand( bool offHand, gentity_t *ent, vec3_t src, vec3_t vf ) {
|
||||
vec3_t dest, mins, maxs;
|
||||
gentity_t *touch[MAX_GENTITIES], *hit;
|
||||
qboolean touched[MAX_GENTITIES];
|
||||
|
@ -867,6 +867,11 @@ void G_TouchTriggersWithHand( gentity_t *ent, vec3_t src, vec3_t vf ) {
|
|||
touched[i] = qtrue;
|
||||
memset( &trace, 0, sizeof(trace) );
|
||||
if ( hit->e_TouchFunc != touchF_NULL ) {
|
||||
int channel = vr->right_handed != offHand ? 1 : 2;
|
||||
if (level.time > vr->useHapticFeedbackTime[channel - 1]) {
|
||||
cgi_HapticEvent("use_button", 0, channel, 60, 0, 0);
|
||||
vr->useHapticFeedbackTime[channel - 1] = level.time + USE_HAPTIC_FEEDBACK_DELAY;
|
||||
}
|
||||
GEntity_TouchFunc(hit, ent, &trace);
|
||||
}
|
||||
}
|
||||
|
@ -1003,13 +1008,13 @@ void G_TouchTriggersLerped( gentity_t *ent ) {
|
|||
vec3_t src, angles, vf;
|
||||
BG_CalculateVRWeaponPosition(src, angles);
|
||||
AngleVectors( angles, vf, NULL, NULL );
|
||||
G_TouchTriggersWithHand( ent, src, vf );
|
||||
G_TouchTriggersWithHand(false, ent, src, vf );
|
||||
}
|
||||
if( ent->client->usercmd.buttons & BUTTON_ALT_USE ) {
|
||||
vec3_t src, angles, vf;
|
||||
BG_CalculateVROffHandPosition(src, angles);
|
||||
AngleVectors( angles, vf, NULL, NULL );
|
||||
G_TouchTriggersWithHand( ent, src, vf );
|
||||
G_TouchTriggersWithHand(true, ent, src, vf );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -234,9 +234,9 @@ void Touch_Multi( gentity_t *self, gentity_t *other, trace_t *trace )
|
|||
|
||||
if ( other->client )
|
||||
{
|
||||
if ( (other->client->ps.clientNum == 0) && (self->spawnflags & 4) )
|
||||
if ( (other->client->ps.clientNum == 0) && (self->spawnflags & 4) && !thirdPersonActive )
|
||||
{
|
||||
// In case of USE_BUTTON, check facing by controller and not by head
|
||||
// In case of USE_BUTTON, check facing by controller and not by head (if not in 3rd person)
|
||||
vec3_t origin, angles;
|
||||
BG_CalculateVRWeaponPosition(origin, angles);
|
||||
AngleVectors( angles, forward, NULL, NULL );
|
||||
|
@ -323,6 +323,13 @@ void Touch_Multi( gentity_t *self, gentity_t *other, trace_t *trace )
|
|||
|
||||
if ( self->spawnflags & 4 )
|
||||
{//USE_BUTTON
|
||||
if (other->client->ps.clientNum == 0 && !useGestureAllowed) {
|
||||
int channel = vr->right_handed ? 1 : 2;
|
||||
if (level.time > vr->useHapticFeedbackTime[channel - 1]) {
|
||||
cgi_HapticEvent("use_button", 0, channel, 60, 0, 0);
|
||||
vr->useHapticFeedbackTime[channel - 1] = level.time + + USE_HAPTIC_FEEDBACK_DELAY;
|
||||
}
|
||||
}
|
||||
NPC_SetAnim( other, SETANIM_TORSO, BOTH_BUTTON_HOLD, SETANIM_FLAG_OVERRIDE|SETANIM_FLAG_HOLD );
|
||||
/*
|
||||
if ( !VectorLengthSquared( other->client->ps.velocity ) && !PM_CrouchAnim( other->client->ps.legsAnim ) )
|
||||
|
|
|
@ -1525,7 +1525,7 @@ Try and use an entity in the world, directly ahead of us
|
|||
#define USE_DISTANCE_BUTTON 64.0f
|
||||
#define USE_DISTANCE_GESTURE 16.0f
|
||||
|
||||
void TryUse_Internal( gentity_t *ent, vec3_t src, vec3_t vf ) {
|
||||
void TryUse_Internal( bool offHand, gentity_t *ent, vec3_t src, vec3_t vf ) {
|
||||
gentity_t *target;
|
||||
trace_t trace;
|
||||
vec3_t dest;
|
||||
|
@ -1565,6 +1565,13 @@ void TryUse_Internal( gentity_t *ent, vec3_t src, vec3_t vf ) {
|
|||
}
|
||||
*/
|
||||
//ent->client->ps.weaponTime = ent->client->ps.torsoAnimTimer;
|
||||
if (ent->client->ps.clientNum == 0) {
|
||||
int channel = vr->right_handed != offHand ? 1 : 2;
|
||||
if (level.time > vr->useHapticFeedbackTime[channel - 1]) {
|
||||
cgi_HapticEvent("use_button", 0, channel, 60, 0, 0);
|
||||
vr->useHapticFeedbackTime[channel - 1] = level.time + + USE_HAPTIC_FEEDBACK_DELAY;
|
||||
}
|
||||
}
|
||||
GEntity_UseFunc( target, ent, ent );
|
||||
return;
|
||||
}
|
||||
|
@ -1575,6 +1582,13 @@ void TryUse_Internal( gentity_t *ent, vec3_t src, vec3_t vf ) {
|
|||
&& (target->client->playerTeam == ent->client->playerTeam || target->client->playerTeam == TEAM_NEUTRAL)
|
||||
&& !(target->NPC->scriptFlags&SCF_NO_RESPONSE) )
|
||||
{
|
||||
if (ent->client->ps.clientNum == 0) {
|
||||
int channel = vr->right_handed != offHand ? 1 : 2;
|
||||
if (level.time > vr->useHapticFeedbackTime[channel - 1]) {
|
||||
cgi_HapticEvent("use_button", 0, channel, 60, 0, 0);
|
||||
vr->useHapticFeedbackTime[channel - 1] = level.time + + USE_HAPTIC_FEEDBACK_DELAY;
|
||||
}
|
||||
}
|
||||
NPC_UseResponse ( target, ent, qfalse );
|
||||
return;
|
||||
}
|
||||
|
@ -1593,15 +1607,16 @@ void TryUse( gentity_t *ent ) {
|
|||
return;
|
||||
}
|
||||
|
||||
bool thirdPersonActive = gi.cvar("cg_thirdPerson", "0", CVAR_TEMP)->integer;
|
||||
vec3_t src, angles, vf;
|
||||
if (ent->client->ps.clientNum == 0) {
|
||||
if (ent->client->ps.clientNum == 0 && !thirdPersonActive) {
|
||||
BG_CalculateVRWeaponPosition(src, angles);
|
||||
AngleVectors( angles, vf, NULL, NULL );
|
||||
TryUse_Internal(ent, src, vf);
|
||||
TryUse_Internal(false, ent, src, vf);
|
||||
} else {
|
||||
VectorCopy(ent->client->renderInfo.eyePoint, src);
|
||||
AngleVectors(ent->client->ps.viewangles, vf, NULL, NULL);
|
||||
TryUse_Internal(ent, src, vf);
|
||||
TryUse_Internal(false, ent, src, vf);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1616,11 +1631,11 @@ void TryAltUse( gentity_t *ent ) {
|
|||
if (ent->client->ps.clientNum == 0) {
|
||||
BG_CalculateVROffHandPosition(src, angles);
|
||||
AngleVectors( angles, vf, NULL, NULL );
|
||||
TryUse_Internal(ent, src, vf);
|
||||
TryUse_Internal(true, ent, src, vf);
|
||||
} else {
|
||||
VectorCopy(ent->client->renderInfo.eyePoint, src);
|
||||
AngleVectors(ent->client->ps.viewangles, vf, NULL, NULL);
|
||||
TryUse_Internal(ent, src, vf);
|
||||
TryUse_Internal(false, ent, src, vf);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue