Remap face buttons along with switching thumbsticks

This commit is contained in:
Petr Bartos 2022-05-14 19:30:50 +02:00
parent 8cf2ffc445
commit 8cf8f3ae1b
5 changed files with 42 additions and 4 deletions

View file

@ -213,6 +213,19 @@ static void Controls3_MenuEvent( void* ptr, int notification ) {
break;
case ID_SWITCHTHUMBSTICKS:
{
if (s_controls3.switchthumbsticks.curvalue) {
trap_Cvar_Set("vr_button_map_A", "+button2"); // Use Item
trap_Cvar_Set("vr_button_map_B", "+button3"); // Gesture
trap_Cvar_Set("vr_button_map_X", "+moveup"); // Jump
trap_Cvar_Set("vr_button_map_Y", "+movedown"); // Crouch
} else {
trap_Cvar_Set("vr_button_map_A", "+moveup"); // Jump
trap_Cvar_Set("vr_button_map_B", "+movedown"); // Crouch
trap_Cvar_Set("vr_button_map_X", "+button2"); // Use Item
trap_Cvar_Set("vr_button_map_Y", "+button3"); // Gesture
}
}
trap_Cvar_SetValue( "vr_switchThumbsticks", s_controls3.switchthumbsticks.curvalue );
break;

View file

@ -3223,6 +3223,18 @@ static void UI_Update(const char *name) {
trap_Cvar_Set("vr_button_map_RTHUMBLEFT_ALT", ""); // unmapped
break;
}
} else if (Q_stricmp(name, "vr_switchThumbsticks") == 0) {
if (val) {
trap_Cvar_Set("vr_button_map_A", "+button2"); // Use Item
trap_Cvar_Set("vr_button_map_B", "+button3"); // Gesture
trap_Cvar_Set("vr_button_map_X", "+moveup"); // Jump
trap_Cvar_Set("vr_button_map_Y", "+movedown"); // Crouch
} else {
trap_Cvar_Set("vr_button_map_A", "+moveup"); // Jump
trap_Cvar_Set("vr_button_map_B", "+movedown"); // Crouch
trap_Cvar_Set("vr_button_map_X", "+button2"); // Use Item
trap_Cvar_Set("vr_button_map_Y", "+button3"); // Gesture
}
} else if (Q_stricmp(name, "vr_uturn") == 0) {
int controlSchema = (int)trap_Cvar_VariableValue( "vr_controlSchema" ) % 3;
if (val) {

View file

@ -239,14 +239,25 @@ void VR_InitCvars( void )
Cvar_Get ("vr_button_map_RTHUMBLEFT_ALT", "", CVAR_ARCHIVE); // unmapped
}
// Map face buttons based on thumbstick assigned to movement
// (cannot move and jump/crouch with same thumb at same time)
qboolean switchThumbsticks = Cvar_VariableValue( "vr_switchThumbsticks" ) != 0;
if (switchThumbsticks) {
Cvar_Get ("vr_button_map_A", "+button2", CVAR_ARCHIVE); // Use Item
Cvar_Get ("vr_button_map_B", "+button3", CVAR_ARCHIVE); // Gesture
Cvar_Get ("vr_button_map_X", "+moveup", CVAR_ARCHIVE); // Jump
Cvar_Get ("vr_button_map_Y", "+movedown", CVAR_ARCHIVE); // Crouch
} else {
Cvar_Get ("vr_button_map_A", "+moveup", CVAR_ARCHIVE); // Jump
Cvar_Get ("vr_button_map_B", "+movedown", CVAR_ARCHIVE); // Crouch
Cvar_Get ("vr_button_map_X", "+button2", CVAR_ARCHIVE); // Use Item
Cvar_Get ("vr_button_map_Y", "+button3", CVAR_ARCHIVE); // Gesture
}
//Remaining button mapping (buttons not affected by schemas)
Cvar_Get ("vr_button_map_A", "+moveup", CVAR_ARCHIVE); // Jump
Cvar_Get ("vr_button_map_A_ALT", "", CVAR_ARCHIVE); // unmapped
Cvar_Get ("vr_button_map_B", "+movedown", CVAR_ARCHIVE); // Crouch
Cvar_Get ("vr_button_map_B_ALT", "", CVAR_ARCHIVE); // unmapped
Cvar_Get ("vr_button_map_X", "+button2", CVAR_ARCHIVE); // Use Item
Cvar_Get ("vr_button_map_X_ALT", "", CVAR_ARCHIVE); // unmapped
Cvar_Get ("vr_button_map_Y", "+button3", CVAR_ARCHIVE); // Gesture
Cvar_Get ("vr_button_map_Y_ALT", "", CVAR_ARCHIVE); // unmapped
Cvar_Get ("vr_button_map_SECONDARYTHUMBSTICK", "+scores", CVAR_ARCHIVE); // Scoreboard
Cvar_Get ("vr_button_map_SECONDARYTHUMBSTICK_ALT", "", CVAR_ARCHIVE); // unmapped

View file

@ -157,6 +157,7 @@ itemDef {
textscale .333
forecolor 1 1 1 1
visible 1
action { uiScript update "vr_switchThumbsticks" }
}
itemDef {

View file

@ -279,6 +279,7 @@ itemDef {
textscale .25
forecolor 1 1 1 1
visible 1
action { uiScript update "vr_switchThumbsticks" }
}
itemDef {