From ce6d680ba9de2ed327ba5f5a715540385264f0a8 Mon Sep 17 00:00:00 2001 From: Petr Bartos Date: Sun, 8 Oct 2023 19:16:22 +0200 Subject: [PATCH] Updated controls: - HUD toggle moved to menu - Removed right grip shortcuts (they were interfering with selector) - X/Y for selecting items replaced by selector - Trigger to toggle scope/silencer/akimbo moved to X (instead of HUD toggle) --- .../Android/jni/RTCWVR/RTCWVR_SurfaceView.c | 1 + Projects/Android/jni/RTCWVR/VrCvars.h | 2 +- Projects/Android/jni/RTCWVR/VrInputDefault.c | 129 +++++------------- Projects/Android/z_vr_assets/ui/controls.menu | 17 +++ .../z_vr_assets/ui/ingame_controls.menu | 17 +++ 5 files changed, 72 insertions(+), 94 deletions(-) diff --git a/Projects/Android/jni/RTCWVR/RTCWVR_SurfaceView.c b/Projects/Android/jni/RTCWVR/RTCWVR_SurfaceView.c index c4dc2d8..f30cda5 100644 --- a/Projects/Android/jni/RTCWVR/RTCWVR_SurfaceView.c +++ b/Projects/Android/jni/RTCWVR/RTCWVR_SurfaceView.c @@ -1503,6 +1503,7 @@ void RTCWVR_Init() vr_comfort_vignette = Cvar_Get ("vr_comfort_vignette", "0.0", CVAR_ARCHIVE); vr_gesture_triggered_use = Cvar_Get ("vr_gesture_triggered_use", "1", CVAR_ARCHIVE); vr_use_gesture_boundary = Cvar_Get ("vr_use_gesture_boundary", "0.35", CVAR_ARCHIVE); + vr_draw_hud = Cvar_Get ("vr_draw_hud", "1", CVAR_ARCHIVE); //Defaults vr_control_scheme = Cvar_Get( "vr_control_scheme", "0", CVAR_ARCHIVE); diff --git a/Projects/Android/jni/RTCWVR/VrCvars.h b/Projects/Android/jni/RTCWVR/VrCvars.h index 106e1d2..931f02a 100644 --- a/Projects/Android/jni/RTCWVR/VrCvars.h +++ b/Projects/Android/jni/RTCWVR/VrCvars.h @@ -15,4 +15,4 @@ cvar_t *vr_cinematic_stereo; cvar_t *vr_screen_dist; cvar_t *vr_gesture_triggered_use; cvar_t *vr_use_gesture_boundary; - +cvar_t *vr_draw_hud; diff --git a/Projects/Android/jni/RTCWVR/VrInputDefault.c b/Projects/Android/jni/RTCWVR/VrInputDefault.c index a4c9c31..7559d3e 100644 --- a/Projects/Android/jni/RTCWVR/VrInputDefault.c +++ b/Projects/Android/jni/RTCWVR/VrInputDefault.c @@ -43,6 +43,7 @@ void HandleInput_Default( ovrInputStateGamepad *pFootTrackingNew, ovrInputStateG vr_control_scheme->value == 99; // Always right-handed for weapon calibration vr.teleportenabled = vr_teleport->integer != 0; + vr.visible_hud = vr_draw_hud->integer; static qboolean dominantGripPushed = false; static float dominantGripPushTime = 0.0f; @@ -553,92 +554,37 @@ void HandleInput_Default( ovrInputStateGamepad *pFootTrackingNew, ovrInputStateG - //We need to record if we have started firing primary so that releasing trigger will stop firing, if user has pushed grip - //in meantime, then it wouldn't stop the gun firing and it would get stuck - static qboolean firing = false; - if (dominantGripPushed && vr.backpackitemactive == 0) - { - if ((pDominantTrackedRemoteNew->Buttons & ovrButton_Trigger) != - (pDominantTrackedRemoteOld->Buttons & ovrButton_Trigger)) - { - if (!vr.scopedweapon) { - if (pDominantTrackedRemoteNew->Buttons & ovrButton_Trigger) { - ALOGV("**WEAPON EVENT** weapalt"); - sendButtonActionSimple("weapalt"); - } - else if (firing) - { - //no longer firing - vr.akimboTriggerState = 0; - firing = qfalse; - ALOGV("**WEAPON EVENT** Grip Pushed %sattack", (pDominantTrackedRemoteNew->Buttons & ovrButton_Trigger) ? "+" : "-"); - sendButtonAction("+attack", firing); - } - } - else if (vr.detachablescope) - { - if (pDominantTrackedRemoteNew->Buttons & ovrButton_Trigger) { - //See if we are able to detach the scope - ALOGV("**WEAPON EVENT** weapdetachscope"); - sendButtonActionSimple("weapdetachscope"); - } - } - else - { - //Just ignore grip and fire - ALOGV("**WEAPON EVENT** Grip Pushed %sattack", (pDominantTrackedRemoteNew->Buttons & ovrButton_Trigger) ? "+" : "-"); - firing = (pDominantTrackedRemoteNew->Buttons & ovrButton_Trigger); - if (vr.weaponid == WP_AKIMBO) { - if (firing) { - vr.akimboTriggerState |= ACTIVE_WEAPON_HAND; - sendButtonAction("+attack", firing); - } else { - vr.akimboTriggerState &= ~ACTIVE_WEAPON_HAND; - if (!vr.akimboTriggerState) { // Stop firing only if we are not firing with off-hand weapon - sendButtonAction("+attack", firing); - } - } - } else { - vr.akimboTriggerState = 0; + //Fire Primary + if (vr.backpackitemactive != 3 && !vr.binocularsActive && // Can't fire while holding binoculars + !vr.velocitytriggered && // Don't fire velocity triggered weapons + (pDominantTrackedRemoteNew->Buttons & ovrButton_Trigger) != + (pDominantTrackedRemoteOld->Buttons & ovrButton_Trigger)) { + + ALOGV("**WEAPON EVENT** Not Grip Pushed %sattack", (pDominantTrackedRemoteNew->Buttons & ovrButton_Trigger) ? "+" : "-"); + qboolean firing = (pDominantTrackedRemoteNew->Buttons & ovrButton_Trigger); + if (vr.weaponid == WP_AKIMBO) { + if (firing) { + vr.akimboTriggerState |= ACTIVE_WEAPON_HAND; + sendButtonAction("+attack", firing); + } else { + vr.akimboTriggerState &= ~ACTIVE_WEAPON_HAND; + if (!vr.akimboTriggerState) { // Stop firing only if we are not still firing with off-hand weapon sendButtonAction("+attack", firing); } } + } else { + vr.akimboTriggerState = 0; + sendButtonAction("+attack", firing); } } - else + else if (binocularsactive) // trigger can zoom-in binoculars, remove from face to reset { - //Fire Primary - if (vr.backpackitemactive != 3 && !vr.binocularsActive && // Can't fire while holding binoculars - !vr.velocitytriggered && // Don't fire velocity triggered weapons - (pDominantTrackedRemoteNew->Buttons & ovrButton_Trigger) != - (pDominantTrackedRemoteOld->Buttons & ovrButton_Trigger)) { - - ALOGV("**WEAPON EVENT** Not Grip Pushed %sattack", (pDominantTrackedRemoteNew->Buttons & ovrButton_Trigger) ? "+" : "-"); - firing = (pDominantTrackedRemoteNew->Buttons & ovrButton_Trigger); - if (vr.weaponid == WP_AKIMBO) { - if (firing) { - vr.akimboTriggerState |= ACTIVE_WEAPON_HAND; - sendButtonAction("+attack", firing); - } else { - vr.akimboTriggerState &= ~ACTIVE_WEAPON_HAND; - if (!vr.akimboTriggerState) { // Stop firing only if we are not still firing with off-hand weapon - sendButtonAction("+attack", firing); - } - } - } else { - vr.akimboTriggerState = 0; - sendButtonAction("+attack", firing); - } - } - else if (binocularsactive) // trigger can zoom-in binoculars, remove from face to reset + static qboolean zoomin = true; + if (pDominantTrackedRemoteNew->Buttons & ovrButton_Trigger) { + sendButtonActionSimple(zoomin ? "weapnext" : "weapprev"); + } else if (pDominantTrackedRemoteOld->Buttons & ovrButton_Trigger) { - static qboolean zoomin = true; - if (pDominantTrackedRemoteNew->Buttons & ovrButton_Trigger) { - sendButtonActionSimple(zoomin ? "weapnext" : "weapprev"); - } else if (pDominantTrackedRemoteOld->Buttons & ovrButton_Trigger) - { - zoomin = !zoomin; - } + zoomin = !zoomin; } } @@ -722,31 +668,28 @@ void HandleInput_Default( ovrInputStateGamepad *pFootTrackingNew, ovrInputStateG stopUseItemNextFrame = false; } + // Detach scopes, draw akimbo if (!canUseQuickSave) { if (((secondaryButtonsNew & secondaryButton1) != (secondaryButtonsOld & secondaryButton1)) && (secondaryButtonsNew & secondaryButton1)) { - - if (dominantGripPushed) { - Cbuf_AddText("+useitem\n"); - stopUseItemNextFrame = qtrue; - } else { - vr.visible_hud = !vr.visible_hud; + if (!vr.scopedweapon) { + ALOGV("**WEAPON EVENT** weapalt"); + sendButtonActionSimple("weapalt"); + } else if (vr.detachablescope) { + //See if we are able to detach the scope + ALOGV("**WEAPON EVENT** weapdetachscope"); + sendButtonActionSimple("weapdetachscope"); } } } - //notebook or select "item" + // Notebook if (!canUseQuickSave) { if (((secondaryButtonsNew & secondaryButton2) != (secondaryButtonsOld & secondaryButton2)) && (secondaryButtonsNew & secondaryButton2)) { - - if (dominantGripPushed) { - sendButtonActionSimple("itemprev"); - } else { - sendButtonActionSimple("notebook"); - } + sendButtonActionSimple("notebook"); } } @@ -759,7 +702,7 @@ void HandleInput_Default( ovrInputStateGamepad *pFootTrackingNew, ovrInputStateG //We need to record if we have started firing primary so that releasing trigger will stop definitely firing, if user has pushed grip //in meantime, then it wouldn't stop the gun firing and it would get stuck - if (!vr.teleportenabled) + if (!vr.teleportenabled || vr.weaponid == WP_AKIMBO) { if (vr.weaponid == WP_AKIMBO && vr.backpackitemactive != 3 && !vr.binocularsActive) { // Fire off-hand weapon diff --git a/Projects/Android/z_vr_assets/ui/controls.menu b/Projects/Android/z_vr_assets/ui/controls.menu index ca4e9f5..7d00bca 100644 --- a/Projects/Android/z_vr_assets/ui/controls.menu +++ b/Projects/Android/z_vr_assets/ui/controls.menu @@ -396,6 +396,23 @@ itemDef visible 1 } + itemDef { + name vr + group grpControls + type ITEM_TYPE_YESNO + text "Draw HUD: " + cvar "vr_draw_hud" + rect 82 270 290 12 + textalign ITEM_ALIGN_RIGHT + textalignx 142 + textaligny 10 + textscale .23 + style WINDOW_STYLE_FILLED + backcolor 1 1 1 .07 + forecolor 1 1 1 1 + visible 1 + } + // TOOLS MESSAGE // itemDef diff --git a/Projects/Android/z_vr_assets/ui/ingame_controls.menu b/Projects/Android/z_vr_assets/ui/ingame_controls.menu index 959be8b..2b06b07 100644 --- a/Projects/Android/z_vr_assets/ui/ingame_controls.menu +++ b/Projects/Android/z_vr_assets/ui/ingame_controls.menu @@ -369,6 +369,23 @@ itemDef visible 1 } + itemDef { + name ingame_vr + group grpControls + type ITEM_TYPE_YESNO + text "Draw HUD: " + cvar "vr_draw_hud" + rect 82 270 290 12 + textalign ITEM_ALIGN_RIGHT + textalignx 142 + textaligny 10 + textscale .23 + style WINDOW_STYLE_FILLED + backcolor 1 1 1 .07 + forecolor 1 1 1 1 + visible 1 + } + itemDef { name yesno_message