Update to use gesture (@MuadDib)

This commit is contained in:
Simon 2022-12-14 14:45:51 +00:00
parent efec79df16
commit bd9984c092
7 changed files with 93 additions and 17 deletions

View file

@ -1436,7 +1436,7 @@ void JKVR_Init()
vr_comfort_vignette = Cvar_Get ("vr_comfort_vignette", "0.0", CVAR_ARCHIVE); 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_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 = 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); cvar_t *expanded_menu_enabled = Cvar_Get ("expanded_menu_enabled", "0", CVAR_ARCHIVE);
if (FS_FileExists("expanded_menu.pk3")) { if (FS_FileExists("expanded_menu.pk3")) {

View file

@ -21,5 +21,5 @@ extern cvar_t *vr_haptic_intensity;
extern cvar_t *vr_comfort_vignette; extern cvar_t *vr_comfort_vignette;
extern cvar_t *vr_saber_3rdperson_mode; extern cvar_t *vr_saber_3rdperson_mode;
extern cvar_t *vr_gesture_triggered_use; extern cvar_t *vr_gesture_triggered_use;
extern cvar_t *vr_gesture_triggered_use_threshold; extern cvar_t *vr_use_gesture_boundary;

View file

@ -34,7 +34,7 @@ cvar_t *vr_haptic_intensity;
cvar_t *vr_comfort_vignette; cvar_t *vr_comfort_vignette;
cvar_t *vr_saber_3rdperson_mode; cvar_t *vr_saber_3rdperson_mode;
cvar_t *vr_gesture_triggered_use; cvar_t *vr_gesture_triggered_use;
cvar_t *vr_gesture_triggered_use_threshold; cvar_t *vr_use_gesture_boundary;
ovrInputStateTrackedRemote leftTrackedRemoteState_old; ovrInputStateTrackedRemote leftTrackedRemoteState_old;
ovrInputStateTrackedRemote leftTrackedRemoteState_new; ovrInputStateTrackedRemote leftTrackedRemoteState_new;

View file

@ -153,7 +153,7 @@ void HandleInput_Default( ovrInputStateTrackedRemote *pDominantTrackedRemoteNew,
powf(vr.hmdposition[1] - pOff->Pose.position.y, 2) + powf(vr.hmdposition[1] - pOff->Pose.position.y, 2) +
powf(vr.hmdposition[2] - pOff->Pose.position.z, 2)); powf(vr.hmdposition[2] - pOff->Pose.position.z, 2));
float controllerYawHeading = 0.0f; float controllerYawHeading = 0.0f;
//Turn on weapon stabilisation? //Turn on weapon stabilisation?
bool offhandGripPushed = (pOffTrackedRemoteNew->Buttons & xrButton_GripTrigger); bool offhandGripPushed = (pOffTrackedRemoteNew->Buttons & xrButton_GripTrigger);
@ -835,23 +835,20 @@ void HandleInput_Default( ovrInputStateTrackedRemote *pDominantTrackedRemoteNew,
// Process "use" gesture // Process "use" gesture
if (vr_gesture_triggered_use->integer) { if (vr_gesture_triggered_use->integer) {
float absoluteDistanceToHMD; float distanceToBody;
float verticalDistanceToHMD; bool controllerTracked;
if (vr_gesture_triggered_use->integer == 1) { if (vr_gesture_triggered_use->integer == 1) {
// Gesture with off-hand // Gesture with off-hand
absoluteDistanceToHMD = distanceToHMDOff; distanceToBody = sqrt(vr.offhandoffset[0]*vr.offhandoffset[0] + vr.offhandoffset[2]*vr.offhandoffset[2]);
verticalDistanceToHMD = vr.offhandoffset[1]; controllerTracked = pOffTracking->Status & VRAPI_TRACKING_STATUS_POSITION_TRACKED;
} else { } else {
// Gesture with dominant-hand // Gesture with dominant-hand
absoluteDistanceToHMD = distanceToHMD; distanceToBody = sqrt(vr.weaponoffset[0]*vr.weaponoffset[0] + vr.weaponoffset[2]*vr.weaponoffset[2]);
verticalDistanceToHMD = vr.weaponoffset[1]; controllerTracked = pDominantTracking->Status & VRAPI_TRACKING_STATUS_POSITION_TRACKED;
} }
float threshhold = vr_gesture_triggered_use_threshold->value; float boundary = vr_use_gesture_boundary->value;
// Hand must be extended and at least on waist level bool gestureUseAllowed = !vr.weapon_stabilised && !vr.cin_camera && !vr.misc_camera && !vr.remote_turret;
// Com_Printf("DISTANCE: %.2f ; HEIGHT: %.2f\n", absoluteDistanceToHMD, verticalDistanceToHMD); if (gestureUseAllowed && controllerTracked && distanceToBody > boundary) {
bool gestureUseAllowed = !vr.weapon_stabilised && !vr.cin_camera && !vr.misc_camera &&
!vr.remote_turret;
if (gestureUseAllowed && absoluteDistanceToHMD > threshhold && verticalDistanceToHMD > -threshhold) {
if (!vr.useGestureActive) { if (!vr.useGestureActive) {
vr.useGestureActive = true; vr.useGestureActive = true;
sendButtonAction("+use", true); sendButtonAction("+use", true);
@ -860,6 +857,9 @@ void HandleInput_Default( ovrInputStateTrackedRemote *pDominantTrackedRemoteNew,
vr.useGestureActive = false; vr.useGestureActive = false;
sendButtonAction("+use", false); sendButtonAction("+use", false);
} }
} else if (vr.useGestureActive) {
vr.useGestureActive = false;
sendButtonAction("+use", false);
} }
} }

View file

@ -3,7 +3,7 @@ CONFIG W:\bin\striped.cfg
ID 100 ID 100
REFERENCE MENUS_VR REFERENCE MENUS_VR
DESCRIPTION "VR Menu Localizations" DESCRIPTION "VR Menu Localizations"
COUNT 132 COUNT 134
INDEX 0 INDEX 0
{ {
REFERENCE COMMON_CONTROLS_ITEM REFERENCE COMMON_CONTROLS_ITEM
@ -664,3 +664,13 @@ INDEX 131
REFERENCE GESTURE_TRIGGERED_USE_DOMINANT_HAND REFERENCE GESTURE_TRIGGERED_USE_DOMINANT_HAND
TEXT_LANGUAGE1 "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."
}

View file

@ -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
}
}
//---------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------
// //

View file

@ -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
}
}
//---------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------
// //