Gesture based button / item triggering

This commit is contained in:
Simon 2022-11-26 15:38:17 +00:00
parent 008e0ff44a
commit f2c9a603b8
11 changed files with 143 additions and 3 deletions

View file

@ -1351,6 +1351,8 @@ void JKVR_Init()
vr_haptic_intensity = Cvar_Get ("vr_haptic_intensity", "1.0", CVAR_ARCHIVE); vr_haptic_intensity = Cvar_Get ("vr_haptic_intensity", "1.0", CVAR_ARCHIVE);
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_threshold = Cvar_Get ("vr_gesture_triggered_use_threshold", "0.5", 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

@ -72,6 +72,7 @@ typedef struct {
float maxHeight; float maxHeight;
float curHeight; float curHeight;
bool useGestureActive;
////////////////////////////////////// //////////////////////////////////////
// Test stuff for weapon alignment // Test stuff for weapon alignment

View file

@ -19,4 +19,6 @@ extern cvar_t *vr_saber_block_debounce_time;
extern cvar_t *vr_haptic_intensity; 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_threshold;

View file

@ -39,6 +39,8 @@ cvar_t *vr_saber_block_debounce_time;
cvar_t *vr_haptic_intensity; 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_threshold;
ovrInputStateTrackedRemote leftTrackedRemoteState_old; ovrInputStateTrackedRemote leftTrackedRemoteState_old;
ovrInputStateTrackedRemote leftTrackedRemoteState_new; ovrInputStateTrackedRemote leftTrackedRemoteState_new;

View file

@ -837,6 +837,33 @@ void HandleInput_Default( ovrInputStateGamepad *pFootTrackingNew, ovrInputStateG
} }
} }
} }
// Process "use" gesture
if (vr_gesture_triggered_use->integer) {
float absoluteDistanceToHMD;
float verticalDistanceToHMD;
if (vr_gesture_triggered_use->integer == 1) {
// Gesture with off-hand
absoluteDistanceToHMD = distanceToHMDOff;
verticalDistanceToHMD = vr.offhandoffset[1];
} else {
// Gesture with dominant-hand
absoluteDistanceToHMD = distanceToHMD;
verticalDistanceToHMD = vr.weaponoffset[1];
}
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);
if (!vr.weapon_stabilised && absoluteDistanceToHMD > threshhold && verticalDistanceToHMD > -threshhold) {
if (!vr.useGestureActive) {
vr.useGestureActive = true;
sendButtonAction("+use", true);
}
} else if (vr.useGestureActive) {
vr.useGestureActive = false;
sendButtonAction("+use", false);
}
}
} }

View file

@ -26,6 +26,7 @@ along with this program; if not, see <http://www.gnu.org/licenses/>.
#include "b_local.h" #include "b_local.h"
#include "anims.h" #include "anims.h"
#include "bg_local.h" #include "bg_local.h"
#include <JKVR/VrClientInfo.h>
#define ENTDIST_PLAYER 1 #define ENTDIST_PLAYER 1
#define ENTDIST_NPC 2 #define ENTDIST_NPC 2
@ -232,7 +233,11 @@ void Touch_Multi( gentity_t *self, gentity_t *other, trace_t *trace )
if (other->client->ps.clientNum == 0) if (other->client->ps.clientNum == 0)
{ {
vec3_t origin, angles; vec3_t origin, angles;
if (vr->useGestureActive && gi.cvar("vr_gesture_triggered_use", "0", CVAR_ARCHIVE)->integer == 1) { // defined in VrCvars.h
BG_CalculateVROffHandPosition(origin, angles);
} else {
BG_CalculateVRWeaponPosition(origin, angles); BG_CalculateVRWeaponPosition(origin, angles);
}
AngleVectors( angles, forward, NULL, NULL ); AngleVectors( angles, forward, NULL, NULL );
} }
else else

View file

