Add support for setting control schema in team arena

This commit is contained in:
Petr Bartos 2022-03-29 22:46:31 +02:00
parent 90fa0bcf42
commit 24ce45a3c5
4 changed files with 163 additions and 28 deletions

View file

@ -3161,6 +3161,75 @@ static void UI_Update(const char *name) {
} else {
trap_Cvar_SetValue( "m_pitch", -0.022f );
}
} else if (Q_stricmp(name, "vr_controlSchema") == 0) {
qboolean uturn = trap_Cvar_VariableValue( "vr_uturn" ) != 0;
switch (val)
{
case 0: // Default schema
trap_Cvar_Set("vr_button_map_RTHUMBLEFT", "turnleft"); // turn left
trap_Cvar_Set("vr_button_map_RTHUMBRIGHT", "turnright"); // turn right
trap_Cvar_Set("vr_button_map_RTHUMBFORWARD", "weapnext"); // next weapon
if (uturn) {
trap_Cvar_Set("vr_button_map_RTHUMBBACK", "uturn"); // u-turn
} else {
trap_Cvar_Set("vr_button_map_RTHUMBBACK", "weapprev"); // previous weapon
}
trap_Cvar_Set("vr_button_map_PRIMARYGRIP", "+weapon_select"); // weapon selector
trap_Cvar_Set("vr_button_map_PRIMARYTHUMBSTICK", ""); // unmapped
trap_Cvar_Set("vr_button_map_RTHUMBFORWARD_ALT", ""); // unmapped
trap_Cvar_Set("vr_button_map_RTHUMBFORWARDRIGHT", ""); // unmapped
trap_Cvar_Set("vr_button_map_RTHUMBFORWARDRIGHT_ALT", ""); // unmapped
trap_Cvar_Set("vr_button_map_RTHUMBRIGHT_ALT", ""); // unmapped
trap_Cvar_Set("vr_button_map_RTHUMBBACKRIGHT", ""); // unmapped
trap_Cvar_Set("vr_button_map_RTHUMBBACKRIGHT_ALT", ""); // unmapped
trap_Cvar_Set("vr_button_map_RTHUMBBACK_ALT", ""); // unmapped
trap_Cvar_Set("vr_button_map_RTHUMBBACKLEFT", ""); // unmapped
trap_Cvar_Set("vr_button_map_RTHUMBBACKLEFT_ALT", ""); // unmapped
trap_Cvar_Set("vr_button_map_RTHUMBLEFT_ALT", ""); // unmapped
trap_Cvar_Set("vr_button_map_RTHUMBFORWARDLEFT", ""); // unmapped
trap_Cvar_Set("vr_button_map_RTHUMBFORWARDLEFT_ALT", ""); // unmapped
break;
default: // Now we have only two schemas
// All directions as weapon select (useful for HMD wheel)
trap_Cvar_Set("vr_button_map_RTHUMBFORWARD", "+weapon_select");
trap_Cvar_Set("vr_button_map_RTHUMBFORWARDRIGHT", "+weapon_select");
trap_Cvar_Set("vr_button_map_RTHUMBRIGHT", "+weapon_select");
trap_Cvar_Set("vr_button_map_RTHUMBBACKRIGHT", "+weapon_select");
trap_Cvar_Set("vr_button_map_RTHUMBBACK", "+weapon_select");
trap_Cvar_Set("vr_button_map_RTHUMBBACKLEFT", "+weapon_select");
trap_Cvar_Set("vr_button_map_RTHUMBLEFT", "+weapon_select");
trap_Cvar_Set("vr_button_map_RTHUMBFORWARDLEFT", "+weapon_select");
trap_Cvar_Set("vr_button_map_PRIMARYTHUMBSTICK", "+weapon_select");
trap_Cvar_Set("vr_button_map_PRIMARYGRIP", "+alt"); // switch to alt layout
trap_Cvar_Set("vr_button_map_RTHUMBLEFT_ALT", "turnleft"); // turn left
trap_Cvar_Set("vr_button_map_RTHUMBRIGHT_ALT", "turnright"); // turn right
trap_Cvar_Set("vr_button_map_RTHUMBFORWARD_ALT", "weapnext");
if (uturn) {
trap_Cvar_Set("vr_button_map_RTHUMBBACK_ALT", "uturn");
} else {
trap_Cvar_Set("vr_button_map_RTHUMBBACK_ALT", "weapprev");
}
trap_Cvar_Set("vr_button_map_RTHUMBFORWARDRIGHT_ALT", "blank"); // unmapped
trap_Cvar_Set("vr_button_map_RTHUMBBACKRIGHT_ALT", "blank"); // unmapped
trap_Cvar_Set("vr_button_map_RTHUMBBACKLEFT_ALT", "blank"); // unmapped
trap_Cvar_Set("vr_button_map_RTHUMBFORWARDLEFT_ALT", "blank"); // unmapped
break;
}
} else if (Q_stricmp(name, "vr_uturn") == 0) {
int controlSchema = (int)trap_Cvar_VariableValue( "vr_controlSchema" ) % 2;
if (val) {
if (controlSchema == 0) {
trap_Cvar_Set("vr_button_map_RTHUMBBACK", "uturn");
} else {
trap_Cvar_Set("vr_button_map_RTHUMBBACK_ALT", "uturn");
}
} else {
if (controlSchema == 0) {
trap_Cvar_Set("vr_button_map_RTHUMBBACK", "");
} else {
trap_Cvar_Set("vr_button_map_RTHUMBBACK_ALT", "");
}
}
}
}

