mirror of
https://github.com/DrBeef/JKXR.git
synced 2024-11-23 20:43:09 +00:00
Update to use gesture (@MuadDib)
This commit is contained in:
parent
efec79df16
commit
bd9984c092
7 changed files with 93 additions and 17 deletions
|
@ -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")) {
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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