diff --git a/Projects/Android/jni/JKVR/JKVR_SurfaceView.cpp b/Projects/Android/jni/JKVR/JKVR_SurfaceView.cpp index 7df84e2..b8bdda2 100644 --- a/Projects/Android/jni/JKVR/JKVR_SurfaceView.cpp +++ b/Projects/Android/jni/JKVR/JKVR_SurfaceView.cpp @@ -1436,7 +1436,7 @@ void JKVR_Init() vr_comfort_vignette = Cvar_Get ("vr_comfort_vignette", "0.0", CVAR_ARCHIVE); vr_saber_3rdperson_mode = Cvar_Get ("vr_saber_3rdperson_mode", "1", CVAR_ARCHIVE); vr_gesture_triggered_use = Cvar_Get ("vr_gesture_triggered_use", "0", CVAR_ARCHIVE); - vr_gesture_triggered_use_threshold = Cvar_Get ("vr_gesture_triggered_use_threshold", "0.5", CVAR_ARCHIVE); + vr_use_gesture_boundary = Cvar_Get ("vr_use_gesture_boundary", "0.35", CVAR_ARCHIVE); cvar_t *expanded_menu_enabled = Cvar_Get ("expanded_menu_enabled", "0", CVAR_ARCHIVE); if (FS_FileExists("expanded_menu.pk3")) { diff --git a/Projects/Android/jni/JKVR/VrCvars.h b/Projects/Android/jni/JKVR/VrCvars.h index 3b37e48..5b5c0a0 100644 --- a/Projects/Android/jni/JKVR/VrCvars.h +++ b/Projects/Android/jni/JKVR/VrCvars.h @@ -21,5 +21,5 @@ extern cvar_t *vr_haptic_intensity; extern cvar_t *vr_comfort_vignette; extern cvar_t *vr_saber_3rdperson_mode; extern cvar_t *vr_gesture_triggered_use; -extern cvar_t *vr_gesture_triggered_use_threshold; +extern cvar_t *vr_use_gesture_boundary; diff --git a/Projects/Android/jni/JKVR/VrInputCommon.cpp b/Projects/Android/jni/JKVR/VrInputCommon.cpp index 1419633..8f59aa6 100644 --- a/Projects/Android/jni/JKVR/VrInputCommon.cpp +++ b/Projects/Android/jni/JKVR/VrInputCommon.cpp @@ -34,7 +34,7 @@ cvar_t *vr_haptic_intensity; cvar_t *vr_comfort_vignette; cvar_t *vr_saber_3rdperson_mode; cvar_t *vr_gesture_triggered_use; -cvar_t *vr_gesture_triggered_use_threshold; +cvar_t *vr_use_gesture_boundary; ovrInputStateTrackedRemote leftTrackedRemoteState_old; ovrInputStateTrackedRemote leftTrackedRemoteState_new; diff --git a/Projects/Android/jni/JKVR/VrInputDefault.cpp b/Projects/Android/jni/JKVR/VrInputDefault.cpp index 89ca6d2..626f960 100644 --- a/Projects/Android/jni/JKVR/VrInputDefault.cpp +++ b/Projects/Android/jni/JKVR/VrInputDefault.cpp @@ -153,7 +153,7 @@ void HandleInput_Default( ovrInputStateTrackedRemote *pDominantTrackedRemoteNew, powf(vr.hmdposition[1] - pOff->Pose.position.y, 2) + powf(vr.hmdposition[2] - pOff->Pose.position.z, 2)); - + float controllerYawHeading = 0.0f; //Turn on weapon stabilisation? bool offhandGripPushed = (pOffTrackedRemoteNew->Buttons & xrButton_GripTrigger); @@ -835,23 +835,20 @@ void HandleInput_Default( ovrInputStateTrackedRemote *pDominantTrackedRemoteNew, // Process "use" gesture if (vr_gesture_triggered_use->integer) { - float absoluteDistanceToHMD; - float verticalDistanceToHMD; + float distanceToBody; + bool controllerTracked; if (vr_gesture_triggered_use->integer == 1) { // Gesture with off-hand - absoluteDistanceToHMD = distanceToHMDOff; - verticalDistanceToHMD = vr.offhandoffset[1]; + distanceToBody = sqrt(vr.offhandoffset[0]*vr.offhandoffset[0] + vr.offhandoffset[2]*vr.offhandoffset[2]); + controllerTracked = pOffTracking->Status & VRAPI_TRACKING_STATUS_POSITION_TRACKED; } else { // Gesture with dominant-hand - absoluteDistanceToHMD = distanceToHMD; - verticalDistanceToHMD = vr.weaponoffset[1]; + distanceToBody = sqrt(vr.weaponoffset[0]*vr.weaponoffset[0] + vr.weaponoffset[2]*vr.weaponoffset[2]); + controllerTracked = pDominantTracking->Status & VRAPI_TRACKING_STATUS_POSITION_TRACKED; } - float threshhold = vr_gesture_triggered_use_threshold->value; - // Hand must be extended and at least on waist level - // Com_Printf("DISTANCE: %.2f ; HEIGHT: %.2f\n", absoluteDistanceToHMD, verticalDistanceToHMD); - bool gestureUseAllowed = !vr.weapon_stabilised && !vr.cin_camera && !vr.misc_camera && - !vr.remote_turret; - if (gestureUseAllowed && absoluteDistanceToHMD > threshhold && verticalDistanceToHMD > -threshhold) { + float boundary = vr_use_gesture_boundary->value; + bool gestureUseAllowed = !vr.weapon_stabilised && !vr.cin_camera && !vr.misc_camera && !vr.remote_turret; + if (gestureUseAllowed && controllerTracked && distanceToBody > boundary) { if (!vr.useGestureActive) { vr.useGestureActive = true; sendButtonAction("+use", true); @@ -860,6 +857,9 @@ void HandleInput_Default( ovrInputStateTrackedRemote *pDominantTrackedRemoteNew, vr.useGestureActive = false; sendButtonAction("+use", false); } + } else if (vr.useGestureActive) { + vr.useGestureActive = false; + sendButtonAction("+use", false); } } diff --git a/z_vr_assets/strip/menus_vr.sp b/z_vr_assets/strip/menus_vr.sp index b0e8d19..5199133 100644 --- a/z_vr_assets/strip/menus_vr.sp +++ b/z_vr_assets/strip/menus_vr.sp @@ -3,7 +3,7 @@ CONFIG W:\bin\striped.cfg ID 100 REFERENCE MENUS_VR DESCRIPTION "VR Menu Localizations" -COUNT 132 +COUNT 134 INDEX 0 { REFERENCE COMMON_CONTROLS_ITEM @@ -664,3 +664,13 @@ INDEX 131 REFERENCE GESTURE_TRIGGERED_USE_DOMINANT_HAND TEXT_LANGUAGE1 "Dominant-Hand" } +INDEX 132 +{ + REFERENCE USE_GESTURE_BOUNDARY_ITEM + TEXT_LANGUAGE1 "Use Gesture Boundary:" +} +INDEX 133 +{ + REFERENCE USE_GESTURE_BOUNDARY_DESC + TEXT_LANGUAGE1 "Configures how far you need to reach to activate use gesture." +} diff --git a/z_vr_assets/ui/controls.menu b/z_vr_assets/ui/controls.menu index b13e5ae..89a9dfb 100644 --- a/z_vr_assets/ui/controls.menu +++ b/z_vr_assets/ui/controls.menu @@ -1403,6 +1403,39 @@ } } + itemDef + { + name none + group commoncontrols + type ITEM_TYPE_SLIDER + text @MENUS_VR_USE_GESTURE_BOUNDARY_ITEM + cvarfloat "vr_use_gesture_boundary" 0 0.20 0.50 + rect 305 351 300 20 + textalign ITEM_ALIGN_RIGHT + textalignx 151 + textaligny -2 + font 2 + textscale 0.8 + forecolor 1 1 1 1 + visible 0 + // appearance_slot 3 + descText @MENUS_VR_USE_GESTURE_BOUNDARY_DESC + action + { + play sound/interface/button1 + } + + mouseenter + { + show highlight10 + } + mouseexit + { + hide highlight10 + } + } + + //---------------------------------------------------------------------------------------------- // diff --git a/z_vr_assets/ui/ingamecontrols.menu b/z_vr_assets/ui/ingamecontrols.menu index 2cd3758..6269b3e 100644 --- a/z_vr_assets/ui/ingamecontrols.menu +++ b/z_vr_assets/ui/ingamecontrols.menu @@ -1402,6 +1402,39 @@ } } + itemDef + { + name none + group commoncontrols + type ITEM_TYPE_SLIDER + text @MENUS_VR_USE_GESTURE_BOUNDARY_ITEM + cvarfloat "vr_use_gesture_boundary" 0 0.20 0.50 + rect 305 351 300 20 + textalign ITEM_ALIGN_RIGHT + textalignx 151 + textaligny -2 + font 2 + textscale 0.8 + forecolor 1 1 1 1 + visible 0 + // appearance_slot 3 + descText @MENUS_VR_USE_GESTURE_BOUNDARY_DESC + action + { + play sound/interface/button1 + } + + mouseenter + { + show highlight10 + } + mouseexit + { + hide highlight10 + } + } + + //---------------------------------------------------------------------------------------------- //