mirror of
https://github.com/DrBeef/JKXR.git
synced 2024-11-24 21:11:03 +00:00
Update to use gesture (@MuadDib)
This commit is contained in:
parent
257382adcd
commit
2cc54bc8bd
7 changed files with 93 additions and 17 deletions
|
@ -1353,7 +1353,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")) {
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -41,7 +41,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;
|
||||
|
|
|
@ -160,7 +160,7 @@ void HandleInput_Default( ovrInputStateGamepad *pFootTrackingNew, ovrInputStateG
|
|||
powf(vr.hmdposition[1] - pOff->HeadPose.Pose.Position.y, 2) +
|
||||
powf(vr.hmdposition[2] - pOff->HeadPose.Pose.Position.z, 2));
|
||||
|
||||
|
||||
|
||||
float controllerYawHeading = 0.0f;
|
||||
//Turn on weapon stabilisation?
|
||||
bool offhandGripPushed = (pOffTrackedRemoteNew->Buttons & ovrButton_GripTrigger);
|
||||
|
@ -843,23 +843,20 @@ void HandleInput_Default( ovrInputStateGamepad *pFootTrackingNew, ovrInputStateG
|
|||
|
||||
// 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);
|
||||
|
@ -868,6 +865,9 @@ void HandleInput_Default( ovrInputStateGamepad *pFootTrackingNew, ovrInputStateG
|
|||
vr.useGestureActive = false;
|
||||
sendButtonAction("+use", false);
|
||||
}
|
||||
} else if (vr.useGestureActive) {
|
||||
vr.useGestureActive = false;
|
||||
sendButtonAction("+use", false);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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."
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------------------------
|
||||
//
|
||||
|
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------------------------
|
||||
//
|
||||
|
|
Loading…
Reference in a new issue