Merge pull request #14 from petr666/feature/control-tweaks

Control tweaks
This commit is contained in:
Simon 2022-03-13 16:14:00 +00:00 committed by GitHub
commit edee441e7a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 288 additions and 121 deletions

View file

@ -14,13 +14,36 @@ set cg_weaponbob 0
set sv_pure 0 set sv_pure 0
set sv_master1 "13.36.227.32:27950" set sv_master1 "13.36.227.32:27950"
//VR Button mappings - ONLY put overrides of defaults in here, such as alt key mappings // VR Button mappings - ONLY put overrides of defaults in here, such as alt key mappings
set vr_button_map_RTHUMBFORWARD_ALT "weapon 2" // set vr_button_map_A ""
set vr_button_map_RTHUMBFORWARDRIGHT_ALT "weapon 3" // set vr_button_map_A_ALT ""
set vr_button_map_RTHUMBRIGHT_ALT "weapon 4" // set vr_button_map_B ""
set vr_button_map_RTHUMBBACKRIGHT_ALT "weapon 5" // set vr_button_map_B_ALT ""
set vr_button_map_RTHUMBBACK_ALT "weapon 6" // set vr_button_map_X ""
set vr_button_map_RTHUMBBACKLEFT_ALT "weapon 7" // set vr_button_map_X_ALT ""
set vr_button_map_RTHUMBLEFT_ALT "weapon 8" // set vr_button_map_Y ""
set vr_button_map_RTHUMBFORWARDLEFT_ALT "weapon 9" // set vr_button_map_Y_ALT ""
// set vr_button_map_SECONDARYTHUMBSTICK ""
// set vr_button_map_SECONDARYTHUMBSTICK_ALT ""
// set vr_button_map_PRIMARYTHUMBSTICK ""
// set vr_button_map_PRIMARYTHUMBSTICK_ALT ""
// set vr_button_map_RTHUMBFORWARD ""
// set vr_button_map_RTHUMBFORWARD_ALT ""
// set vr_button_map_RTHUMBFORWARDLEFT ""
// set vr_button_map_RTHUMBFORWARDLEFT_ALT ""
// set vr_button_map_RTHUMBFORWARDRIGHT ""
// set vr_button_map_RTHUMBFORWARDRIGHT_ALT ""
// set vr_button_map_RTHUMBBACK ""
// set vr_button_map_RTHUMBBACK_ALT ""
// set vr_button_map_RTHUMBBACKLEFT ""
// set vr_button_map_RTHUMBBACKLEFT_ALT ""
// set vr_button_map_RTHUMBBACKRIGHT ""
// set vr_button_map_RTHUMBBACKRIGHT_ALT ""
// set vr_button_map_SECONDARYTRIGGER ""
// set vr_button_map_SECONDARYTRIGGER_ALT ""
// set vr_button_map_PRIMARYTRIGGER ""
// set vr_button_map_PRIMARYTRIGGER_ALT ""
// set vr_button_map_SECONDARYGRIP ""
// set vr_button_map_SECONDARYGRIP_ALT ""
// set vr_button_map_PRIMARYGRIP "+alt"
// set vr_button_map_PRIMARYGRIP_ALT ""

View file