@ -32,6 +32,7 @@ along with this program; if not, see <http://www.gnu.org/licenses/>.
#include "b_local.h" #include "b_local.h"
#include "anims.h" #include "anims.h"
#include "../../code/rd-common/mdx_format.h" #include "../../code/rd-common/mdx_format.h"
#include <JKVR/VrClientInfo.h>
#define ACT_ACTIVE qtrue #define ACT_ACTIVE qtrue
#define ACT_INACTIVE qfalse #define ACT_INACTIVE qfalse
@ -1283,7 +1284,11 @@ void TryUse( gentity_t *ent ) {
//cg.refdef.vieworg, basically //cg.refdef.vieworg, basically
if (ent->client->ps.clientNum == 0) { if (ent->client->ps.clientNum == 0) {
vec3_t angles; vec3_t angles;
if (vr->useGestureActive && gi.cvar("vr_gesture_triggered_use", "0", CVAR_ARCHIVE)->integer == 1) { // defined in VrCvars.h
BG_CalculateVROffHandPosition(src, angles);
} else {
BG_CalculateVRWeaponPosition(src, angles); BG_CalculateVRWeaponPosition(src, angles);
}
AngleVectors(angles, vf, NULL, NULL); AngleVectors(angles, vf, NULL, NULL);
} else { } else {
VectorCopy(ent->client->renderInfo.eyePoint, src); VectorCopy(ent->client->renderInfo.eyePoint, src);

Binary file not shown.

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 128 COUNT 132
INDEX 0 INDEX 0
{ {
REFERENCE COMMON_CONTROLS_ITEM REFERENCE COMMON_CONTROLS_ITEM
@ -644,3 +644,23 @@ INDEX 127
REFERENCE SABER_3RD_PERSON_AUTO REFERENCE SABER_3RD_PERSON_AUTO
TEXT_LANGUAGE1 "Auto" TEXT_LANGUAGE1 "Auto"
} }
INDEX 128
{
REFERENCE GESTURE_TRIGGERED_USE_ITEM
TEXT_LANGUAGE1 "Gesture Triggered Use:"
}
INDEX 129
{
REFERENCE GESTURE_TRIGGERED_USE_DESC
TEXT_LANGUAGE1 "Toggles triggering of use/action by gesture."
}
INDEX 130
{
REFERENCE GESTURE_TRIGGERED_USE_OFF_HAND
TEXT_LANGUAGE1 "Off-Hand"
}
INDEX 131
{
REFERENCE GESTURE_TRIGGERED_USE_DOMINANT_HAND
TEXT_LANGUAGE1 "Dominant-Hand"
}

View file

@ -1398,6 +1398,44 @@
} }
} }
itemDef
{
name none
group commoncontrols
type ITEM_TYPE_MULTI
text @MENUS_VR_GESTURE_TRIGGERED_USE_ITEM
cvar "vr_gesture_triggered_use"
cvarFloatList
{
@MENUS0_NO 0
@MENUS_VR_GESTURE_TRIGGERED_USE_OFF_HAND 1
@MENUS_VR_GESTURE_TRIGGERED_USE_DOMINANT_HAND 2
}
rect 305 331 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_GESTURE_TRIGGERED_USE_DESC
action
{
play sound/interface/button1
}
mouseenter
{
show highlight9
}
mouseexit
{
hide highlight9
}
}
//---------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------
// //

View file

@ -1397,6 +1397,44 @@
} }
} }
itemDef
{
name none
group commoncontrols
type ITEM_TYPE_MULTI
text @MENUS_VR_GESTURE_TRIGGERED_USE_ITEM
cvar "vr_gesture_triggered_use"
cvarFloatList
{
@MENUS0_NO 0
@MENUS_VR_GESTURE_TRIGGERED_USE_OFF_HAND 1
@MENUS_VR_GESTURE_TRIGGERED_USE_DOMINANT_HAND 2
}
rect 305 331 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_GESTURE_TRIGGERED_USE_DESC
action
{
play sound/interface/button1
}
mouseenter
{
show highlight9
}
mouseexit
{
hide highlight9
}
}
//---------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------
// //