Implementation of Quick Crouch/Jump

Use double click of jump button to crouch jump
This commit is contained in:
Simon committed 2020-02-16 23:05:18 +00:00
1 parent 68f0042498
commit d032696011
8 files changed
+134 -11

No files matched your search

+2 -2
View File
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.drbeef.lambda1vr"
android:versionCode="20"
android:versionName="1.4.2" android:installLocation="auto" >
android:versionCode="21"
android:versionName="1.4.3" android:installLocation="auto" >
<!-- Tell the system this app requires OpenGL ES 3.1. -->
<uses-feature android:glEsVersion="0x00030001" android:required="true"/>
@@ -1457,6 +1457,7 @@ void VR_Init()
vr_controller_tracking_haptic = Cvar_Get( "vr_controller_tracking_haptic", "1", CVAR_ARCHIVE, "Set to 0 to disable haptic blip when dominant controller loses tracking" );
vr_highlight_actionables = Cvar_Get( "vr_highlight_actionables", "1", CVAR_ARCHIVE, "Set to 0 to disable highlighting of actionable objects/entities" );
vr_headtorch = Cvar_Get( "vr_headtorch", "0", CVAR_ARCHIVE, "Set to 1 to enable head-torch flashlight mode" );
vr_quick_crouchjump = Cvar_Get( "vr_quick_crouchjump", "1", CVAR_ARCHIVE, "Set to 0 to disable quick crouch-jump mode (double clicking jump button triggers duck)" );
//Not to be changed by users, as it will be overwritten anyway
vr_stereo_side = Cvar_Get( "vr_stereo_side", "0", CVAR_READ_ONLY, "Eye being drawn" );
@@ -23,6 +23,7 @@ convar_t *vr_legacy_ladders;
convar_t *vr_controller_tracking_haptic;
convar_t *vr_highlight_actionables;
convar_t *vr_headtorch;
convar_t *vr_quick_crouchjump;
//Used and updated continuously during rendering
convar_t *vr_stereo_side;
@@ -318,9 +318,46 @@ void HandleInput_Alt( ovrInputStateTrackedRemote *pDominantTrackedRemoteNew, ovr
positional_movementSideways,
positional_movementForward);
//Jump
sendButtonAction("+jump", pDominantTrackedRemoteNew->Buttons & domButton2);
if (vr_quick_crouchjump->value != 0.0) {
//Jump (and crouch if double clicked quick enough)
static bool quickCrouchJumped = false;
static double jumpTimer = 0;
if ((pDominantTrackedRemoteNew->Buttons & domButton2) !=
(pDominantTrackedRemoteOld->Buttons & domButton2)) {
if ((pDominantTrackedRemoteNew->Buttons & domButton2) && jumpTimer == 0) {
//Jump and start timer
sendButtonActionSimple("+jump");
jumpTimer = GetTimeInMilliSeconds();
} else {
//Is jump button released?
if ((pDominantTrackedRemoteNew->Buttons & domButton2) == 0) {
if (quickCrouchJumped) {
ducked = DUCK_NOTDUCKED;
sendButtonActionSimple("-duck");
jumpTimer = 0;
quickCrouchJumped = false;
} else {
sendButtonActionSimple("-jump");
}
}
//Jump button is therefore pushed, was it pushed quick enough to trigger duck?
else if (between(1, (float) (GetTimeInMilliSeconds() - jumpTimer), 300)) {
ducked = DUCK_BUTTON;
sendButtonActionSimple("+duck");
quickCrouchJumped = true;
}
//Nope
else {
//Just jump and reset timer
sendButtonActionSimple("+jump");
jumpTimer = GetTimeInMilliSeconds();
}
}
}
} else {
//Jump
sendButtonAction("+jump", (pDominantTrackedRemoteNew->Buttons & domButton2));
}
//We need to record if we have started firing primary so that releasing trigger will stop firing, if user has pushed grip
//in meantime, then it wouldn't stop the gun firing and it would get stuck
@@ -330,7 +330,46 @@ void HandleInput_Alt2( ovrInputStateTrackedRemote *pDominantTrackedRemoteNew, ov
positional_movementForward);
//Jump
sendButtonAction("+jump", pOffTrackedRemoteNew->Buttons & domButton2);
if (vr_quick_crouchjump->value != 0.0) {
//Jump (and crouch if double clicked quick enough)
static bool quickCrouchJumped = false;
static double jumpTimer = 0;
if ((pOffTrackedRemoteNew->Buttons & offButton2) !=
(pOffTrackedRemoteOld->Buttons & offButton2)) {
if ((pOffTrackedRemoteNew->Buttons & offButton2) && jumpTimer == 0) {
//Jump and start timer
sendButtonActionSimple("+jump");
jumpTimer = GetTimeInMilliSeconds();
} else {
//Is jump button released?
if ((pOffTrackedRemoteNew->Buttons & offButton2) == 0) {
if (quickCrouchJumped) {
ducked = DUCK_NOTDUCKED;
sendButtonActionSimple("-duck");
jumpTimer = 0;
quickCrouchJumped = false;
} else {
sendButtonActionSimple("-jump");
}
}
//Jump button is therefore pushed, was it pushed quick enough to trigger duck?
else if (between(1, (float) (GetTimeInMilliSeconds() - jumpTimer), 300)) {
ducked = DUCK_BUTTON;
sendButtonActionSimple("+duck");
quickCrouchJumped = true;
}
//Nope
else {
//Just jump and reset timer
sendButtonActionSimple("+jump");
jumpTimer = GetTimeInMilliSeconds();
}
}
}
} else {
//Jump
sendButtonAction("+jump", (pDominantTrackedRemoteNew->Buttons & domButton2));
}
//We need to record if we have started firing primary so that releasing trigger will stop firing, if user has pushed grip
//in meantime, then it wouldn't stop the gun firing and it would get stuck
@@ -328,8 +328,47 @@ void HandleInput_Default( ovrInputStateTrackedRemote *pDominantTrackedRemoteNew,
positional_movementSideways,
positional_movementForward);
//Jump
sendButtonAction("+jump", (pDominantTrackedRemoteNew->Buttons & domButton2));
if (vr_quick_crouchjump->value != 0.0) {
//Jump (and crouch if double clicked quick enough)
static bool quickCrouchJumped = false;
static double jumpTimer = 0;
if ((pDominantTrackedRemoteNew->Buttons & domButton2) !=
(pDominantTrackedRemoteOld->Buttons & domButton2)) {
if ((pDominantTrackedRemoteNew->Buttons & domButton2) && jumpTimer == 0) {
//Jump and start timer
sendButtonActionSimple("+jump");
jumpTimer = GetTimeInMilliSeconds();
} else {
//Is jump button released?
if ((pDominantTrackedRemoteNew->Buttons & domButton2) == 0) {
if (quickCrouchJumped) {
ducked = DUCK_NOTDUCKED;
sendButtonActionSimple("-duck");
jumpTimer = 0;
quickCrouchJumped = false;
} else {
sendButtonActionSimple("-jump");
}
}
//Jump button is therefore pushed, was it pushed quick enough to trigger duck?
else if (between(1, (float) (GetTimeInMilliSeconds() - jumpTimer), 300)) {
ducked = DUCK_BUTTON;
sendButtonActionSimple("+duck");
quickCrouchJumped = true;
}
//Nope
else {
//Just jump and reset timer
sendButtonActionSimple("+jump");
jumpTimer = GetTimeInMilliSeconds();
}
}
}
} else {
//Jump
sendButtonAction("+jump", (pDominantTrackedRemoteNew->Buttons & domButton2));
}
//We need to record if we have started firing primary so that releasing trigger will stop firing, if user has pushed grip
@@ -364,8 +403,7 @@ void HandleInput_Default( ovrInputStateTrackedRemote *pDominantTrackedRemoteNew,
}
//Duck
if ((pDominantTrackedRemoteNew->Buttons & domButton1) !=
(pDominantTrackedRemoteOld->Buttons & domButton1) &&
if ((pDominantTrackedRemoteNew->Buttons & domButton1) != (pDominantTrackedRemoteOld->Buttons & domButton1) &&
ducked != DUCK_CROUCHED) {
ducked = (pDominantTrackedRemoteNew->Buttons & domButton1) ? DUCK_BUTTON : DUCK_NOTDUCKED;
sendButtonAction("+duck", (pDominantTrackedRemoteNew->Buttons & domButton1));
@@ -139,7 +139,7 @@ Q_buildcommit will identify this build as release or "notset"
*/
const char *Q_buildcommit( void )
{
return "Lambda1VR-v1.4.2";
return "Lambda1VR-v1.4.3";
}
/*
@@ -66,6 +66,7 @@ private:
CMenuCheckBox hmdWalkDirection;
CMenuCheckBox mirrorWeapons;
CMenuCheckBox headTorch;
CMenuCheckBox quickCrouchJump;
CMenuSlider snapTurnAngle;
CMenuTable controllerList;
@@ -99,6 +100,10 @@ void CMenuControls::_Init( void )
hmdWalkDirection.SetCoord( 320, 450 );
hmdWalkDirection.LinkCvar( "vr_walkdirection" );
quickCrouchJump.SetNameAndStatus( "Quick Crouch-Jump", "Check to enable quick Crouch-Jump (by double clicking jump)" );
quickCrouchJump.SetCoord( 720, 450 );
quickCrouchJump.LinkCvar( "vr_quick_crouchjump" );
mirrorWeapons.SetNameAndStatus( "Mirror Weapon Models", "Check to mirror weapon models (for left-handed play to avoid seeing missing sides)" );
mirrorWeapons.SetCoord( 320, 510 );
mirrorWeapons.LinkCvar( "vr_mirror_weapons" );
@@ -117,6 +122,7 @@ void CMenuControls::_Init( void )
AddItem( controllerList );
AddItem( hmdWalkDirection );
AddItem( quickCrouchJump );
AddItem( mirrorWeapons );
AddItem( headTorch );
AddItem( snapTurnAngle );
@@ -145,6 +151,7 @@ void CMenuControls::SetConfig( )
EngFuncs::CvarSetValue( "vr_control_scheme", mode );
hmdWalkDirection.WriteCvar();
quickCrouchJump.WriteCvar();
mirrorWeapons.WriteCvar();
headTorch.WriteCvar();
snapTurnAngle.WriteCvar();