From d032696011ffd04f727de180e49b7f04446a41f3 Mon Sep 17 00:00:00 2001 From: Simon Date: Sun, 16 Feb 2020 23:05:18 +0000 Subject: [PATCH] Implementation of Quick Crouch/Jump Use double click of jump button to crouch jump --- Projects/Android/AndroidManifest.xml | 4 +- .../jni/src/Lambda1VR/L1VR_SurfaceView.c | 1 + Projects/Android/jni/src/Lambda1VR/VrCvars.h | 1 + .../Android/jni/src/Lambda1VR/VrInputAlt.c | 43 +++++++++++++++-- .../Android/jni/src/Lambda1VR/VrInputAlt2.c | 41 ++++++++++++++++- .../jni/src/Lambda1VR/VrInputDefault.c | 46 +++++++++++++++++-- .../src/Xash3D/xash3d/engine/common/build.c | 2 +- .../Xash3D/xash3d/mainui/menus/Controls.cpp | 7 +++ 8 files changed, 134 insertions(+), 11 deletions(-) diff --git a/Projects/Android/AndroidManifest.xml b/Projects/Android/AndroidManifest.xml index 3f981c8..11f7e01 100644 --- a/Projects/Android/AndroidManifest.xml +++ b/Projects/Android/AndroidManifest.xml @@ -1,8 +1,8 @@ + android:versionCode="21" + android:versionName="1.4.3" android:installLocation="auto" > diff --git a/Projects/Android/jni/src/Lambda1VR/L1VR_SurfaceView.c b/Projects/Android/jni/src/Lambda1VR/L1VR_SurfaceView.c index 20a3191..7651bc0 100644 --- a/Projects/Android/jni/src/Lambda1VR/L1VR_SurfaceView.c +++ b/Projects/Android/jni/src/Lambda1VR/L1VR_SurfaceView.c @@ -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" ); diff --git a/Projects/Android/jni/src/Lambda1VR/VrCvars.h b/Projects/Android/jni/src/Lambda1VR/VrCvars.h index 1123060..303c437 100644 --- a/Projects/Android/jni/src/Lambda1VR/VrCvars.h +++ b/Projects/Android/jni/src/Lambda1VR/VrCvars.h @@ -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; \ No newline at end of file diff --git a/Projects/Android/jni/src/Lambda1VR/VrInputAlt.c b/Projects/Android/jni/src/Lambda1VR/VrInputAlt.c index b293da9..c3d904e 100644 --- a/Projects/Android/jni/src/Lambda1VR/VrInputAlt.c +++ b/Projects/Android/jni/src/Lambda1VR/VrInputAlt.c @@ -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 diff --git a/Projects/Android/jni/src/Lambda1VR/VrInputAlt2.c b/Projects/Android/jni/src/Lambda1VR/VrInputAlt2.c index 2a4a0b1..a4cbe3f 100644 --- a/Projects/Android/jni/src/Lambda1VR/VrInputAlt2.c +++ b/Projects/Android/jni/src/Lambda1VR/VrInputAlt2.c @@ -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 diff --git a/Projects/Android/jni/src/Lambda1VR/VrInputDefault.c b/Projects/Android/jni/src/Lambda1VR/VrInputDefault.c index a72bfaf..65c8e7c 100644 --- a/Projects/Android/jni/src/Lambda1VR/VrInputDefault.c +++ b/Projects/Android/jni/src/Lambda1VR/VrInputDefault.c @@ -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)); diff --git a/Projects/Android/jni/src/Xash3D/xash3d/engine/common/build.c b/Projects/Android/jni/src/Xash3D/xash3d/engine/common/build.c index 1013adc..6387ec3 100644 --- a/Projects/Android/jni/src/Xash3D/xash3d/engine/common/build.c +++ b/Projects/Android/jni/src/Xash3D/xash3d/engine/common/build.c @@ -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"; } /* diff --git a/Projects/Android/jni/src/Xash3D/xash3d/mainui/menus/Controls.cpp b/Projects/Android/jni/src/Xash3D/xash3d/mainui/menus/Controls.cpp index 05e9325..c3705e8 100644 --- a/Projects/Android/jni/src/Xash3D/xash3d/mainui/menus/Controls.cpp +++ b/Projects/Android/jni/src/Xash3D/xash3d/mainui/menus/Controls.cpp @@ -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();