New control schema - weapon wheel disabled

This commit is contained in:
Petr Bartos 2022-04-06 20:17:58 +02:00
parent e91141c727
commit a88d864a65
6 changed files with 98 additions and 26 deletions

View file

@ -91,7 +91,7 @@ static void Controls3_SetMenuItems( void ) {
s_controls3.righthanded.curvalue = trap_Cvar_VariableValue( "vr_righthanded" ) != 0; s_controls3.righthanded.curvalue = trap_Cvar_VariableValue( "vr_righthanded" ) != 0;
s_controls3.weaponpitch.curvalue = trap_Cvar_VariableValue( "vr_weaponPitch" ) + 25; s_controls3.weaponpitch.curvalue = trap_Cvar_VariableValue( "vr_weaponPitch" ) + 25;
s_controls3.weaponselectormode.curvalue = (int)trap_Cvar_VariableValue( "vr_weaponSelectorMode" ) % 2; s_controls3.weaponselectormode.curvalue = (int)trap_Cvar_VariableValue( "vr_weaponSelectorMode" ) % 2;
s_controls3.controlschema.curvalue = (int)trap_Cvar_VariableValue( "vr_controlSchema" ) % 2; s_controls3.controlschema.curvalue = (int)trap_Cvar_VariableValue( "vr_controlSchema" ) % 3;
s_controls3.switchthumbsticks.curvalue = trap_Cvar_VariableValue( "vr_switchThumbsticks" ) != 0; s_controls3.switchthumbsticks.curvalue = trap_Cvar_VariableValue( "vr_switchThumbsticks" ) != 0;
} }
@ -137,16 +137,16 @@ static void Controls3_MenuEvent( void* ptr, int notification ) {
case ID_UTURN: case ID_UTURN:
{ {
if (s_controls3.uturn.curvalue) { if (s_controls3.uturn.curvalue) {
if (s_controls3.controlschema.curvalue == 0) { if (s_controls3.controlschema.curvalue == 1) {
trap_Cvar_Set("vr_button_map_RTHUMBBACK", "uturn");
} else {
trap_Cvar_Set("vr_button_map_RTHUMBBACK_ALT", "uturn"); trap_Cvar_Set("vr_button_map_RTHUMBBACK_ALT", "uturn");
} else {
trap_Cvar_Set("vr_button_map_RTHUMBBACK", "uturn");
} }
} else { } else {
if (s_controls3.controlschema.curvalue == 0) { if (s_controls3.controlschema.curvalue == 1) {
trap_Cvar_Set("vr_button_map_RTHUMBBACK", ""); trap_Cvar_Set("vr_button_map_RTHUMBBACK_ALT", "weapprev");
} else { } else {
trap_Cvar_Set("vr_button_map_RTHUMBBACK_ALT", ""); trap_Cvar_Set("vr_button_map_RTHUMBBACK", "weapprev");
} }
} }
} }
@ -157,7 +157,7 @@ static void Controls3_MenuEvent( void* ptr, int notification ) {
{ {
switch (s_controls3.controlschema.curvalue) switch (s_controls3.controlschema.curvalue)
{ {
case 0: // Default schema case 0: // Default schema (weapon wheel on grip)
trap_Cvar_Set("vr_button_map_RTHUMBLEFT", "turnleft"); // turn left 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_RTHUMBRIGHT", "turnright"); // turn right
trap_Cvar_Set("vr_button_map_RTHUMBFORWARD", "weapnext"); // next weapon trap_Cvar_Set("vr_button_map_RTHUMBFORWARD", "weapnext"); // next weapon
@ -181,8 +181,7 @@ static void Controls3_MenuEvent( void* ptr, int notification ) {
trap_Cvar_Set("vr_button_map_RTHUMBFORWARDLEFT", ""); // unmapped trap_Cvar_Set("vr_button_map_RTHUMBFORWARDLEFT", ""); // unmapped
trap_Cvar_Set("vr_button_map_RTHUMBFORWARDLEFT_ALT", ""); // unmapped trap_Cvar_Set("vr_button_map_RTHUMBFORWARDLEFT_ALT", ""); // unmapped
break; break;
default: // Now we have only two schemas case 1: // Weapon wheel on thumbstick - all directions as weapon select (useful for HMD wheel)
// All directions as weapon select (useful for HMD wheel)
trap_Cvar_Set("vr_button_map_RTHUMBFORWARD", "+weapon_select"); trap_Cvar_Set("vr_button_map_RTHUMBFORWARD", "+weapon_select");
trap_Cvar_Set("vr_button_map_RTHUMBFORWARDRIGHT", "+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_RTHUMBRIGHT", "+weapon_select");
@ -206,6 +205,30 @@ static void Controls3_MenuEvent( void* ptr, int notification ) {
trap_Cvar_Set("vr_button_map_RTHUMBBACKLEFT_ALT", "blank"); // unmapped trap_Cvar_Set("vr_button_map_RTHUMBBACKLEFT_ALT", "blank"); // unmapped
trap_Cvar_Set("vr_button_map_RTHUMBFORWARDLEFT_ALT", "blank"); // unmapped trap_Cvar_Set("vr_button_map_RTHUMBFORWARDLEFT_ALT", "blank"); // unmapped
break; break;
default: // Weapon wheel disabled - only prev/next weapon switch is active
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 (s_controls3.uturn.curvalue) {
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", ""); // unmapped
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;
} }
} }
trap_Cvar_SetValue( "vr_controlSchema", s_controls3.controlschema.curvalue ); trap_Cvar_SetValue( "vr_controlSchema", s_controls3.controlschema.curvalue );
@ -250,6 +273,7 @@ static void Controls3_MenuInit( void ) {
{ {
"Weapon Wheel on Grip", "Weapon Wheel on Grip",
"Weapon Wheel on Thumbstick", "Weapon Wheel on Thumbstick",
"Weapon Wheel Disabled",
NULL NULL
}; };
@ -390,7 +414,7 @@ static void Controls3_MenuInit( void ) {
s_controls3.controlschema.generic.callback = Controls3_MenuEvent; s_controls3.controlschema.generic.callback = Controls3_MenuEvent;
s_controls3.controlschema.generic.id = ID_CONTROLSCHEMA; s_controls3.controlschema.generic.id = ID_CONTROLSCHEMA;
s_controls3.controlschema.itemnames = s_controlschema; s_controls3.controlschema.itemnames = s_controlschema;
s_controls3.controlschema.numitems = 2; s_controls3.controlschema.numitems = 3;
s_controls3.back.generic.type = MTYPE_BITMAP; s_controls3.back.generic.type = MTYPE_BITMAP;
s_controls3.back.generic.name = ART_BACK0; s_controls3.back.generic.name = ART_BACK0;

View file

@ -3174,7 +3174,7 @@ static void UI_Update(const char *name) {
qboolean uturn = trap_Cvar_VariableValue( "vr_uturn" ) != 0; qboolean uturn = trap_Cvar_VariableValue( "vr_uturn" ) != 0;
switch (val) switch (val)
{ {
case 0: // Default schema case 0: // Default schema (weapon wheel on grip)
trap_Cvar_Set("vr_button_map_RTHUMBLEFT", "turnleft"); // turn left 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_RTHUMBRIGHT", "turnright"); // turn right
trap_Cvar_Set("vr_button_map_RTHUMBFORWARD", "weapnext"); // next weapon trap_Cvar_Set("vr_button_map_RTHUMBFORWARD", "weapnext"); // next weapon
@ -3198,8 +3198,7 @@ static void UI_Update(const char *name) {
trap_Cvar_Set("vr_button_map_RTHUMBFORWARDLEFT", ""); // unmapped trap_Cvar_Set("vr_button_map_RTHUMBFORWARDLEFT", ""); // unmapped
trap_Cvar_Set("vr_button_map_RTHUMBFORWARDLEFT_ALT", ""); // unmapped trap_Cvar_Set("vr_button_map_RTHUMBFORWARDLEFT_ALT", ""); // unmapped
break; break;
default: // Now we have only two schemas case 1: // Weapon wheel on thumbstick - all directions as weapon select (useful for HMD wheel)
// All directions as weapon select (useful for HMD wheel)
trap_Cvar_Set("vr_button_map_RTHUMBFORWARD", "+weapon_select"); trap_Cvar_Set("vr_button_map_RTHUMBFORWARD", "+weapon_select");
trap_Cvar_Set("vr_button_map_RTHUMBFORWARDRIGHT", "+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_RTHUMBRIGHT", "+weapon_select");
@ -3223,20 +3222,44 @@ static void UI_Update(const char *name) {
trap_Cvar_Set("vr_button_map_RTHUMBBACKLEFT_ALT", "blank"); // unmapped trap_Cvar_Set("vr_button_map_RTHUMBBACKLEFT_ALT", "blank"); // unmapped
trap_Cvar_Set("vr_button_map_RTHUMBFORWARDLEFT_ALT", "blank"); // unmapped trap_Cvar_Set("vr_button_map_RTHUMBFORWARDLEFT_ALT", "blank"); // unmapped
break; break;
default: // Weapon wheel disabled - only prev/next weapon switch is active
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", ""); // unmapped
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;
} }
} else if (Q_stricmp(name, "vr_uturn") == 0) { } else if (Q_stricmp(name, "vr_uturn") == 0) {
int controlSchema = (int)trap_Cvar_VariableValue( "vr_controlSchema" ) % 2; int controlSchema = (int)trap_Cvar_VariableValue( "vr_controlSchema" ) % 3;
if (val) { if (val) {
if (controlSchema == 0) { if (controlSchema == 1) {
trap_Cvar_Set("vr_button_map_RTHUMBBACK", "uturn");
} else {
trap_Cvar_Set("vr_button_map_RTHUMBBACK_ALT", "uturn"); trap_Cvar_Set("vr_button_map_RTHUMBBACK_ALT", "uturn");
} else {
trap_Cvar_Set("vr_button_map_RTHUMBBACK", "uturn");
} }
} else { } else {
if (controlSchema == 0) { if (controlSchema == 1) {
trap_Cvar_Set("vr_button_map_RTHUMBBACK", ""); trap_Cvar_Set("vr_button_map_RTHUMBBACK_ALT", "weapprev");
} else { } else {
trap_Cvar_Set("vr_button_map_RTHUMBBACK_ALT", ""); trap_Cvar_Set("vr_button_map_RTHUMBBACK", "weapprev");
} }
} }
} else if (Q_stricmp(name, "vr_goreLevel") == 0) { } else if (Q_stricmp(name, "vr_goreLevel") == 0) {

View file

@ -110,8 +110,9 @@ void VR_InitCvars( void )
Cvar_Get ("vr_uturn", "0", CVAR_ARCHIVE); Cvar_Get ("vr_uturn", "0", CVAR_ARCHIVE);
Cvar_Get ("vr_controlSchema", "0", CVAR_ARCHIVE); Cvar_Get ("vr_controlSchema", "0", CVAR_ARCHIVE);
qboolean uturnEnabled = Cvar_VariableValue( "vr_uturn" ) != 0; qboolean uturnEnabled = Cvar_VariableValue( "vr_uturn" ) != 0;
int controlSchema = (int)Cvar_VariableValue( "vr_controlSchema" ) % 2; int controlSchema = (int)Cvar_VariableValue( "vr_controlSchema" ) % 3;
if (controlSchema == 0) { if (controlSchema == 0) {
// Default schema (weapon wheel on grip)
Cvar_Get ("vr_button_map_RTHUMBLEFT", "turnleft", CVAR_ARCHIVE); // turn left Cvar_Get ("vr_button_map_RTHUMBLEFT", "turnleft", CVAR_ARCHIVE); // turn left
Cvar_Get ("vr_button_map_RTHUMBRIGHT", "turnright", CVAR_ARCHIVE); // turn right Cvar_Get ("vr_button_map_RTHUMBRIGHT", "turnright", CVAR_ARCHIVE); // turn right
Cvar_Get ("vr_button_map_RTHUMBFORWARD", "weapnext", CVAR_ARCHIVE); // next weapon Cvar_Get ("vr_button_map_RTHUMBFORWARD", "weapnext", CVAR_ARCHIVE); // next weapon
@ -134,8 +135,8 @@ void VR_InitCvars( void )
Cvar_Get ("vr_button_map_RTHUMBLEFT_ALT", "", CVAR_ARCHIVE); // unmapped Cvar_Get ("vr_button_map_RTHUMBLEFT_ALT", "", CVAR_ARCHIVE); // unmapped
Cvar_Get ("vr_button_map_RTHUMBFORWARDLEFT", "", CVAR_ARCHIVE); // unmapped Cvar_Get ("vr_button_map_RTHUMBFORWARDLEFT", "", CVAR_ARCHIVE); // unmapped
Cvar_Get ("vr_button_map_RTHUMBFORWARDLEFT_ALT", "", CVAR_ARCHIVE); // unmapped Cvar_Get ("vr_button_map_RTHUMBFORWARDLEFT_ALT", "", CVAR_ARCHIVE); // unmapped
} else { } else if (controlSchema == 1) {
// All directions as weapon select (useful for HMD wheel) // Weapon wheel on thumbstick - all directions as weapon select (useful for HMD wheel)
Cvar_Get ("vr_button_map_RTHUMBFORWARD", "+weapon_select", CVAR_ARCHIVE); Cvar_Get ("vr_button_map_RTHUMBFORWARD", "+weapon_select", CVAR_ARCHIVE);
Cvar_Get ("vr_button_map_RTHUMBFORWARDRIGHT", "+weapon_select", CVAR_ARCHIVE); Cvar_Get ("vr_button_map_RTHUMBFORWARDRIGHT", "+weapon_select", CVAR_ARCHIVE);
Cvar_Get ("vr_button_map_RTHUMBRIGHT", "+weapon_select", CVAR_ARCHIVE); Cvar_Get ("vr_button_map_RTHUMBRIGHT", "+weapon_select", CVAR_ARCHIVE);
@ -158,6 +159,30 @@ void VR_InitCvars( void )
Cvar_Get ("vr_button_map_RTHUMBBACKRIGHT_ALT", "blank", CVAR_ARCHIVE); // unmapped Cvar_Get ("vr_button_map_RTHUMBBACKRIGHT_ALT", "blank", CVAR_ARCHIVE); // unmapped
Cvar_Get ("vr_button_map_RTHUMBBACKLEFT_ALT", "blank", CVAR_ARCHIVE); // unmapped Cvar_Get ("vr_button_map_RTHUMBBACKLEFT_ALT", "blank", CVAR_ARCHIVE); // unmapped
Cvar_Get ("vr_button_map_RTHUMBFORWARDLEFT_ALT", "blank", CVAR_ARCHIVE); // unmapped Cvar_Get ("vr_button_map_RTHUMBFORWARDLEFT_ALT", "blank", CVAR_ARCHIVE); // unmapped
} else {
// Weapon wheel disabled - only prev/next weapon switch is active
Cvar_Get ("vr_button_map_RTHUMBLEFT", "turnleft", CVAR_ARCHIVE); // turn left
Cvar_Get ("vr_button_map_RTHUMBRIGHT", "turnright", CVAR_ARCHIVE); // turn right
Cvar_Get ("vr_button_map_RTHUMBFORWARD", "weapnext", CVAR_ARCHIVE); // next weapon
if (uturnEnabled) {
Cvar_Get ("vr_button_map_RTHUMBBACK", "uturn", CVAR_ARCHIVE); // u-turn
} else {
Cvar_Get ("vr_button_map_RTHUMBBACK", "weapprev", CVAR_ARCHIVE); // previous weapon
}
Cvar_Get ("vr_button_map_PRIMARYGRIP", "", CVAR_ARCHIVE); // unmapped
Cvar_Get ("vr_button_map_PRIMARYTHUMBSTICK", "", CVAR_ARCHIVE); // unmapped
Cvar_Get ("vr_button_map_RTHUMBFORWARD_ALT", "", CVAR_ARCHIVE); // unmapped
Cvar_Get ("vr_button_map_RTHUMBFORWARDRIGHT", "", CVAR_ARCHIVE); // unmapped
Cvar_Get ("vr_button_map_RTHUMBFORWARDRIGHT_ALT", "", CVAR_ARCHIVE); // unmapped
Cvar_Get ("vr_button_map_RTHUMBRIGHT_ALT", "", CVAR_ARCHIVE); // unmapped
Cvar_Get ("vr_button_map_RTHUMBBACKRIGHT", "", CVAR_ARCHIVE); // unmapped
Cvar_Get ("vr_button_map_RTHUMBBACKRIGHT_ALT", "", CVAR_ARCHIVE); // unmapped
Cvar_Get ("vr_button_map_RTHUMBBACK_ALT", "", CVAR_ARCHIVE); // unmapped
Cvar_Get ("vr_button_map_RTHUMBBACKLEFT", "", CVAR_ARCHIVE); // unmapped
Cvar_Get ("vr_button_map_RTHUMBBACKLEFT_ALT", "", CVAR_ARCHIVE); // unmapped
Cvar_Get ("vr_button_map_RTHUMBLEFT_ALT", "", CVAR_ARCHIVE); // unmapped
Cvar_Get ("vr_button_map_RTHUMBFORWARDLEFT", "", CVAR_ARCHIVE); // unmapped
Cvar_Get ("vr_button_map_RTHUMBFORWARDLEFT_ALT", "", CVAR_ARCHIVE); // unmapped
} }
//Remaining button mapping (buttons not affected by schemas) //Remaining button mapping (buttons not affected by schemas)

View file

@ -196,7 +196,7 @@ itemDef {
type ITEM_TYPE_MULTI type ITEM_TYPE_MULTI
text "Control Schema:" text "Control Schema:"
cvar "vr_controlSchema" cvar "vr_controlSchema"
cvarFloatList { "Weapon Wheel on Grip" 0 "Weapon Wheel on Thumbstick" 1 } cvarFloatList { "Weapon Wheel on Grip" 0 "Weapon Wheel on Thumbstick" 1 "Weapon Wheel Disabled" 2 }
rect 99 325 256 20 rect 99 325 256 20
textalign ITEM_ALIGN_RIGHT textalign ITEM_ALIGN_RIGHT
textalignx 100 textalignx 100

View file

@ -318,7 +318,7 @@ itemDef {
type ITEM_TYPE_MULTI type ITEM_TYPE_MULTI
text "Control Schema:" text "Control Schema:"
cvar "vr_controlSchema" cvar "vr_controlSchema"
cvarFloatList { "Weapon Wheel on Grip" 0 "Weapon Wheel on Thumbstick" 1 } cvarFloatList { "Weapon Wheel on Grip" 0 "Weapon Wheel on Thumbstick" 1 "Weapon Wheel Disabled" 2 }
rect 30 200 200 20 rect 30 200 200 20
textalign ITEM_ALIGN_RIGHT textalign ITEM_ALIGN_RIGHT
textalignx 143 textalignx 143