@ -2094,6 +2094,15 @@ void CG_DrawWeaponSelector( void )
VectorMA(holsterOrigin, ((DEPTH*2.0f)*((selectorMode == WS_CONTROLLER) ? frac : 1.0f)), holsterForward, holsterOrigin); VectorMA(holsterOrigin, ((DEPTH*2.0f)*((selectorMode == WS_CONTROLLER) ? frac : 1.0f)), holsterForward, holsterOrigin);
VectorCopy(holsterOrigin, selectorOrigin); VectorCopy(holsterOrigin, selectorOrigin);
float thumbstickAxisX = 0.0f;
float thumbstickAxisY = 0.0f;
if (length(vr->thumbstick_location[THUMB_RIGHT][0], vr->thumbstick_location[THUMB_RIGHT][1]) > 0.95f)
{
float a = atan2(vr->thumbstick_location[THUMB_RIGHT][0], vr->thumbstick_location[THUMB_RIGHT][1]);
thumbstickAxisX = sinf(a) * 0.95f;
thumbstickAxisY = cosf(a) * 0.95f;
}
float x = 0.0f; float x = 0.0f;
float y = 0.0f; float y = 0.0f;
if (selectorMode == WS_CONTROLLER) if (selectorMode == WS_CONTROLLER)
@ -2110,12 +2119,8 @@ void CG_DrawWeaponSelector( void )
} }
else //selectorMode == WS_HMD else //selectorMode == WS_HMD
{ {
if (length(vr->thumbstick_location[THUMB_RIGHT][0], vr->thumbstick_location[THUMB_RIGHT][1]) > 0.95f) x = thumbstickAxisX;
{ y = thumbstickAxisY;
float a = atan2(vr->thumbstick_location[THUMB_RIGHT][0], vr->thumbstick_location[THUMB_RIGHT][1]);
x = sinf(a) * 0.95f;
y = cosf(a) * 0.95f;
}
} }
VectorMA(selectorOrigin, RAD * x, holsterRight, selectorOrigin); VectorMA(selectorOrigin, RAD * x, holsterRight, selectorOrigin);
@ -2355,6 +2360,18 @@ void CG_DrawWeaponSelector( void )
{ {
cg.weaponSelectorSelection = WP_NONE; cg.weaponSelectorSelection = WP_NONE;
} }
// In case was invoked by thumbstick axis and thumbstick is centered
// select weapon (if any selected) and close the selector
if (vr->weapon_select_autoclose && frac > 0.25f) {
if (thumbstickAxisX > -0.1f && thumbstickAxisX < 0.1f && thumbstickAxisY > -0.1f && thumbstickAxisY < 0.1f) {
if (selected) {
cg.weaponSelect = cg.weaponSelectorSelection;
}
vr->weapon_select = qfalse;
vr->weapon_select_autoclose = qfalse;
}
}
} }
/* /*

View file

@ -47,8 +47,10 @@ CONTROLS OPTIONS MENU
#define ID_RIGHTHANDED 132 #define ID_RIGHTHANDED 132
#define ID_WEAPONPITCH 133 #define ID_WEAPONPITCH 133
#define ID_WEAPONSELECTORMODE 134 #define ID_WEAPONSELECTORMODE 134
#define ID_UTURN 135
#define ID_CONTROLSCHEMA 136
#define ID_BACK 135 #define ID_BACK 137
#define NUM_DIRECTIONMODE 2 #define NUM_DIRECTIONMODE 2
@ -65,9 +67,11 @@ typedef struct {
menuradiobutton_s twohanded; menuradiobutton_s twohanded;
menulist_s directionmode; menulist_s directionmode;
menulist_s snapturn; menulist_s snapturn;
menuradiobutton_s uturn;
menuradiobutton_s righthanded; menuradiobutton_s righthanded;
menuslider_s weaponpitch; menuslider_s weaponpitch;
menulist_s weaponselectormode; menulist_s weaponselectormode;
menulist_s controlschema;
menubitmap_s back; menubitmap_s back;
} controls3_t; } controls3_t;
@ -81,9 +85,11 @@ static void Controls3_SetMenuItems( void ) {
s_controls3.twohanded.curvalue = trap_Cvar_VariableValue( "vr_twoHandedWeapons" ) != 0; s_controls3.twohanded.curvalue = trap_Cvar_VariableValue( "vr_twoHandedWeapons" ) != 0;
s_controls3.directionmode.curvalue = (int)trap_Cvar_VariableValue( "vr_directionMode" ) % NUM_DIRECTIONMODE; s_controls3.directionmode.curvalue = (int)trap_Cvar_VariableValue( "vr_directionMode" ) % NUM_DIRECTIONMODE;
s_controls3.snapturn.curvalue = (int)trap_Cvar_VariableValue( "vr_snapturn" ) / 45; s_controls3.snapturn.curvalue = (int)trap_Cvar_VariableValue( "vr_snapturn" ) / 45;
s_controls3.uturn.curvalue = trap_Cvar_VariableValue( "vr_uturn" ) != 0;
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" ) % 4; s_controls3.weaponselectormode.curvalue = (int)trap_Cvar_VariableValue( "vr_weaponSelectorMode" ) % 2;
s_controls3.controlschema.curvalue = (int)trap_Cvar_VariableValue( "vr_controlSchema" ) % 2;
} }
@ -122,34 +128,86 @@ static void Controls3_MenuEvent( void* ptr, int notification ) {
break; break;
case ID_WEAPONSELECTORMODE: case ID_WEAPONSELECTORMODE:
{
switch (s_controls3.weaponselectormode.curvalue)
{
case 0: //Controller
trap_Cvar_Set( "vr_button_map_PRIMARYGRIP", "+weapon_select");
trap_Cvar_Set( "vr_button_map_RTHUMBFORWARD", "");
trap_Cvar_Set( "vr_button_map_RTHUMBBACK", "uturn");
break;
case 1: //HMD
trap_Cvar_Set( "vr_button_map_PRIMARYGRIP", "+weapon_select");
trap_Cvar_Set( "vr_button_map_RTHUMBFORWARD", "");
trap_Cvar_Set( "vr_button_map_RTHUMBBACK", "uturn");
break;
case 2: //Alt-Key bindings
trap_Cvar_Set( "vr_button_map_PRIMARYGRIP", "+alt");
trap_Cvar_Set( "vr_button_map_RTHUMBFORWARD", "");
trap_Cvar_Set( "vr_button_map_RTHUMBBACK", "uturn");
break;
case 3: //Thumbstick
trap_Cvar_Set( "vr_button_map_PRIMARYGRIP", "");
trap_Cvar_Set( "vr_button_map_RTHUMBFORWARD", "weapnext");
trap_Cvar_Set( "vr_button_map_RTHUMBBACK", "weapprev");
break;
}
}
trap_Cvar_SetValue( "vr_weaponSelectorMode", s_controls3.weaponselectormode.curvalue ); trap_Cvar_SetValue( "vr_weaponSelectorMode", s_controls3.weaponselectormode.curvalue );
break; break;
case ID_UTURN:
{
if (s_controls3.uturn.curvalue) {
if (s_controls3.controlschema.curvalue == 0) {
trap_Cvar_Set("vr_button_map_RTHUMBBACK", "uturn");
} else {
trap_Cvar_Set("vr_button_map_RTHUMBBACK_ALT", "uturn");
}
} else {
if (s_controls3.controlschema.curvalue == 0) {
trap_Cvar_Set("vr_button_map_RTHUMBBACK", "");
} else {
trap_Cvar_Set("vr_button_map_RTHUMBBACK_ALT", "");
}
}
}
trap_Cvar_SetValue( "vr_uturn", s_controls3.uturn.curvalue );
break;
case ID_CONTROLSCHEMA:
{
switch (s_controls3.controlschema.curvalue)
{
case 0: // Default schema
trap_Cvar_Set("vr_button_map_RTHUMBLEFT", ""); // empty ~ turn left
trap_Cvar_Set("vr_button_map_RTHUMBRIGHT", ""); // empty ~ 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", "+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", ""); // empty ~ turn left
trap_Cvar_Set("vr_button_map_RTHUMBRIGHT_ALT", ""); // empty ~ turn right
trap_Cvar_Set("vr_button_map_RTHUMBFORWARD_ALT", "weapnext");
if (s_controls3.uturn.curvalue) {
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", ""); // unmapped
trap_Cvar_Set("vr_button_map_RTHUMBBACKRIGHT_ALT", ""); // unmapped
trap_Cvar_Set("vr_button_map_RTHUMBBACKLEFT_ALT", ""); // unmapped
trap_Cvar_Set("vr_button_map_RTHUMBFORWARDLEFT_ALT", ""); // unmapped
break;
}
}
trap_Cvar_SetValue( "vr_controlSchema", s_controls3.controlschema.curvalue );
break;
case ID_BACK: case ID_BACK:
UI_PopMenu(); UI_PopMenu();
break; break;
@ -178,8 +236,13 @@ static void Controls3_MenuInit( void ) {
{ {
"Controller Weapon Selector", "Controller Weapon Selector",
"HMD Weapon Wheel", "HMD Weapon Wheel",
"Alt-Key Bindings", NULL
"Thumbstick Forward/Back", };
static const char *s_controlschema[] =
{
"Primary",
"Secondary",
NULL NULL
}; };
@ -213,7 +276,7 @@ static void Controls3_MenuInit( void ) {
s_controls3.framer.width = 256; s_controls3.framer.width = 256;
s_controls3.framer.height = 334; s_controls3.framer.height = 334;
y = 162; y = 126;
s_controls3.autoswitch.generic.type = MTYPE_RADIOBUTTON; s_controls3.autoswitch.generic.type = MTYPE_RADIOBUTTON;
s_controls3.autoswitch.generic.flags = QMF_PULSEIFFOCUS|QMF_SMALLFONT; s_controls3.autoswitch.generic.flags = QMF_PULSEIFFOCUS|QMF_SMALLFONT;
s_controls3.autoswitch.generic.name = "Autoswitch Weapons:"; s_controls3.autoswitch.generic.name = "Autoswitch Weapons:";
@ -262,6 +325,15 @@ static void Controls3_MenuInit( void ) {
s_controls3.snapturn.itemnames = s_snapturn; s_controls3.snapturn.itemnames = s_snapturn;
s_controls3.snapturn.numitems = 3; s_controls3.snapturn.numitems = 3;
y += BIGCHAR_HEIGHT+2;
s_controls3.uturn.generic.type = MTYPE_RADIOBUTTON;
s_controls3.uturn.generic.flags = QMF_PULSEIFFOCUS|QMF_SMALLFONT;
s_controls3.uturn.generic.x = VR_X_POS;
s_controls3.uturn.generic.y = y;
s_controls3.uturn.generic.name = "Quick U-Turn:";
s_controls3.uturn.generic.callback = Controls3_MenuEvent;
s_controls3.uturn.generic.id = ID_UTURN;
y += BIGCHAR_HEIGHT+2; y += BIGCHAR_HEIGHT+2;
s_controls3.righthanded.generic.type = MTYPE_RADIOBUTTON; s_controls3.righthanded.generic.type = MTYPE_RADIOBUTTON;
s_controls3.righthanded.generic.name = "Right-Handed:"; s_controls3.righthanded.generic.name = "Right-Handed:";
@ -291,7 +363,18 @@ static void Controls3_MenuInit( void ) {
s_controls3.weaponselectormode.generic.callback = Controls3_MenuEvent; s_controls3.weaponselectormode.generic.callback = Controls3_MenuEvent;
s_controls3.weaponselectormode.generic.id = ID_WEAPONSELECTORMODE; s_controls3.weaponselectormode.generic.id = ID_WEAPONSELECTORMODE;
s_controls3.weaponselectormode.itemnames = s_weaponselectormode; s_controls3.weaponselectormode.itemnames = s_weaponselectormode;
s_controls3.weaponselectormode.numitems = 4; s_controls3.weaponselectormode.numitems = 2;
y += BIGCHAR_HEIGHT+2;
s_controls3.controlschema.generic.type = MTYPE_SPINCONTROL;
s_controls3.controlschema.generic.flags = QMF_PULSEIFFOCUS|QMF_SMALLFONT;
s_controls3.controlschema.generic.x = VR_X_POS;
s_controls3.controlschema.generic.y = y;
s_controls3.controlschema.generic.name = "Control Schema:";
s_controls3.controlschema.generic.callback = Controls3_MenuEvent;
s_controls3.controlschema.generic.id = ID_CONTROLSCHEMA;
s_controls3.controlschema.itemnames = s_controlschema;
s_controls3.controlschema.numitems = 2;
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;
@ -313,9 +396,11 @@ static void Controls3_MenuInit( void ) {
Menu_AddItem( &s_controls3.menu, &s_controls3.twohanded ); Menu_AddItem( &s_controls3.menu, &s_controls3.twohanded );
Menu_AddItem( &s_controls3.menu, &s_controls3.directionmode ); Menu_AddItem( &s_controls3.menu, &s_controls3.directionmode );
Menu_AddItem( &s_controls3.menu, &s_controls3.snapturn ); Menu_AddItem( &s_controls3.menu, &s_controls3.snapturn );
Menu_AddItem( &s_controls3.menu, &s_controls3.uturn );
Menu_AddItem( &s_controls3.menu, &s_controls3.righthanded ); Menu_AddItem( &s_controls3.menu, &s_controls3.righthanded );
Menu_AddItem( &s_controls3.menu, &s_controls3.weaponpitch ); Menu_AddItem( &s_controls3.menu, &s_controls3.weaponpitch );
Menu_AddItem( &s_controls3.menu, &s_controls3.weaponselectormode ); Menu_AddItem( &s_controls3.menu, &s_controls3.weaponselectormode );
Menu_AddItem( &s_controls3.menu, &s_controls3.controlschema );
Menu_AddItem( &s_controls3.menu, &s_controls3.back ); Menu_AddItem( &s_controls3.menu, &s_controls3.back );

View file

@ -93,7 +93,61 @@ void VR_InitCvars( void )
Cvar_Get ("vr_weapon_adjustment_11", "0.8,-5.5,6,0,0,0,0", CVAR_ARCHIVE); Cvar_Get ("vr_weapon_adjustment_11", "0.8,-5.5,6,0,0,0,0", CVAR_ARCHIVE);
Cvar_Get ("vr_weapon_adjustment_12", "0.8,-5.5,6,0,0,0,0", CVAR_ARCHIVE); Cvar_Get ("vr_weapon_adjustment_12", "0.8,-5.5,6,0,0,0,0", CVAR_ARCHIVE);
//Button remapping // Control schemas
Cvar_Get ("vr_uturn", "0", CVAR_ARCHIVE);
Cvar_Get ("vr_controlSchema", "0", CVAR_ARCHIVE);
qboolean uturnEnabled = Cvar_VariableValue( "vr_uturn" ) != 0;
int controlSchema = (int)Cvar_VariableValue( "vr_controlSchema" ) % 2;
if (controlSchema == 0) {
Cvar_Get ("vr_button_map_RTHUMBLEFT", "", CVAR_ARCHIVE); // empty ~ turn left
Cvar_Get ("vr_button_map_RTHUMBRIGHT", "", CVAR_ARCHIVE); // empty ~ 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", "+weapon_select", CVAR_ARCHIVE); // weapon selector
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
} else {
// All directions as weapon select (useful for HMD wheel)
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_RTHUMBRIGHT", "+weapon_select", CVAR_ARCHIVE);
Cvar_Get ("vr_button_map_RTHUMBBACKRIGHT", "+weapon_select", CVAR_ARCHIVE);
Cvar_Get ("vr_button_map_RTHUMBBACK", "+weapon_select", CVAR_ARCHIVE);
Cvar_Get ("vr_button_map_RTHUMBBACKLEFT", "+weapon_select", CVAR_ARCHIVE);
Cvar_Get ("vr_button_map_RTHUMBLEFT", "+weapon_select", CVAR_ARCHIVE);
Cvar_Get ("vr_button_map_RTHUMBFORWARDLEFT", "+weapon_select", CVAR_ARCHIVE);
Cvar_Get ("vr_button_map_PRIMARYTHUMBSTICK", "+weapon_select", CVAR_ARCHIVE);
Cvar_Get ("vr_button_map_PRIMARYGRIP", "+alt", CVAR_ARCHIVE); // switch to alt layout
Cvar_Get ("vr_button_map_RTHUMBLEFT_ALT", "", CVAR_ARCHIVE); // empty ~ turn left
Cvar_Get ("vr_button_map_RTHUMBRIGHT_ALT", "", CVAR_ARCHIVE); // empty ~ turn right
Cvar_Get ("vr_button_map_RTHUMBFORWARD_ALT", "weapnext", CVAR_ARCHIVE);
if (uturnEnabled) {
Cvar_Get ("vr_button_map_RTHUMBBACK_ALT", "uturn", CVAR_ARCHIVE);
} else {
Cvar_Get ("vr_button_map_RTHUMBBACK_ALT", "weapprev", CVAR_ARCHIVE);
}
Cvar_Get ("vr_button_map_RTHUMBFORWARDRIGHT_ALT", "", CVAR_ARCHIVE); // unmapped
Cvar_Get ("vr_button_map_RTHUMBBACKRIGHT_ALT", "", CVAR_ARCHIVE); // unmapped
Cvar_Get ("vr_button_map_RTHUMBBACKLEFT_ALT", "", CVAR_ARCHIVE); // unmapped
Cvar_Get ("vr_button_map_RTHUMBFORWARDLEFT_ALT", "", CVAR_ARCHIVE); // unmapped
}
//Remaining button mapping (buttons not affected by schemas)
Cvar_Get ("vr_button_map_A", "+moveup", CVAR_ARCHIVE); // Jump 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_A_ALT", "", CVAR_ARCHIVE); // unmapped
Cvar_Get ("vr_button_map_B", "+movedown", CVAR_ARCHIVE); // Crouch Cvar_Get ("vr_button_map_B", "+movedown", CVAR_ARCHIVE); // Crouch
@ -104,32 +158,14 @@ void VR_InitCvars( void )
Cvar_Get ("vr_button_map_Y_ALT", "", CVAR_ARCHIVE); // unmapped 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", "+scores", CVAR_ARCHIVE); // Scoreboard
Cvar_Get ("vr_button_map_SECONDARYTHUMBSTICK_ALT", "", CVAR_ARCHIVE); // unmapped Cvar_Get ("vr_button_map_SECONDARYTHUMBSTICK_ALT", "", CVAR_ARCHIVE); // unmapped
Cvar_Get ("vr_button_map_PRIMARYTHUMBSTICK", "", CVAR_ARCHIVE); // unmapped
Cvar_Get ("vr_button_map_PRIMARYTHUMBSTICK_ALT", "", CVAR_ARCHIVE); // unmapped Cvar_Get ("vr_button_map_PRIMARYTHUMBSTICK_ALT", "", CVAR_ARCHIVE); // unmapped
Cvar_Get ("vr_button_map_RTHUMBFORWARD", "", 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", "", 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", "uturn", CVAR_ARCHIVE); // U-Turn
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", "", 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
Cvar_Get ("vr_button_map_SECONDARYTRIGGER", "+moveup", CVAR_ARCHIVE); // Also Jump Cvar_Get ("vr_button_map_SECONDARYTRIGGER", "+moveup", CVAR_ARCHIVE); // Also Jump
Cvar_Get ("vr_button_map_SECONDARYTRIGGER_ALT", "", CVAR_ARCHIVE); // unmapped Cvar_Get ("vr_button_map_SECONDARYTRIGGER_ALT", "", CVAR_ARCHIVE); // unmapped
Cvar_Get ("vr_button_map_PRIMARYTRIGGER", "+attack", CVAR_ARCHIVE); // Fire Cvar_Get ("vr_button_map_PRIMARYTRIGGER", "+attack", CVAR_ARCHIVE); // Fire
Cvar_Get ("vr_button_map_PRIMARYTRIGGER_ALT", "", CVAR_ARCHIVE); // unmapped Cvar_Get ("vr_button_map_PRIMARYTRIGGER_ALT", "", CVAR_ARCHIVE); // unmapped
Cvar_Get ("vr_button_map_SECONDARYGRIP", "+weapon_stabilise", CVAR_ARCHIVE); // Weapon stabilisation Cvar_Get ("vr_button_map_SECONDARYGRIP", "+weapon_stabilise", CVAR_ARCHIVE); // Weapon stabilisation
Cvar_Get ("vr_button_map_SECONDARYGRIP_ALT", "", CVAR_ARCHIVE); // unmapped Cvar_Get ("vr_button_map_SECONDARYGRIP_ALT", "", CVAR_ARCHIVE); // unmapped
Cvar_Get ("vr_button_map_PRIMARYGRIP", "+weapon_select", CVAR_ARCHIVE); Cvar_Get ("vr_button_map_PRIMARYGRIP_ALT", "", CVAR_ARCHIVE); // unmapped
Cvar_Get ("vr_button_map_PRIMARYGRIP_ALT", "", CVAR_ARCHIVE);
} }
void VR_Destroy( engine_t* engine ) void VR_Destroy( engine_t* engine )

View file

@ -18,6 +18,7 @@ typedef struct {
qboolean local_server; // used in bg_pmove.c qboolean local_server; // used in bg_pmove.c
vrFollowMode_t follow_mode; vrFollowMode_t follow_mode;
qboolean weapon_select; qboolean weapon_select;
qboolean weapon_select_autoclose;
qboolean smooth_turning; qboolean smooth_turning;
int realign; // used to realign the fake 6DoF playspace in a multiplayer game int realign; // used to realign the fake 6DoF playspace in a multiplayer game

View file

@ -243,7 +243,7 @@ static void VR_processHaptics() {
} }
} }
static void IN_SendButtonAction(const char* action, qboolean pressed) static void IN_SendButtonAction(const char* action, qboolean pressed, qboolean isThumbstickAxis)
{ {
if (action) if (action)
{ {
@ -265,6 +265,7 @@ static void IN_SendButtonAction(const char* action, qboolean pressed)
else if (strcmp(action, "+weapon_select") == 0) else if (strcmp(action, "+weapon_select") == 0)
{ {
vr.weapon_select = pressed; vr.weapon_select = pressed;
vr.weapon_select_autoclose = isThumbstickAxis;
if (!pressed) if (!pressed)
{ {
Cbuf_AddText("weapon_select"); Cbuf_AddText("weapon_select");
@ -350,21 +351,25 @@ void VR_HapticEvent(const char* event, int position, int flags, int intensity, f
static qboolean IN_GetButtonAction(const char* button, char* action) static qboolean IN_GetButtonAction(const char* button, char* action)
{ {
char cvarname[256]; char cvarname[256];
Com_sprintf(cvarname, 256, "vr_button_map_%s%s", button, alt_key_mode_active ? "_ALT" : ""); if (alt_key_mode_active) {
Com_sprintf(cvarname, 256, "vr_button_map_%s_ALT", button);
} else {
Com_sprintf(cvarname, 256, "vr_button_map_%s", button);
}
char * val = Cvar_VariableString(cvarname); char * val = Cvar_VariableString(cvarname);
if (val && strlen(val) > 0) if (val && strlen(val) > 0)
{ {
Com_sprintf(action, 256, "%s", val); Com_sprintf(action, 256, "%s", val);
return qtrue; return qtrue;
} }
else if (alt_key_mode_active)
//If we didn't find something for this button and the alt key is active, then see if the un-alt key has a function
if (alt_key_mode_active)
{ {
// No action found for buttom ALT mapping. Check if we are not
// holding ALT key itself (there is no ALT function for ALT)
Com_sprintf(cvarname, 256, "vr_button_map_%s", button); Com_sprintf(cvarname, 256, "vr_button_map_%s", button);
char * val = Cvar_VariableString(cvarname); char * val = Cvar_VariableString(cvarname);
if (val && strlen(val) > 0) if (val && strcmp(val, "+alt") == 0) {
{
Com_sprintf(action, 256, "%s", val); Com_sprintf(action, 256, "%s", val);
return qtrue; return qtrue;
} }
@ -526,11 +531,11 @@ static void IN_VRJoystick( qboolean isRightController, float joystickX, float jo
// stop left & right // stop left & right
vr.smooth_turning = false; vr.smooth_turning = false;
if ((controller->axisButtons & VR_TOUCH_AXIS_LEFT) && IN_GetButtonAction("RTHUMBLEFT", action)) { if ((controller->axisButtons & VR_TOUCH_AXIS_LEFT) && IN_GetButtonAction("RTHUMBLEFT", action)) {
IN_SendButtonAction(action, qfalse); IN_SendButtonAction(action, qfalse, qtrue);
} }
controller->axisButtons &= ~VR_TOUCH_AXIS_LEFT; controller->axisButtons &= ~VR_TOUCH_AXIS_LEFT;
if ((controller->axisButtons & VR_TOUCH_AXIS_RIGHT) && IN_GetButtonAction("RTHUMBRIGHT", action)) { if ((controller->axisButtons & VR_TOUCH_AXIS_RIGHT) && IN_GetButtonAction("RTHUMBRIGHT", action)) {
IN_SendButtonAction(action, qfalse); IN_SendButtonAction(action, qfalse, qtrue);
} }
controller->axisButtons &= ~VR_TOUCH_AXIS_RIGHT; controller->axisButtons &= ~VR_TOUCH_AXIS_RIGHT;
@ -538,19 +543,19 @@ static void IN_VRJoystick( qboolean isRightController, float joystickX, float jo
if (joystickX < -releasedThreshold) { if (joystickX < -releasedThreshold) {
// stop up // stop up
if ((controller->axisButtons & VR_TOUCH_AXIS_UP) && IN_GetButtonAction("RTHUMBFORWARD", action)) { if ((controller->axisButtons & VR_TOUCH_AXIS_UP) && IN_GetButtonAction("RTHUMBFORWARD", action)) {
IN_SendButtonAction(action, qfalse); IN_SendButtonAction(action, qfalse, qtrue);
} }
controller->axisButtons &= ~VR_TOUCH_AXIS_UP; controller->axisButtons &= ~VR_TOUCH_AXIS_UP;
// stop up-right // stop up-right
if ((controller->axisButtons & VR_TOUCH_AXIS_UPRIGHT) && IN_GetButtonAction("RTHUMBFORWARDRIGHT", action)) { if ((controller->axisButtons & VR_TOUCH_AXIS_UPRIGHT) && IN_GetButtonAction("RTHUMBFORWARDRIGHT", action)) {
IN_SendButtonAction(action, qfalse); IN_SendButtonAction(action, qfalse, qtrue);
} }
controller->axisButtons &= ~VR_TOUCH_AXIS_UPRIGHT; controller->axisButtons &= ~VR_TOUCH_AXIS_UPRIGHT;
// start up-left // start up-left
if (!(controller->axisButtons & VR_TOUCH_AXIS_UPLEFT)) { if (!(controller->axisButtons & VR_TOUCH_AXIS_UPLEFT)) {
controller->axisButtons |= VR_TOUCH_AXIS_UPLEFT; controller->axisButtons |= VR_TOUCH_AXIS_UPLEFT;
if (IN_GetButtonAction("RTHUMBFORWARDLEFT", action)) { if (IN_GetButtonAction("RTHUMBFORWARDLEFT", action)) {
IN_SendButtonAction(action, qtrue); IN_SendButtonAction(action, qtrue, qtrue);
} }
} }
@ -558,19 +563,19 @@ static void IN_VRJoystick( qboolean isRightController, float joystickX, float jo
} else if (joystickX > releasedThreshold) { } else if (joystickX > releasedThreshold) {
// stop up // stop up
if ((controller->axisButtons & VR_TOUCH_AXIS_UP) && IN_GetButtonAction("RTHUMBFORWARD", action)) { if ((controller->axisButtons & VR_TOUCH_AXIS_UP) && IN_GetButtonAction("RTHUMBFORWARD", action)) {
IN_SendButtonAction(action, qfalse); IN_SendButtonAction(action, qfalse, qtrue);
} }
controller->axisButtons &= ~VR_TOUCH_AXIS_UP; controller->axisButtons &= ~VR_TOUCH_AXIS_UP;
// stop up-left // stop up-left
if ((controller->axisButtons & VR_TOUCH_AXIS_UPLEFT) && IN_GetButtonAction("RTHUMBFORWARDLEFT", action)) { if ((controller->axisButtons & VR_TOUCH_AXIS_UPLEFT) && IN_GetButtonAction("RTHUMBFORWARDLEFT", action)) {
IN_SendButtonAction(action, qfalse); IN_SendButtonAction(action, qfalse, qtrue);
} }
controller->axisButtons &= ~VR_TOUCH_AXIS_UPLEFT; controller->axisButtons &= ~VR_TOUCH_AXIS_UPLEFT;
// start up-right // start up-right
if (!(controller->axisButtons & VR_TOUCH_AXIS_UPRIGHT)) { if (!(controller->axisButtons & VR_TOUCH_AXIS_UPRIGHT)) {
controller->axisButtons |= VR_TOUCH_AXIS_UPRIGHT; controller->axisButtons |= VR_TOUCH_AXIS_UPRIGHT;
if (IN_GetButtonAction("RTHUMBFORWARDRIGHT", action)) { if (IN_GetButtonAction("RTHUMBFORWARDRIGHT", action)) {
IN_SendButtonAction(action, qtrue); IN_SendButtonAction(action, qtrue, qtrue);
} }
} }
@ -578,19 +583,19 @@ static void IN_VRJoystick( qboolean isRightController, float joystickX, float jo
} else { } else {
// stop up-left // stop up-left
if ((controller->axisButtons & VR_TOUCH_AXIS_UPLEFT) && IN_GetButtonAction("RTHUMBFORWARDLEFT", action)) { if ((controller->axisButtons & VR_TOUCH_AXIS_UPLEFT) && IN_GetButtonAction("RTHUMBFORWARDLEFT", action)) {
IN_SendButtonAction(action, qfalse); IN_SendButtonAction(action, qfalse, qtrue);
} }
controller->axisButtons &= ~VR_TOUCH_AXIS_UPLEFT; controller->axisButtons &= ~VR_TOUCH_AXIS_UPLEFT;
// stop up-right // stop up-right
if ((controller->axisButtons & VR_TOUCH_AXIS_UPRIGHT) && IN_GetButtonAction("RTHUMBFORWARDRIGHT", action)) { if ((controller->axisButtons & VR_TOUCH_AXIS_UPRIGHT) && IN_GetButtonAction("RTHUMBFORWARDRIGHT", action)) {
IN_SendButtonAction(action, qfalse); IN_SendButtonAction(action, qfalse, qtrue);
} }
controller->axisButtons &= ~VR_TOUCH_AXIS_UPRIGHT; controller->axisButtons &= ~VR_TOUCH_AXIS_UPRIGHT;
// start up // start up
if (!(controller->axisButtons & VR_TOUCH_AXIS_UP) && joystickY > pressedThreshold) { if (!(controller->axisButtons & VR_TOUCH_AXIS_UP) && joystickY > pressedThreshold) {
controller->axisButtons |= VR_TOUCH_AXIS_UP; controller->axisButtons |= VR_TOUCH_AXIS_UP;
if (IN_GetButtonAction("RTHUMBFORWARD", action)) { if (IN_GetButtonAction("RTHUMBFORWARD", action)) {
IN_SendButtonAction(action, qtrue); IN_SendButtonAction(action, qtrue, qtrue);
} }
} }
} }
@ -601,11 +606,11 @@ static void IN_VRJoystick( qboolean isRightController, float joystickX, float jo
// stop left & right // stop left & right
vr.smooth_turning = false; vr.smooth_turning = false;
if ((controller->axisButtons & VR_TOUCH_AXIS_LEFT) && IN_GetButtonAction("RTHUMBLEFT", action)) { if ((controller->axisButtons & VR_TOUCH_AXIS_LEFT) && IN_GetButtonAction("RTHUMBLEFT", action)) {
IN_SendButtonAction(action, qfalse); IN_SendButtonAction(action, qfalse, qtrue);
} }
controller->axisButtons &= ~VR_TOUCH_AXIS_LEFT; controller->axisButtons &= ~VR_TOUCH_AXIS_LEFT;
if ((controller->axisButtons & VR_TOUCH_AXIS_RIGHT) && IN_GetButtonAction("RTHUMBRIGHT", action)) { if ((controller->axisButtons & VR_TOUCH_AXIS_RIGHT) && IN_GetButtonAction("RTHUMBRIGHT", action)) {
IN_SendButtonAction(action, qfalse); IN_SendButtonAction(action, qfalse, qtrue);
} }
controller->axisButtons &= ~VR_TOUCH_AXIS_RIGHT; controller->axisButtons &= ~VR_TOUCH_AXIS_RIGHT;
@ -613,19 +618,19 @@ static void IN_VRJoystick( qboolean isRightController, float joystickX, float jo
if (joystickX < -releasedThreshold) { if (joystickX < -releasedThreshold) {
// stop down // stop down
if ((controller->axisButtons & VR_TOUCH_AXIS_DOWN) && IN_GetButtonAction("RTHUMBBACK", action)) { if ((controller->axisButtons & VR_TOUCH_AXIS_DOWN) && IN_GetButtonAction("RTHUMBBACK", action)) {
IN_SendButtonAction(action, qfalse); IN_SendButtonAction(action, qfalse, qtrue);
} }
controller->axisButtons &= ~VR_TOUCH_AXIS_DOWN; controller->axisButtons &= ~VR_TOUCH_AXIS_DOWN;
// stop down-right // stop down-right
if ((controller->axisButtons & VR_TOUCH_AXIS_DOWNRIGHT) && IN_GetButtonAction("RTHUMBBACKRIGHT", action)) { if ((controller->axisButtons & VR_TOUCH_AXIS_DOWNRIGHT) && IN_GetButtonAction("RTHUMBBACKRIGHT", action)) {
IN_SendButtonAction(action, qfalse); IN_SendButtonAction(action, qfalse, qtrue);
} }
controller->axisButtons &= ~VR_TOUCH_AXIS_DOWNRIGHT; controller->axisButtons &= ~VR_TOUCH_AXIS_DOWNRIGHT;
// start down-left // start down-left
if (!(controller->axisButtons & VR_TOUCH_AXIS_DOWNLEFT)) { if (!(controller->axisButtons & VR_TOUCH_AXIS_DOWNLEFT)) {
controller->axisButtons |= VR_TOUCH_AXIS_DOWNLEFT; controller->axisButtons |= VR_TOUCH_AXIS_DOWNLEFT;
if (IN_GetButtonAction("RTHUMBBACKLEFT", action)) { if (IN_GetButtonAction("RTHUMBBACKLEFT", action)) {
IN_SendButtonAction(action, qtrue); IN_SendButtonAction(action, qtrue, qtrue);
} }
} }
@ -633,19 +638,19 @@ static void IN_VRJoystick( qboolean isRightController, float joystickX, float jo
} else if (joystickX > releasedThreshold) { } else if (joystickX > releasedThreshold) {
// stop down // stop down
if ((controller->axisButtons & VR_TOUCH_AXIS_DOWN) && IN_GetButtonAction("RTHUMBBACK", action)) { if ((controller->axisButtons & VR_TOUCH_AXIS_DOWN) && IN_GetButtonAction("RTHUMBBACK", action)) {
IN_SendButtonAction(action, qfalse); IN_SendButtonAction(action, qfalse, qtrue);
} }
controller->axisButtons &= ~VR_TOUCH_AXIS_DOWN; controller->axisButtons &= ~VR_TOUCH_AXIS_DOWN;
// stop down-left // stop down-left
if ((controller->axisButtons & VR_TOUCH_AXIS_DOWNLEFT) && IN_GetButtonAction("RTHUMBBACKLEFT", action)) { if ((controller->axisButtons & VR_TOUCH_AXIS_DOWNLEFT) && IN_GetButtonAction("RTHUMBBACKLEFT", action)) {
IN_SendButtonAction(action, qfalse); IN_SendButtonAction(action, qfalse, qtrue);
} }
controller->axisButtons &= ~VR_TOUCH_AXIS_DOWNLEFT; controller->axisButtons &= ~VR_TOUCH_AXIS_DOWNLEFT;
// start down-right // start down-right
if (!(controller->axisButtons & VR_TOUCH_AXIS_DOWNRIGHT)) { if (!(controller->axisButtons & VR_TOUCH_AXIS_DOWNRIGHT)) {
controller->axisButtons |= VR_TOUCH_AXIS_DOWNRIGHT; controller->axisButtons |= VR_TOUCH_AXIS_DOWNRIGHT;
if (IN_GetButtonAction("RTHUMBBACKRIGHT", action)) { if (IN_GetButtonAction("RTHUMBBACKRIGHT", action)) {
IN_SendButtonAction(action, qtrue); IN_SendButtonAction(action, qtrue, qtrue);
} }
} }
@ -653,19 +658,19 @@ static void IN_VRJoystick( qboolean isRightController, float joystickX, float jo
} else { } else {
// stop down-left // stop down-left
if ((controller->axisButtons & VR_TOUCH_AXIS_DOWNLEFT) && IN_GetButtonAction("RTHUMBBACKLEFT", action)) { if ((controller->axisButtons & VR_TOUCH_AXIS_DOWNLEFT) && IN_GetButtonAction("RTHUMBBACKLEFT", action)) {
IN_SendButtonAction(action, qfalse); IN_SendButtonAction(action, qfalse, qtrue);
} }
controller->axisButtons &= ~VR_TOUCH_AXIS_DOWNLEFT; controller->axisButtons &= ~VR_TOUCH_AXIS_DOWNLEFT;
// stop down-right // stop down-right
if ((controller->axisButtons & VR_TOUCH_AXIS_DOWNRIGHT) && IN_GetButtonAction("RTHUMBBACKRIGHT", action)) { if ((controller->axisButtons & VR_TOUCH_AXIS_DOWNRIGHT) && IN_GetButtonAction("RTHUMBBACKRIGHT", action)) {
IN_SendButtonAction(action, qfalse); IN_SendButtonAction(action, qfalse, qtrue);
} }
controller->axisButtons &= ~VR_TOUCH_AXIS_DOWNRIGHT; controller->axisButtons &= ~VR_TOUCH_AXIS_DOWNRIGHT;
// start down // start down
if (!(controller->axisButtons & VR_TOUCH_AXIS_DOWN) && joystickY < -pressedThreshold) { if (!(controller->axisButtons & VR_TOUCH_AXIS_DOWN) && joystickY < -pressedThreshold) {
controller->axisButtons |= VR_TOUCH_AXIS_DOWN; controller->axisButtons |= VR_TOUCH_AXIS_DOWN;
if (IN_GetButtonAction("RTHUMBBACK", action)) { if (IN_GetButtonAction("RTHUMBBACK", action)) {
IN_SendButtonAction(action, qtrue); IN_SendButtonAction(action, qtrue, qtrue);
} }
} }
} }
@ -675,32 +680,32 @@ static void IN_VRJoystick( qboolean isRightController, float joystickX, float jo
// stop up-left // stop up-left
if ((controller->axisButtons & VR_TOUCH_AXIS_UPLEFT) && IN_GetButtonAction("RTHUMBFORWARDLEFT", action)) { if ((controller->axisButtons & VR_TOUCH_AXIS_UPLEFT) && IN_GetButtonAction("RTHUMBFORWARDLEFT", action)) {
IN_SendButtonAction(action, qfalse); IN_SendButtonAction(action, qfalse, qtrue);
} }
controller->axisButtons &= ~VR_TOUCH_AXIS_UPLEFT; controller->axisButtons &= ~VR_TOUCH_AXIS_UPLEFT;
// stop up // stop up
if ((controller->axisButtons & VR_TOUCH_AXIS_UP) && IN_GetButtonAction("RTHUMBFORWARD", action)) { if ((controller->axisButtons & VR_TOUCH_AXIS_UP) && IN_GetButtonAction("RTHUMBFORWARD", action)) {
IN_SendButtonAction(action, qfalse); IN_SendButtonAction(action, qfalse, qtrue);
} }
controller->axisButtons &= ~VR_TOUCH_AXIS_UP; controller->axisButtons &= ~VR_TOUCH_AXIS_UP;
// stop up-right // stop up-right
if ((controller->axisButtons & VR_TOUCH_AXIS_UPRIGHT) && IN_GetButtonAction("RTHUMBFORWARDRIGHT", action)) { if ((controller->axisButtons & VR_TOUCH_AXIS_UPRIGHT) && IN_GetButtonAction("RTHUMBFORWARDRIGHT", action)) {
IN_SendButtonAction(action, qfalse); IN_SendButtonAction(action, qfalse, qtrue);
} }
controller->axisButtons &= ~VR_TOUCH_AXIS_UPRIGHT; controller->axisButtons &= ~VR_TOUCH_AXIS_UPRIGHT;
// stop down-left // stop down-left
if ((controller->axisButtons & VR_TOUCH_AXIS_DOWNLEFT) && IN_GetButtonAction("RTHUMBBACKLEFT", action)) { if ((controller->axisButtons & VR_TOUCH_AXIS_DOWNLEFT) && IN_GetButtonAction("RTHUMBBACKLEFT", action)) {
IN_SendButtonAction(action, qfalse); IN_SendButtonAction(action, qfalse, qtrue);
} }
controller->axisButtons &= ~VR_TOUCH_AXIS_DOWNLEFT; controller->axisButtons &= ~VR_TOUCH_AXIS_DOWNLEFT;
// stop down // stop down
if ((controller->axisButtons & VR_TOUCH_AXIS_DOWN) && IN_GetButtonAction("RTHUMBBACK", action)) { if ((controller->axisButtons & VR_TOUCH_AXIS_DOWN) && IN_GetButtonAction("RTHUMBBACK", action)) {
IN_SendButtonAction(action, qfalse); IN_SendButtonAction(action, qfalse, qtrue);
} }
controller->axisButtons &= ~VR_TOUCH_AXIS_DOWN; controller->axisButtons &= ~VR_TOUCH_AXIS_DOWN;
// stop down-right // stop down-right
if ((controller->axisButtons & VR_TOUCH_AXIS_DOWNRIGHT) && IN_GetButtonAction("RTHUMBBACKRIGHT", action)) { if ((controller->axisButtons & VR_TOUCH_AXIS_DOWNRIGHT) && IN_GetButtonAction("RTHUMBBACKRIGHT", action)) {
IN_SendButtonAction(action, qfalse); IN_SendButtonAction(action, qfalse, qtrue);
} }
controller->axisButtons &= ~VR_TOUCH_AXIS_DOWNRIGHT; controller->axisButtons &= ~VR_TOUCH_AXIS_DOWNRIGHT;
@ -711,7 +716,7 @@ static void IN_VRJoystick( qboolean isRightController, float joystickX, float jo
if (IN_GetButtonAction("RTHUMBLEFT", action)) { if (IN_GetButtonAction("RTHUMBLEFT", action)) {
vr.smooth_turning = false; vr.smooth_turning = false;
if (!(controller->axisButtons & VR_TOUCH_AXIS_LEFT)) { if (!(controller->axisButtons & VR_TOUCH_AXIS_LEFT)) {
IN_SendButtonAction(action, qtrue); IN_SendButtonAction(action, qtrue, qtrue);
} }
controller->axisButtons |= VR_TOUCH_AXIS_LEFT; controller->axisButtons |= VR_TOUCH_AXIS_LEFT;
@ -740,7 +745,7 @@ static void IN_VRJoystick( qboolean isRightController, float joystickX, float jo
vr.smooth_turning = false; vr.smooth_turning = false;
} }
if ((controller->axisButtons & VR_TOUCH_AXIS_LEFT) && IN_GetButtonAction("RTHUMBLEFT", action)) { if ((controller->axisButtons & VR_TOUCH_AXIS_LEFT) && IN_GetButtonAction("RTHUMBLEFT", action)) {
IN_SendButtonAction(action, qfalse); IN_SendButtonAction(action, qfalse, qtrue);
} }
controller->axisButtons &= ~VR_TOUCH_AXIS_LEFT; controller->axisButtons &= ~VR_TOUCH_AXIS_LEFT;
} }
@ -752,7 +757,7 @@ static void IN_VRJoystick( qboolean isRightController, float joystickX, float jo
if (IN_GetButtonAction("RTHUMBRIGHT", action)) { if (IN_GetButtonAction("RTHUMBRIGHT", action)) {
vr.smooth_turning = false; vr.smooth_turning = false;
if (!(controller->axisButtons & VR_TOUCH_AXIS_RIGHT)) { if (!(controller->axisButtons & VR_TOUCH_AXIS_RIGHT)) {
IN_SendButtonAction(action, qtrue); IN_SendButtonAction(action, qtrue, qtrue);
} }
controller->axisButtons |= VR_TOUCH_AXIS_RIGHT; controller->axisButtons |= VR_TOUCH_AXIS_RIGHT;
@ -781,7 +786,7 @@ static void IN_VRJoystick( qboolean isRightController, float joystickX, float jo
vr.smooth_turning = false; vr.smooth_turning = false;
} }
if ((controller->axisButtons & VR_TOUCH_AXIS_RIGHT) && IN_GetButtonAction("RTHUMBRIGHT", action)) { if ((controller->axisButtons & VR_TOUCH_AXIS_RIGHT) && IN_GetButtonAction("RTHUMBRIGHT", action)) {
IN_SendButtonAction(action, qfalse); IN_SendButtonAction(action, qfalse, qtrue);
} }
controller->axisButtons &= ~VR_TOUCH_AXIS_RIGHT; controller->axisButtons &= ~VR_TOUCH_AXIS_RIGHT;
} }
@ -828,7 +833,7 @@ static void IN_VRTriggers( qboolean isRightController, float index ) {
controller->axisButtons |= VR_TOUCH_AXIS_TRIGGER_INDEX; controller->axisButtons |= VR_TOUCH_AXIS_TRIGGER_INDEX;
if (IN_GetButtonAction("PRIMARYTRIGGER", action)) if (IN_GetButtonAction("PRIMARYTRIGGER", action))
{ {
IN_SendButtonAction(action, qtrue); IN_SendButtonAction(action, qtrue, qfalse);
} }
} }
else if ((controller->axisButtons & VR_TOUCH_AXIS_TRIGGER_INDEX) && else if ((controller->axisButtons & VR_TOUCH_AXIS_TRIGGER_INDEX) &&
@ -837,7 +842,7 @@ static void IN_VRTriggers( qboolean isRightController, float index ) {
controller->axisButtons &= ~VR_TOUCH_AXIS_TRIGGER_INDEX; controller->axisButtons &= ~VR_TOUCH_AXIS_TRIGGER_INDEX;
if (IN_GetButtonAction("PRIMARYTRIGGER", action)) if (IN_GetButtonAction("PRIMARYTRIGGER", action))
{ {
IN_SendButtonAction(action, qfalse); IN_SendButtonAction(action, qfalse, qfalse);
} }
} }
} }
@ -851,7 +856,7 @@ static void IN_VRTriggers( qboolean isRightController, float index ) {
controller->axisButtons |= VR_TOUCH_AXIS_TRIGGER_INDEX; controller->axisButtons |= VR_TOUCH_AXIS_TRIGGER_INDEX;
if (IN_GetButtonAction("SECONDARYTRIGGER", action)) if (IN_GetButtonAction("SECONDARYTRIGGER", action))
{ {
IN_SendButtonAction(action, qtrue); IN_SendButtonAction(action, qtrue, qfalse);
} }
} }
else if ((controller->axisButtons & VR_TOUCH_AXIS_TRIGGER_INDEX) && else if ((controller->axisButtons & VR_TOUCH_AXIS_TRIGGER_INDEX) &&
@ -860,7 +865,7 @@ static void IN_VRTriggers( qboolean isRightController, float index ) {
controller->axisButtons &= ~VR_TOUCH_AXIS_TRIGGER_INDEX; controller->axisButtons &= ~VR_TOUCH_AXIS_TRIGGER_INDEX;
if (IN_GetButtonAction("SECONDARYTRIGGER", action)) if (IN_GetButtonAction("SECONDARYTRIGGER", action))
{ {
IN_SendButtonAction(action, qfalse); IN_SendButtonAction(action, qfalse, qfalse);
} }
} }
} }
@ -887,7 +892,7 @@ static void IN_VRButtonsChanged( qboolean isRightController, uint32_t buttons )
{ {
if (IN_GetButtonAction("SECONDARYGRIP", action)) if (IN_GetButtonAction("SECONDARYGRIP", action))
{ {
IN_SendButtonAction(action, qtrue); IN_SendButtonAction(action, qtrue, qfalse);
} }
} }
else if (!(buttons & ovrButton_GripTrigger) && else if (!(buttons & ovrButton_GripTrigger) &&
@ -895,7 +900,7 @@ static void IN_VRButtonsChanged( qboolean isRightController, uint32_t buttons )
{ {
if (IN_GetButtonAction("SECONDARYGRIP", action)) if (IN_GetButtonAction("SECONDARYGRIP", action))
{ {
IN_SendButtonAction(action, qfalse); IN_SendButtonAction(action, qfalse, qfalse);
} }
} }
} }
@ -905,7 +910,7 @@ static void IN_VRButtonsChanged( qboolean isRightController, uint32_t buttons )
{ {
if (IN_GetButtonAction("PRIMARYGRIP", action)) if (IN_GetButtonAction("PRIMARYGRIP", action))
{ {
IN_SendButtonAction(action, qtrue); IN_SendButtonAction(action, qtrue, qfalse);
} }
} }
else if (!(buttons & ovrButton_GripTrigger) && else if (!(buttons & ovrButton_GripTrigger) &&
@ -913,7 +918,7 @@ static void IN_VRButtonsChanged( qboolean isRightController, uint32_t buttons )
{ {
if (IN_GetButtonAction("PRIMARYGRIP", action)) if (IN_GetButtonAction("PRIMARYGRIP", action))
{ {
IN_SendButtonAction(action, qfalse); IN_SendButtonAction(action, qfalse, qfalse);
} }
} }
} }
@ -924,14 +929,14 @@ static void IN_VRButtonsChanged( qboolean isRightController, uint32_t buttons )
if ((buttons & ovrButton_LThumb) && !(controller->buttons & ovrButton_LThumb)) { if ((buttons & ovrButton_LThumb) && !(controller->buttons & ovrButton_LThumb)) {
if (IN_GetButtonAction("SECONDARYTHUMBSTICK", action)) if (IN_GetButtonAction("SECONDARYTHUMBSTICK", action))
{ {
IN_SendButtonAction(action, qtrue); IN_SendButtonAction(action, qtrue, qfalse);
} }
vr.realign = 3; vr.realign = 3;
} else if (!(buttons & ovrButton_LThumb) && (controller->buttons & ovrButton_LThumb)) { } else if (!(buttons & ovrButton_LThumb) && (controller->buttons & ovrButton_LThumb)) {
if (IN_GetButtonAction("SECONDARYTHUMBSTICK", action)) if (IN_GetButtonAction("SECONDARYTHUMBSTICK", action))
{ {
IN_SendButtonAction(action, qfalse); IN_SendButtonAction(action, qfalse, qfalse);
} }
} }
} }
@ -940,12 +945,12 @@ static void IN_VRButtonsChanged( qboolean isRightController, uint32_t buttons )
if ((buttons & ovrButton_RThumb) && !(controller->buttons & ovrButton_RThumb)) { if ((buttons & ovrButton_RThumb) && !(controller->buttons & ovrButton_RThumb)) {
if (IN_GetButtonAction("PRIMARYTHUMBSTICK", action)) if (IN_GetButtonAction("PRIMARYTHUMBSTICK", action))
{ {
IN_SendButtonAction(action, qtrue); IN_SendButtonAction(action, qtrue, qfalse);
} }
} else if (!(buttons & ovrButton_RThumb) && (controller->buttons & ovrButton_RThumb)) { } else if (!(buttons & ovrButton_RThumb) && (controller->buttons & ovrButton_RThumb)) {
if (IN_GetButtonAction("PRIMARYTHUMBSTICK", action)) if (IN_GetButtonAction("PRIMARYTHUMBSTICK", action))
{ {
IN_SendButtonAction(action, qfalse); IN_SendButtonAction(action, qfalse, qfalse);
} }
} }
} }
@ -961,7 +966,7 @@ static void IN_VRButtonsChanged( qboolean isRightController, uint32_t buttons )
{ {
if (IN_GetButtonAction("A", action)) if (IN_GetButtonAction("A", action))
{ {
IN_SendButtonAction(action, qtrue); IN_SendButtonAction(action, qtrue, qfalse);
} }
} }
} }
@ -969,7 +974,7 @@ static void IN_VRButtonsChanged( qboolean isRightController, uint32_t buttons )
{ {
if (IN_GetButtonAction("A", action) && !(cl.snap.ps.pm_flags & PMF_FOLLOW)) if (IN_GetButtonAction("A", action) && !(cl.snap.ps.pm_flags & PMF_FOLLOW))
{ {
IN_SendButtonAction(action, qfalse); IN_SendButtonAction(action, qfalse, qfalse);
} }
} }
@ -977,12 +982,12 @@ static void IN_VRButtonsChanged( qboolean isRightController, uint32_t buttons )
if ((buttons & ovrButton_B) && !(controller->buttons & ovrButton_B)) { if ((buttons & ovrButton_B) && !(controller->buttons & ovrButton_B)) {
if (IN_GetButtonAction("B", action)) if (IN_GetButtonAction("B", action))
{ {
IN_SendButtonAction(action, qtrue); IN_SendButtonAction(action, qtrue, qfalse);
} }
} else if (!(buttons & ovrButton_B) && (controller->buttons & ovrButton_B)) { } else if (!(buttons & ovrButton_B) && (controller->buttons & ovrButton_B)) {
if (IN_GetButtonAction("B", action)) if (IN_GetButtonAction("B", action))
{ {
IN_SendButtonAction(action, qfalse); IN_SendButtonAction(action, qfalse, qfalse);
} }
} }
@ -998,7 +1003,7 @@ static void IN_VRButtonsChanged( qboolean isRightController, uint32_t buttons )
{ {
if (IN_GetButtonAction("X", action)) if (IN_GetButtonAction("X", action))
{ {
IN_SendButtonAction(action, qtrue); IN_SendButtonAction(action, qtrue, qfalse);
} }
} }
} }
@ -1006,7 +1011,7 @@ static void IN_VRButtonsChanged( qboolean isRightController, uint32_t buttons )
{ {
if (IN_GetButtonAction("X", action) && !(cl.snap.ps.pm_flags & PMF_FOLLOW)) if (IN_GetButtonAction("X", action) && !(cl.snap.ps.pm_flags & PMF_FOLLOW))
{ {
IN_SendButtonAction(action, qfalse); IN_SendButtonAction(action, qfalse, qfalse);
} }
} }
@ -1014,12 +1019,12 @@ static void IN_VRButtonsChanged( qboolean isRightController, uint32_t buttons )
if ((buttons & ovrButton_Y) && !(controller->buttons & ovrButton_Y)) { if ((buttons & ovrButton_Y) && !(controller->buttons & ovrButton_Y)) {
if (IN_GetButtonAction("Y", action)) if (IN_GetButtonAction("Y", action))
{ {
IN_SendButtonAction(action, qtrue); IN_SendButtonAction(action, qtrue, qfalse);
} }
} else if (!(buttons & ovrButton_Y) && (controller->buttons & ovrButton_Y)) { } else if (!(buttons & ovrButton_Y) && (controller->buttons & ovrButton_Y)) {
if (IN_GetButtonAction("Y", action)) if (IN_GetButtonAction("Y", action))
{ {
IN_SendButtonAction(action, qfalse); IN_SendButtonAction(action, qfalse, qfalse);
} }
} }