From d9949273949691349acf4d510b259367eeb1b7ff Mon Sep 17 00:00:00 2001 From: Petr Bartos Date: Sun, 6 Mar 2022 22:48:16 +0100 Subject: [PATCH 1/2] Allow to assign action also to right stick diagonals (up-left, up-right, down-left and down-right) --- android/app/src/main/assets/autoexec.cfg | 8 + android/app/src/main/cpp/code/vr/vr_base.c | 8 + android/app/src/main/cpp/code/vr/vr_input.c | 259 +++++++++++++++----- 3 files changed, 217 insertions(+), 58 deletions(-) diff --git a/android/app/src/main/assets/autoexec.cfg b/android/app/src/main/assets/autoexec.cfg index dd561239..41c0a13d 100644 --- a/android/app/src/main/assets/autoexec.cfg +++ b/android/app/src/main/assets/autoexec.cfg @@ -29,8 +29,16 @@ 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_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 "+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..380f363f 100644 --- a/android/app/src/main/cpp/code/vr/vr_base.c +++ b/android/app/src/main/cpp/code/vr/vr_base.c @@ -102,8 +102,16 @@ void VR_InitCvars( void ) 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_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_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_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..26febf2e 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_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_LEFT = 1 << 6, + VR_TOUCH_AXIS_RIGHT = 1 << 7, + VR_TOUCH_AXIS_TRIGGER_INDEX = 1 << 8, }; typedef struct { @@ -497,72 +501,211 @@ 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; + + // up, up-left, up-right (use release threshold to be more sensitive) + if (joystickY > releasedThreshold) { + + // stop left & right + controller->axisButtons &= ~VR_TOUCH_AXIS_LEFT; + 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); + } + } } - 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; + // down, down-left, down-right (use release threshold to be more sensitive) + } else if (joystickY < -releasedThreshold) { + + // stop left & right + controller->axisButtons &= ~VR_TOUCH_AXIS_LEFT; + 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); + } + } } - 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); - } + // left & right + } else { - //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 up-left + if ((controller->axisButtons & VR_TOUCH_AXIS_UPLEFT) && IN_GetButtonAction("RTHUMBFORWARDLEFT", 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_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; + + //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; + } + + 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); + } + } + } } } From 81e0947c86ec6b7ee9d6f38148b5758e7e98be1d Mon Sep 17 00:00:00 2001 From: Petr Bartos Date: Mon, 7 Mar 2022 09:27:28 +0100 Subject: [PATCH 2/2] Allow to override smooth/snap turn with action; set default weapon mapping --- android/app/src/main/assets/autoexec.cfg | 22 ++-- android/app/src/main/cpp/code/vr/vr_base.c | 22 ++-- android/app/src/main/cpp/code/vr/vr_input.c | 136 +++++++++++++------- 3 files changed, 119 insertions(+), 61 deletions(-) diff --git a/android/app/src/main/assets/autoexec.cfg b/android/app/src/main/assets/autoexec.cfg index 41c0a13d..5fa5da2d 100644 --- a/android/app/src/main/assets/autoexec.cfg +++ b/android/app/src/main/assets/autoexec.cfg @@ -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" 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 380f363f..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,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_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_RTHUMBBACKRIGHT", "", 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_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 26febf2e..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,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) @@ -530,8 +536,8 @@ static void IN_VRJoystick( qboolean isRightController, float joystickX, float jo } // up-right (use release threshold to be more sensitive) - } else if (joystickX > releasedThreshold) { - // stop up + } else if (joystickX > releasedThreshold) { + // stop up if ((controller->axisButtons & VR_TOUCH_AXIS_UP) && IN_GetButtonAction("RTHUMBFORWARD", action)) { IN_SendButtonAction(action, qfalse); } @@ -550,7 +556,7 @@ static void IN_VRJoystick( qboolean isRightController, float joystickX, float jo } // direct-up - } else { + } else { // stop up-left if ((controller->axisButtons & VR_TOUCH_AXIS_UPLEFT) && IN_GetButtonAction("RTHUMBFORWARDLEFT", action)) { IN_SendButtonAction(action, qfalse); @@ -568,13 +574,19 @@ static void IN_VRJoystick( qboolean isRightController, float joystickX, float jo 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) @@ -598,8 +610,8 @@ static void IN_VRJoystick( qboolean isRightController, float joystickX, float jo } // down-right (use release threshold to be more sensitive) - } else if (joystickX > releasedThreshold) { - // stop down + } else if (joystickX > releasedThreshold) { + // stop down if ((controller->axisButtons & VR_TOUCH_AXIS_DOWN) && IN_GetButtonAction("RTHUMBBACK", action)) { IN_SendButtonAction(action, qfalse); } @@ -618,7 +630,7 @@ static void IN_VRJoystick( qboolean isRightController, float joystickX, float jo } // direct-down - } else { + } else { // stop down-left if ((controller->axisButtons & VR_TOUCH_AXIS_DOWNLEFT) && IN_GetButtonAction("RTHUMBBACKLEFT", action)) { IN_SendButtonAction(action, qfalse); @@ -636,7 +648,7 @@ static void IN_VRJoystick( qboolean isRightController, float joystickX, float jo IN_SendButtonAction(action, qtrue); } } - } + } // left & right } else { @@ -672,37 +684,75 @@ static void IN_VRJoystick( qboolean isRightController, float joystickX, float jo } controller->axisButtons &= ~VR_TOUCH_AXIS_DOWNRIGHT; - //yaw - if (vr_snapturn->integer > 0) - { - int snap = 45; - if (vr_snapturn->integer > 1) - { - snap = vr_snapturn->integer; - } + // left + if (joystickX < -pressedThreshold) { - 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; - } + // left action + if (IN_GetButtonAction("RTHUMBLEFT", action)) { + if (!(controller->axisButtons & VR_TOUCH_AXIS_LEFT)) { + IN_SendButtonAction(action, qtrue); + } + controller->axisButtons |= VR_TOUCH_AXIS_LEFT; - 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); - } + // 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; + } }