Allow to override smooth/snap turn with action; set default weapon mapping

This commit is contained in:
Petr Bartos 2022-03-07 09:27:28 +01:00
parent bb164f3091
commit 81e0947c86
3 changed files with 119 additions and 61 deletions

View File

@ -28,17 +28,21 @@ set vr_button_map_SECONDARYTHUMBSTICK_ALT ""
set vr_button_map_PRIMARYTHUMBSTICK ""
set vr_button_map_PRIMARYTHUMBSTICK_ALT ""
set vr_button_map_RTHUMBFORWARD "+weapon_select"
set vr_button_map_RTHUMBFORWARD_ALT ""
set vr_button_map_RTHUMBFORWARDLEFT ""
set vr_button_map_RTHUMBFORWARDLEFT_ALT ""
set vr_button_map_RTHUMBFORWARD_ALT "weapon 3"
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_RTHUMBFORWARDRIGHT_ALT "weapon 2"
set vr_button_map_RTHUMBRIGHT ""
set vr_button_map_RTHUMBRIGHT_ALT "weapon 5"
set vr_button_map_RTHUMBBACKRIGHT ""
set vr_button_map_RTHUMBBACKRIGHT_ALT ""
set vr_button_map_RTHUMBBACKRIGHT_ALT "weapon 4"
set vr_button_map_RTHUMBBACK ""
set vr_button_map_RTHUMBBACK_ALT "weapon 7"
set vr_button_map_RTHUMBBACKLEFT ""
set vr_button_map_RTHUMBBACKLEFT_ALT "weapon 8"
set vr_button_map_RTHUMBLEFT ""
set vr_button_map_RTHUMBLEFT_ALT "weapon 6"
set vr_button_map_RTHUMBFORWARDLEFT ""
set vr_button_map_RTHUMBFORWARDLEFT_ALT "weapon 9"
set vr_button_map_SECONDARYTRIGGER "+moveup"
set vr_button_map_SECONDARYTRIGGER_ALT ""
set vr_button_map_PRIMARYTRIGGER "+attack"

View File

@ -100,18 +100,22 @@ void VR_InitCvars( void )
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", "weapon 1", CVAR_ARCHIVE); // Switch to gauntlet
Cvar_Get ("vr_button_map_RTHUMBFORWARD", "weapnext", CVAR_ARCHIVE); //Next Weapon
Cvar_Get ("vr_button_map_RTHUMBFORWARD", "", CVAR_ARCHIVE); // unmapped
Cvar_Get ("vr_button_map_RTHUMBFORWARD_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_RTHUMBFORWARDRIGHT", "", CVAR_ARCHIVE); // unmapped
Cvar_Get ("vr_button_map_RTHUMBFORWARDRIGHT_ALT", "", CVAR_ARCHIVE); // unmapped
Cvar_Get ("vr_button_map_RTHUMBBACK", "weapprev", CVAR_ARCHIVE); // Previous Weapon
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", "", 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_RTHUMBBACKRIGHT", "", CVAR_ARCHIVE); // unmapped
Cvar_Get ("vr_button_map_RTHUMBBACKRIGHT_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_ALT", "", CVAR_ARCHIVE); // unmapped
Cvar_Get ("vr_button_map_PRIMARYTRIGGER", "+attack", CVAR_ARCHIVE); // Fire

View File

