diff --git a/android/app/src/main/assets/autoexec.cfg b/android/app/src/main/assets/autoexec.cfg index dd561239..5fa5da2d 100644 --- a/android/app/src/main/assets/autoexec.cfg +++ b/android/app/src/main/assets/autoexec.cfg @@ -28,9 +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_RTHUMBFORWARD_ALT "weapon 3" +set vr_button_map_RTHUMBFORWARDRIGHT "" +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 "weapon 4" set vr_button_map_RTHUMBBACK "" -set vr_button_map_RTHUMBBACK_ALT "" +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" diff --git a/android/app/src/main/cpp/code/vr/vr_base.c b/android/app/src/main/cpp/code/vr/vr_base.c index be87c966..64cb8dac 100644 --- a/android/app/src/main/cpp/code/vr/vr_base.c +++ b/android/app/src/main/cpp/code/vr/vr_base.c @@ -100,10 +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_RTHUMBBACK", "weapprev", CVAR_ARCHIVE); // Previous Weapon + 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", "", 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", "", 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 diff --git a/android/app/src/main/cpp/code/vr/vr_input.c b/android/app/src/main/cpp/code/vr/vr_input.c index dafca8fe..81e72b65 100644 --- a/android/app/src/main/cpp/code/vr/vr_input.c +++ b/android/app/src/main/cpp/code/vr/vr_input.c @@ -22,10 +22,14 @@ enum { VR_TOUCH_AXIS_UP = 1 << 0, - VR_TOUCH_AXIS_DOWN = 1 << 1, - VR_TOUCH_AXIS_LEFT = 1 << 2, - VR_TOUCH_AXIS_RIGHT = 1 << 3, - VR_TOUCH_AXIS_TRIGGER_INDEX = 1 << 4, + 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_UPLEFT = 1 << 7, + VR_TOUCH_AXIS_TRIGGER_INDEX = 1 << 8, }; typedef struct { @@ -497,72 +501,261 @@ static void IN_VRJoystick( qboolean isRightController, float joystickX, float jo } else //right controller { - //yaw - if (vr_snapturn->integer > 0) - { - int snap = 45; - 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; - } + // up, up-left, up-right (use release threshold to be more sensitive) + if (joystickY > releasedThreshold) { - if (!(controller->axisButtons & VR_TOUCH_AXIS_LEFT) && joystickX < -pressedThreshold) { - 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 - const float x = joystickX * cl_sensitivity->value * m_yaw->value; - Com_QueueEvent(in_vrEventTime, SE_MOUSE, x, 0, 0, NULL); - } - - //Default up/down on right thumbstick is weapon switch - if (!(controller->axisButtons & VR_TOUCH_AXIS_UP) && joystickY > pressedThreshold) - { - controller->axisButtons |= VR_TOUCH_AXIS_UP; - if (IN_GetButtonAction("RTHUMBFORWARD", action)) - { - IN_SendButtonAction(action, qtrue); + // stop left & right + if ((controller->axisButtons & VR_TOUCH_AXIS_LEFT) && IN_GetButtonAction("RTHUMBLEFT", action)) { + IN_SendButtonAction(action, qfalse); } - } - else if ((controller->axisButtons & VR_TOUCH_AXIS_UP) && - joystickY < releasedThreshold) - { - if (IN_GetButtonAction("RTHUMBFORWARD", action)) - { + 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) + if (joystickX < -releasedThreshold) { + // stop up + if ((controller->axisButtons & VR_TOUCH_AXIS_UP) && IN_GetButtonAction("RTHUMBFORWARD", action)) { + IN_SendButtonAction(action, qfalse); + } + controller->axisButtons &= ~VR_TOUCH_AXIS_UP; + // stop up-right + if ((controller->axisButtons & VR_TOUCH_AXIS_UPRIGHT) && IN_GetButtonAction("RTHUMBFORWARDRIGHT", action)) { + IN_SendButtonAction(action, qfalse); + } + controller->axisButtons &= ~VR_TOUCH_AXIS_UPRIGHT; + // start up-left + if (!(controller->axisButtons & VR_TOUCH_AXIS_UPLEFT)) { + controller->axisButtons |= VR_TOUCH_AXIS_UPLEFT; + if (IN_GetButtonAction("RTHUMBFORWARDLEFT", action)) { + IN_SendButtonAction(action, qtrue); + } + } + + // up-right (use release threshold to be more sensitive) + } else if (joystickX > releasedThreshold) { + // stop up + if ((controller->axisButtons & VR_TOUCH_AXIS_UP) && IN_GetButtonAction("RTHUMBFORWARD", action)) { + IN_SendButtonAction(action, qfalse); + } + controller->axisButtons &= ~VR_TOUCH_AXIS_UP; + // stop up-left + if ((controller->axisButtons & VR_TOUCH_AXIS_UPLEFT) && IN_GetButtonAction("RTHUMBFORWARDLEFT", action)) { + IN_SendButtonAction(action, qfalse); + } + controller->axisButtons &= ~VR_TOUCH_AXIS_UPLEFT; + // start up-right + if (!(controller->axisButtons & VR_TOUCH_AXIS_UPRIGHT)) { + controller->axisButtons |= VR_TOUCH_AXIS_UPRIGHT; + if (IN_GetButtonAction("RTHUMBFORWARDRIGHT", action)) { + IN_SendButtonAction(action, qtrue); + } + } + + // direct-up + } else { + // stop up-left + if ((controller->axisButtons & VR_TOUCH_AXIS_UPLEFT) && IN_GetButtonAction("RTHUMBFORWARDLEFT", action)) { + IN_SendButtonAction(action, qfalse); + } + controller->axisButtons &= ~VR_TOUCH_AXIS_UPLEFT; + // stop up-right + if ((controller->axisButtons & VR_TOUCH_AXIS_UPRIGHT) && IN_GetButtonAction("RTHUMBFORWARDRIGHT", action)) { + IN_SendButtonAction(action, qfalse); + } + controller->axisButtons &= ~VR_TOUCH_AXIS_UPRIGHT; + // start up + if (!(controller->axisButtons & VR_TOUCH_AXIS_UP) && joystickY > pressedThreshold) { + controller->axisButtons |= VR_TOUCH_AXIS_UP; + if (IN_GetButtonAction("RTHUMBFORWARD", action)) { + IN_SendButtonAction(action, qtrue); + } + } + } + + // down, down-left, down-right (use release threshold to be more sensitive) + } 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) + if (joystickX < -releasedThreshold) { + // stop down + if ((controller->axisButtons & VR_TOUCH_AXIS_DOWN) && IN_GetButtonAction("RTHUMBBACK", action)) { + IN_SendButtonAction(action, qfalse); + } + controller->axisButtons &= ~VR_TOUCH_AXIS_DOWN; + // stop down-right + if ((controller->axisButtons & VR_TOUCH_AXIS_DOWNRIGHT) && IN_GetButtonAction("RTHUMBBACKRIGHT", action)) { + IN_SendButtonAction(action, qfalse); + } + controller->axisButtons &= ~VR_TOUCH_AXIS_DOWNRIGHT; + // start down-left + if (!(controller->axisButtons & VR_TOUCH_AXIS_DOWNLEFT)) { + controller->axisButtons |= VR_TOUCH_AXIS_DOWNLEFT; + if (IN_GetButtonAction("RTHUMBBACKLEFT", action)) { + IN_SendButtonAction(action, qtrue); + } + } + + // down-right (use release threshold to be more sensitive) + } else if (joystickX > releasedThreshold) { + // stop down + if ((controller->axisButtons & VR_TOUCH_AXIS_DOWN) && IN_GetButtonAction("RTHUMBBACK", action)) { + IN_SendButtonAction(action, qfalse); + } + controller->axisButtons &= ~VR_TOUCH_AXIS_DOWN; + // stop down-left + if ((controller->axisButtons & VR_TOUCH_AXIS_DOWNLEFT) && IN_GetButtonAction("RTHUMBBACKLEFT", action)) { + IN_SendButtonAction(action, qfalse); + } + controller->axisButtons &= ~VR_TOUCH_AXIS_DOWNLEFT; + // start down-right + if (!(controller->axisButtons & VR_TOUCH_AXIS_DOWNRIGHT)) { + controller->axisButtons |= VR_TOUCH_AXIS_DOWNRIGHT; + if (IN_GetButtonAction("RTHUMBBACKRIGHT", action)) { + IN_SendButtonAction(action, qtrue); + } + } + + // direct-down + } else { + // stop down-left + if ((controller->axisButtons & VR_TOUCH_AXIS_DOWNLEFT) && IN_GetButtonAction("RTHUMBBACKLEFT", action)) { + IN_SendButtonAction(action, qfalse); + } + controller->axisButtons &= ~VR_TOUCH_AXIS_DOWNLEFT; + // stop down-right + if ((controller->axisButtons & VR_TOUCH_AXIS_DOWNRIGHT) && IN_GetButtonAction("RTHUMBBACKRIGHT", action)) { + IN_SendButtonAction(action, qfalse); + } + controller->axisButtons &= ~VR_TOUCH_AXIS_DOWNRIGHT; + // start down + if (!(controller->axisButtons & VR_TOUCH_AXIS_DOWN) && joystickY < -pressedThreshold) { + controller->axisButtons |= VR_TOUCH_AXIS_DOWN; + if (IN_GetButtonAction("RTHUMBBACK", action)) { + IN_SendButtonAction(action, qtrue); + } + } + } + + // left & right + } else { + + // stop up-left + if ((controller->axisButtons & VR_TOUCH_AXIS_UPLEFT) && IN_GetButtonAction("RTHUMBFORWARDLEFT", action)) { + IN_SendButtonAction(action, qfalse); + } + controller->axisButtons &= ~VR_TOUCH_AXIS_UPLEFT; + // stop up + if ((controller->axisButtons & VR_TOUCH_AXIS_UP) && IN_GetButtonAction("RTHUMBFORWARD", action)) { IN_SendButtonAction(action, qfalse); } controller->axisButtons &= ~VR_TOUCH_AXIS_UP; - } - - - if (!(controller->axisButtons & VR_TOUCH_AXIS_DOWN) && joystickY < -pressedThreshold) { - controller->axisButtons |= VR_TOUCH_AXIS_DOWN; - if (IN_GetButtonAction("RTHUMBBACK", action)) - { - IN_SendButtonAction(action, qtrue); - } - } else if ((controller->axisButtons & VR_TOUCH_AXIS_DOWN) && - joystickY > -releasedThreshold) { - controller->axisButtons &= ~VR_TOUCH_AXIS_DOWN; - if (IN_GetButtonAction("RTHUMBBACK", action)) - { + // stop up-right + if ((controller->axisButtons & VR_TOUCH_AXIS_UPRIGHT) && IN_GetButtonAction("RTHUMBFORWARDRIGHT", action)) { IN_SendButtonAction(action, qfalse); } + controller->axisButtons &= ~VR_TOUCH_AXIS_UPRIGHT; + // stop down-left + if ((controller->axisButtons & VR_TOUCH_AXIS_DOWNLEFT) && IN_GetButtonAction("RTHUMBBACKLEFT", action)) { + IN_SendButtonAction(action, qfalse); + } + controller->axisButtons &= ~VR_TOUCH_AXIS_DOWNLEFT; + // stop down + if ((controller->axisButtons & VR_TOUCH_AXIS_DOWN) && IN_GetButtonAction("RTHUMBBACK", action)) { + IN_SendButtonAction(action, qfalse); + } + controller->axisButtons &= ~VR_TOUCH_AXIS_DOWN; + // stop down-right + if ((controller->axisButtons & VR_TOUCH_AXIS_DOWNRIGHT) && IN_GetButtonAction("RTHUMBBACKRIGHT", action)) { + IN_SendButtonAction(action, qfalse); + } + controller->axisButtons &= ~VR_TOUCH_AXIS_DOWNRIGHT; + + // 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) { + snap = vr_snapturn->integer; + } + if (!(controller->axisButtons & VR_TOUCH_AXIS_LEFT)) { + 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_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; + } + } + } } }