View file

@ -42,7 +42,7 @@ itemDef {
type ITEM_TYPE_YESNO
text "Autoswitch Weapons:"
cvar "cg_autoswitch"
rect 99 125 256 20
rect 99 75 256 20
textalign ITEM_ALIGN_RIGHT
textalignx 128
textaligny 20
@ -57,7 +57,7 @@ itemDef {
type ITEM_TYPE_YESNO
text "Railgun Scope:"
cvar "vr_weaponScope"
rect 99 150 256 20
rect 99 100 256 20
textalign ITEM_ALIGN_RIGHT
textalignx 128
textaligny 20
@ -72,7 +72,7 @@ itemDef {
type ITEM_TYPE_YESNO
text "Two-Handed Weapons:"
cvar "vr_twoHandedWeapons"
rect 99 175 256 20
rect 99 125 256 20
textalign ITEM_ALIGN_RIGHT
textalignx 128
textaligny 20
@ -88,13 +88,29 @@ itemDef {
text "Direction Mode:"
cvar "vr_directionMode"
cvarFloatList { "HMD (Default)" 0 "Off-hand Controller" 1 }
rect 99 200 256 20
rect 99 150 256 20
textalign ITEM_ALIGN_RIGHT
textalignx 128
textaligny 20
textscale .333
forecolor 1 1 1 1
visible 1
visible 1
}
itemDef {
name controls3
group grpControls3
type ITEM_TYPE_YESNO
text "Quick U-Turn:"
cvar "vr_uturn"
rect 99 175 256 20
textalign ITEM_ALIGN_RIGHT
textalignx 128
textaligny 20
textscale .333
forecolor 1 1 1 1
visible 1
action { uiScript update "vr_uturn" }
}
itemDef {
@ -104,7 +120,7 @@ itemDef {
text "Turning Mode:"
cvar "vr_snapturn"
cvarFloatList { "Smooth Turning" 0 "45 Degrees" 45 "90 Degrees" 90 }
rect 99 225 256 20
rect 99 200 256 20
textalign ITEM_ALIGN_RIGHT
textalignx 128
textaligny 20
@ -119,7 +135,7 @@ itemDef {
type ITEM_TYPE_YESNO
text "Right-Handed:"
cvar "vr_righthanded"
rect 99 250 256 20
rect 99 225 256 20
textalign ITEM_ALIGN_RIGHT
textalignx 128
textaligny 20
@ -134,7 +150,7 @@ itemDef {
type ITEM_TYPE_YESNO
text "Switch Thumbsticks:"
cvar "vr_switchThumbsticks"
rect 99 275 256 20
rect 99 250 256 20
textalign ITEM_ALIGN_RIGHT
textalignx 128
textaligny 20
@ -149,7 +165,7 @@ itemDef {
type ITEM_TYPE_SLIDER
text "Weapon Pitch:"
cvarfloat "vr_weaponPitch" 5 -25 5
rect 99 300 256 20
rect 99 275 256 20
textalign ITEM_ALIGN_RIGHT
textalignx 128
textaligny 20
@ -165,7 +181,7 @@ itemDef {
text "Weapon Wheel Mode:"
cvar "vr_weaponSelectorMode"
cvarFloatList { "Controller Based" 0 "HMD/Thumbstick Based" 1 }
rect 99 325 256 20
rect 99 300 256 20
textalign ITEM_ALIGN_RIGHT
textalignx 128
textaligny 20
@ -174,6 +190,22 @@ itemDef {
visible 1
}
itemDef {
name controls3
group grpControls3
type ITEM_TYPE_MULTI
text "Control Schema:"
cvar "vr_controlSchema"
cvarFloatList { "Weapon Wheel on Grip" 0 "Weapon Wheel on Thumbstick" 1 }
rect 99 325 256 20
textalign ITEM_ALIGN_RIGHT
textalignx 100
textaligny 20
textscale .333
forecolor 1 1 1 1
visible 1
action { uiScript update "vr_controlSchema" }
}
itemDef {
name fadebox

View file

@ -180,7 +180,7 @@ itemDef {
type ITEM_TYPE_YESNO
text "Railgun Scope:"
cvar "vr_weaponScope"
rect 30 40 200 20
rect 30 38 200 20
textalign ITEM_ALIGN_RIGHT
textalignx 143
textaligny 17
@ -194,7 +194,7 @@ itemDef {
type ITEM_TYPE_YESNO
text "Two-Handed Weapons:"
cvar "vr_twoHandedWeapons"
rect 30 60 200 20
rect 30 56 200 20
textalign ITEM_ALIGN_RIGHT
textalignx 143
textaligny 17
@ -210,7 +210,7 @@ itemDef {
text "Direction Mode:"
cvar "vr_directionMode"
cvarFloatList { "HMD (Default)" 0 "Off-hand Controller" 1 }
rect 30 80 200 20
rect 30 74 200 20
textalign ITEM_ALIGN_RIGHT
textalignx 143
textaligny 17
@ -222,16 +222,33 @@ itemDef {
itemDef {
name controls
group grpControls
type ITEM_TYPE_MULTI
text "Turning Mode:"
cvar "vr_snapturn"
cvarFloatList { "Smooth Turning" 0 "45 Degrees" 45 "90 Degrees" 90 }
rect 30 100 200 20
rect 30 92 200 20
textalign ITEM_ALIGN_RIGHT
textalignx 143
textaligny 17
textscale .25
forecolor 1 1 1 1
visible 1
}
itemDef {
name controls
group grpControls
type ITEM_TYPE_YESNO
text "Quick U-Turn:"
cvar "vr_uturn"
rect 30 110 200 20
textalign ITEM_ALIGN_RIGHT
textalignx 143
textaligny 17
textscale .25
forecolor 1 1 1 1
visible 1
visible 1
action { uiScript update "vr_uturn" }
}
itemDef {
@ -240,7 +257,7 @@ itemDef {
type ITEM_TYPE_YESNO
text "Right-Handed:"
cvar "vr_righthanded"
rect 30 120 200 20
rect 30 128 200 20
textalign ITEM_ALIGN_RIGHT
textalignx 143
textaligny 17
@ -255,7 +272,7 @@ itemDef {
type ITEM_TYPE_YESNO
text "Switch Thumbsticks:"
cvar "vr_switchThumbsticks"
rect 30 140 200 20
rect 30 146 200 20
textalign ITEM_ALIGN_RIGHT
textalignx 143
textaligny 17
@ -270,7 +287,7 @@ itemDef {
type ITEM_TYPE_SLIDER
text "Weapon Pitch:"
cvarfloat "vr_weaponPitch" 5 -25 5
rect 30 160 200 20
rect 30 164 200 20
textalign ITEM_ALIGN_RIGHT
textalignx 143
textaligny 17
@ -286,21 +303,38 @@ itemDef {
text "Weapon Wheel Mode:"
cvar "vr_weaponSelectorMode"
cvarFloatList { "Controller Based" 0 "HMD/Thumbstick Based" 1 }
rect 30 180 200 20
rect 30 182 200 20
textalign ITEM_ALIGN_RIGHT
textalignx 143
textaligny 17
textscale .25
forecolor 1 1 1 1
visible 1
}
itemDef {
name controls
group grpControls
type ITEM_TYPE_MULTI
text "Control Schema:"
cvar "vr_controlSchema"
cvarFloatList { "Weapon Wheel on Grip" 0 "Weapon Wheel on Thumbstick" 1 }
rect 30 200 200 20
textalign ITEM_ALIGN_RIGHT
textalignx 143
textaligny 17
textscale .25
forecolor 1 1 1 1
visible 1
visible 1
action { uiScript update "vr_controlSchema" }
}
itemDef {
name controls
group grpControls
style 1
text "Comfort Options"
rect 100 215 100 20
rect 100 231 100 20
textalign ITEM_ALIGN_RIGHT
textalignx 143
textaligny 17
@ -315,7 +349,7 @@ itemDef {
type ITEM_TYPE_SLIDER
text "Comfort Vignette:"
cvarfloat "vr_comfortVignette" 0.2 0 1
rect 30 240 200 20
rect 30 251 200 20
textalign ITEM_ALIGN_RIGHT
textalignx 143
textaligny 17
@ -329,7 +363,7 @@ itemDef {
type ITEM_TYPE_SLIDER
text "Height Adjust:"
cvarfloat "vr_heightAdjust" 0.2 0 1
rect 30 260 200 20
rect 30 271 200 20
textalign ITEM_ALIGN_RIGHT
textalignx 143
textaligny 17
@ -343,7 +377,7 @@ itemDef {
type ITEM_TYPE_YESNO
text "Roll When Hit:"
cvar "vr_rollWhenHit"
rect 30 280 200 20
rect 30 291 200 20
textalign ITEM_ALIGN_RIGHT
textalignx 143
textaligny 17
@ -357,7 +391,7 @@ itemDef {
type ITEM_TYPE_SLIDER
text "Haptic Intensity:"
cvarfloat "vr_hapticIntensity" 0.2 0 1
rect 30 300 200 20
rect 30 311 200 20
textalign ITEM_ALIGN_RIGHT
textalignx 143
textaligny 17
@ -372,7 +406,7 @@ itemDef {
text "HUD Depth:"
cvar "vr_hudDepth"
cvarFloatList { "Very Close" 0 "Close" 1 "Middle" 2 "Further" 3 "Far" 4 "Distant" 5 }
rect 30 320 200 20
rect 30 331 200 20
textalign ITEM_ALIGN_RIGHT
textalignx 143
textaligny 17
@ -386,7 +420,7 @@ itemDef {
type ITEM_TYPE_SLIDER
text "HUD Y Offset:"
cvarfloat "vr_hudYOffset" 20 -200 200
rect 30 340 200 20
rect 30 351 200 20
textalign ITEM_ALIGN_RIGHT
textalignx 143
textaligny 17