@ -22,13 +22,13 @@
enum {
VR_TOUCH_AXIS_UP = 1 << 0,
VR_TOUCH_AXIS_UPLEFT = 1 << 1,
VR_TOUCH_AXIS_UPRIGHT = 1 << 2,
VR_TOUCH_AXIS_DOWN = 1 << 3,
VR_TOUCH_AXIS_DOWNLEFT = 1 << 4,
VR_TOUCH_AXIS_DOWNRIGHT = 1 << 5,
VR_TOUCH_AXIS_UPRIGHT = 1 << 1,
VR_TOUCH_AXIS_RIGHT = 1 << 2,
VR_TOUCH_AXIS_DOWNRIGHT = 1 << 3,
VR_TOUCH_AXIS_DOWN = 1 << 4,
VR_TOUCH_AXIS_DOWNLEFT = 1 << 5,
VR_TOUCH_AXIS_LEFT = 1 << 6,
VR_TOUCH_AXIS_RIGHT = 1 << 7,
VR_TOUCH_AXIS_UPLEFT = 1 << 7,
VR_TOUCH_AXIS_TRIGGER_INDEX = 1 << 8,
};
@ -506,7 +506,13 @@ static void IN_VRJoystick( qboolean isRightController, float joystickX, float jo
if (joystickY > releasedThreshold) {
// stop left & right
if ((controller->axisButtons & VR_TOUCH_AXIS_LEFT) && IN_GetButtonAction("RTHUMBLEFT", action)) {
IN_SendButtonAction(action, qfalse);
}
controller->axisButtons &= ~VR_TOUCH_AXIS_LEFT;
if ((controller->axisButtons & VR_TOUCH_AXIS_RIGHT) && IN_GetButtonAction("RTHUMBRIGHT", action)) {
IN_SendButtonAction(action, qfalse);
}
controller->axisButtons &= ~VR_TOUCH_AXIS_RIGHT;
// up-left (use release threshold to be more sensitive)
@ -574,7 +580,13 @@ static void IN_VRJoystick( qboolean isRightController, float joystickX, float jo
} else if (joystickY < -releasedThreshold) {
// stop left & right
if ((controller->axisButtons & VR_TOUCH_AXIS_LEFT) && IN_GetButtonAction("RTHUMBLEFT", action)) {
IN_SendButtonAction(action, qfalse);
}
controller->axisButtons &= ~VR_TOUCH_AXIS_LEFT;
if ((controller->axisButtons & VR_TOUCH_AXIS_RIGHT) && IN_GetButtonAction("RTHUMBRIGHT", action)) {
IN_SendButtonAction(action, qfalse);
}
controller->axisButtons &= ~VR_TOUCH_AXIS_RIGHT;
// down-left (use release threshold to be more sensitive)
@ -672,38 +684,76 @@ static void IN_VRJoystick( qboolean isRightController, float joystickX, float jo
}
controller->axisButtons &= ~VR_TOUCH_AXIS_DOWNRIGHT;
//yaw
if (vr_snapturn->integer > 0)
{
// left
if (joystickX < -pressedThreshold) {
// left action
if (IN_GetButtonAction("RTHUMBLEFT", action)) {
if (!(controller->axisButtons & VR_TOUCH_AXIS_LEFT)) {
IN_SendButtonAction(action, qtrue);
}
controller->axisButtons |= VR_TOUCH_AXIS_LEFT;
// yaw (snap turn)
} else if (vr_snapturn->integer > 0) {
int snap = 45;
if (vr_snapturn->integer > 1)
{
if (vr_snapturn->integer > 1) {
snap = vr_snapturn->integer;
}
if (!(controller->axisButtons & VR_TOUCH_AXIS_RIGHT) && joystickX > pressedThreshold) {
controller->axisButtons |= VR_TOUCH_AXIS_RIGHT;
CL_SnapTurn(snap);
} else if ((controller->axisButtons & VR_TOUCH_AXIS_RIGHT) &&
joystickX < releasedThreshold) {
controller->axisButtons &= ~VR_TOUCH_AXIS_RIGHT;
}
if (!(controller->axisButtons & VR_TOUCH_AXIS_LEFT) && joystickX < -pressedThreshold) {
controller->axisButtons |= VR_TOUCH_AXIS_LEFT;
if (!(controller->axisButtons & VR_TOUCH_AXIS_LEFT)) {
CL_SnapTurn(-snap);
} else if ((controller->axisButtons & VR_TOUCH_AXIS_LEFT) &&
joystickX > -releasedThreshold) {
controller->axisButtons &= ~VR_TOUCH_AXIS_LEFT;
}
}
else
{
//smooth turn
// yaw (smooth turn)
} else {
const float x = joystickX * cl_sensitivity->value * m_yaw->value;
Com_QueueEvent(in_vrEventTime, SE_MOUSE, x, 0, 0, NULL);
}
controller->axisButtons |= VR_TOUCH_AXIS_LEFT;
} else if (joystickX > -releasedThreshold) {
if ((controller->axisButtons & VR_TOUCH_AXIS_LEFT) && IN_GetButtonAction("RTHUMBLEFT", action)) {
IN_SendButtonAction(action, qfalse);
}
controller->axisButtons &= ~VR_TOUCH_AXIS_LEFT;
}
// right
if (joystickX > pressedThreshold) {
// right action
if (IN_GetButtonAction("RTHUMBRIGHT", action)) {
if (!(controller->axisButtons & VR_TOUCH_AXIS_RIGHT)) {
IN_SendButtonAction(action, qtrue);
}
controller->axisButtons |= VR_TOUCH_AXIS_RIGHT;
// yaw (snap turn)
} else if (vr_snapturn->integer > 0) {
int snap = 45;
if (vr_snapturn->integer > 1) {
snap = vr_snapturn->integer;
}
if (!(controller->axisButtons & VR_TOUCH_AXIS_RIGHT)) {
CL_SnapTurn(snap);
}
// yaw (smooth turn)
} else {
const float x = joystickX * cl_sensitivity->value * m_yaw->value;
Com_QueueEvent(in_vrEventTime, SE_MOUSE, x, 0, 0, NULL);
}
controller->axisButtons |= VR_TOUCH_AXIS_RIGHT;
} else if (joystickX < releasedThreshold) {
if ((controller->axisButtons & VR_TOUCH_AXIS_RIGHT) && IN_GetButtonAction("RTHUMBRIGHT", action)) {
IN_SendButtonAction(action, qfalse);
}
controller->axisButtons &= ~VR_TOUCH_AXIS_RIGHT;
}
}
}