From caa14c81e71048a10bd8fab1d0dd2b8c235f377a Mon Sep 17 00:00:00 2001 From: Petr Bartos Date: Fri, 8 Apr 2022 18:13:46 +0200 Subject: [PATCH 1/2] Weapon selector fixes --- .../app/src/main/cpp/code/cgame/cg_weapons.c | 11 +++++- .../app/src/main/cpp/code/vr/vr_clientinfo.h | 1 + android/app/src/main/cpp/code/vr/vr_input.c | 38 +++++++++++-------- 3 files changed, 32 insertions(+), 18 deletions(-) diff --git a/android/app/src/main/cpp/code/cgame/cg_weapons.c b/android/app/src/main/cpp/code/cgame/cg_weapons.c index ba8f8ac9..88755eb9 100644 --- a/android/app/src/main/cpp/code/cgame/cg_weapons.c +++ b/android/app/src/main/cpp/code/cgame/cg_weapons.c @@ -1860,6 +1860,11 @@ void CG_DrawWeaponSelect( void ) { return; } + // don't display when weapon wheel is opened + if (vr->weapon_select) { + return; + } + color = CG_FadeColor( cg.weaponSelectTime, WEAPON_SELECT_TIME ); if ( !color ) { return; @@ -2114,7 +2119,8 @@ void CG_DrawWeaponSelector( void ) float thumbstickAxisX = 0.0f; float thumbstickAxisY = 0.0f; float a = atan2(vr->thumbstick_location[thumb][0], vr->thumbstick_location[thumb][1]); - if (length(vr->thumbstick_location[thumb][0], vr->thumbstick_location[thumb][1]) > 0.95f) + float thumbstickValue = length(vr->thumbstick_location[thumb][0], vr->thumbstick_location[thumb][1]); + if (thumbstickValue > 0.95f) { thumbstickAxisX = sinf(a) * 0.95f; thumbstickAxisY = cosf(a) * 0.95f; @@ -2384,12 +2390,13 @@ void CG_DrawWeaponSelector( void ) // 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 (thumbstickValue < 0.1f) { if (selected) { cg.weaponSelect = cg.weaponSelectorSelection; } vr->weapon_select = qfalse; vr->weapon_select_autoclose = qfalse; + vr->weapon_select_using_thumbstick = qfalse; } } } diff --git a/android/app/src/main/cpp/code/vr/vr_clientinfo.h b/android/app/src/main/cpp/code/vr/vr_clientinfo.h index d156b80f..2dd5430d 100644 --- a/android/app/src/main/cpp/code/vr/vr_clientinfo.h +++ b/android/app/src/main/cpp/code/vr/vr_clientinfo.h @@ -23,6 +23,7 @@ typedef struct { vrFollowMode_t follow_mode; qboolean weapon_select; qboolean weapon_select_autoclose; + qboolean weapon_select_using_thumbstick; qboolean no_crosshair; int realign; // used to realign the fake 6DoF playspace in a multiplayer game 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 891b6869..4d970950 100644 --- a/android/app/src/main/cpp/code/vr/vr_input.c +++ b/android/app/src/main/cpp/code/vr/vr_input.c @@ -46,8 +46,11 @@ static vrController_t rightController; static int in_vrEventTime = 0; static double lastframetime = 0; -static float pressedThreshold = 0.75f; -static float releasedThreshold = 0.5f; +static float triggerPressedThreshold = 0.75f; +static float triggerReleasedThreshold = 0.5f; + +static float thumbstickPressedThreshold = 0.5f; +static float thumbstickReleasedThreshold = 0.4f; extern cvar_t *cl_sensitivity; extern cvar_t *m_pitch; @@ -313,9 +316,13 @@ static qboolean IN_SendInputAction(const char* action, qboolean inputActive, flo else if (strcmp(action, "+weapon_select") == 0) { vr.weapon_select = inputActive; - vr.weapon_select_autoclose = thumbstickAxis; - if (!inputActive) - { + if (inputActive) { + int selectorType = (int) Cvar_VariableValue("vr_weaponSelectorMode"); + vr.weapon_select_using_thumbstick = (selectorType == WS_HMD); + vr.weapon_select_autoclose = vr.weapon_select_using_thumbstick && thumbstickAxis; + } else { + vr.weapon_select_using_thumbstick = qfalse; + vr.weapon_select_autoclose = qfalse; Cbuf_AddText("weapon_select"); } } @@ -728,12 +735,11 @@ static void IN_VRJoystick( qboolean isRightController, float joystickX, float jo Com_QueueEvent(in_vrEventTime, SE_JOYSTICK_AXIS, 1, joystick[1] * 127.0f + positional[1] * 127.0f, 0, NULL); } - // In case weapon wheel is opened, and is in HMD/thumbstick mode or was opened by thumbstick, ignore standard thumbstick inputs - // In case weapon wheel is in controller mode and is opened by grip, allow use use of thumbstick e.g. to not block turning while wheel is open - else if (!vr.weapon_select || ((int)Cvar_VariableValue("vr_weaponSelectorMode") == WS_CONTROLLER && !vr.weapon_select_autoclose)) + // In case thumbstick is used by weapon wheel (is in HMD/thumbstick mode), ignore standard thumbstick inputs + else if (!vr.weapon_select_using_thumbstick) { float joystickValue = length(joystickX, joystickY); - if (joystickValue < releasedThreshold) { + if (joystickValue < thumbstickReleasedThreshold) { // Joystick within threshold -> disable all inputs IN_HandleInactiveInput(&controller->axisButtons, VR_TOUCH_AXIS_UP, "RTHUMBFORWARD", joystickValue, qtrue); IN_HandleInactiveInput(&controller->axisButtons, VR_TOUCH_AXIS_UPRIGHT, "RTHUMBFORWARDRIGHT", joystickValue, qtrue); @@ -743,7 +749,7 @@ static void IN_VRJoystick( qboolean isRightController, float joystickX, float jo IN_HandleInactiveInput(&controller->axisButtons, VR_TOUCH_AXIS_DOWNLEFT, "RTHUMBBACKLEFT", joystickValue, qtrue); IN_HandleInactiveInput(&controller->axisButtons, VR_TOUCH_AXIS_LEFT, "RTHUMBLEFT", joystickValue, qtrue); IN_HandleInactiveInput(&controller->axisButtons, VR_TOUCH_AXIS_UPLEFT, "RTHUMBFORWARDLEFT", joystickValue, qtrue); - } else { + } else if (joystickValue > thumbstickPressedThreshold) { float joystickAngle = AngleNormalize360(RAD2DEG(atan2(joystickX, joystickY))); if (IN_VRJoystickUse8WayMapping()) { IN_VRJoystickHandle8WayMapping(&controller->axisButtons, joystickAngle, joystickValue); @@ -762,7 +768,7 @@ static void IN_VRTriggers( qboolean isRightController, float triggerValue ) { if (VR_useScreenLayer() || cl.snap.ps.pm_type == PM_INTERMISSION) { // Triggers are used for menu navigation in screen mode or in intermission - if (triggerValue > pressedThreshold && !IN_InputActivated(&controller->axisButtons, VR_TOUCH_AXIS_TRIGGER_INDEX)) + if (triggerValue > triggerPressedThreshold && !IN_InputActivated(&controller->axisButtons, VR_TOUCH_AXIS_TRIGGER_INDEX)) { IN_ActivateInput(&controller->axisButtons, VR_TOUCH_AXIS_TRIGGER_INDEX); if ((isRightController && !vr.menuLeftHanded) || (!isRightController && vr.menuLeftHanded)) { @@ -774,7 +780,7 @@ static void IN_VRTriggers( qboolean isRightController, float triggerValue ) { vr.menuLeftHanded = !vr.menuLeftHanded; } } - else if (triggerValue < releasedThreshold && IN_InputActivated(&controller->axisButtons, VR_TOUCH_AXIS_TRIGGER_INDEX)) + else if (triggerValue < triggerReleasedThreshold && IN_InputActivated(&controller->axisButtons, VR_TOUCH_AXIS_TRIGGER_INDEX)) { IN_DeactivateInput(&controller->axisButtons, VR_TOUCH_AXIS_TRIGGER_INDEX); if ((isRightController && !vr.menuLeftHanded) || (!isRightController && vr.menuLeftHanded)) { @@ -787,9 +793,9 @@ static void IN_VRTriggers( qboolean isRightController, float triggerValue ) { // Primary trigger if (isRightController == (vr_righthanded->integer != 0)) { - if (triggerValue > pressedThreshold) { + if (triggerValue > triggerPressedThreshold) { IN_HandleActiveInput(&controller->axisButtons, VR_TOUCH_AXIS_TRIGGER_INDEX, "PRIMARYTRIGGER", triggerValue, qfalse); - } else if (triggerValue < releasedThreshold) { + } else if (triggerValue < triggerReleasedThreshold) { IN_HandleInactiveInput(&controller->axisButtons, VR_TOUCH_AXIS_TRIGGER_INDEX, "PRIMARYTRIGGER", triggerValue, qfalse); } } @@ -797,9 +803,9 @@ static void IN_VRTriggers( qboolean isRightController, float triggerValue ) { // Off hand trigger if (isRightController != (vr_righthanded->integer != 0)) { - if (triggerValue > pressedThreshold) { + if (triggerValue > triggerPressedThreshold) { IN_HandleActiveInput(&controller->axisButtons, VR_TOUCH_AXIS_TRIGGER_INDEX, "SECONDARYTRIGGER", triggerValue, qfalse); - } else if (triggerValue < releasedThreshold) { + } else if (triggerValue < triggerReleasedThreshold) { IN_HandleInactiveInput(&controller->axisButtons, VR_TOUCH_AXIS_TRIGGER_INDEX, "SECONDARYTRIGGER", triggerValue, qfalse); } } From 7c5815f3b11847c4ca7fe59a25d5b31df223e2d7 Mon Sep 17 00:00:00 2001 From: Petr Bartos Date: Fri, 8 Apr 2022 18:44:50 +0200 Subject: [PATCH 2/2] Make name input in Team Arena menus inactive --- android/app/src/main/pakQ3Q/ui/ingame_player.menu | 3 ++- android/app/src/main/pakQ3Q/ui/player.menu | 3 +-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/android/app/src/main/pakQ3Q/ui/ingame_player.menu b/android/app/src/main/pakQ3Q/ui/ingame_player.menu index 7dcaa55d..5d2a7f10 100644 --- a/android/app/src/main/pakQ3Q/ui/ingame_player.menu +++ b/android/app/src/main/pakQ3Q/ui/ingame_player.menu @@ -143,7 +143,8 @@ itemDef { forecolor 1 1 1 1 border 0 bordercolor 0 0 0 0 - visible 1 + visible 1 + decoration } diff --git a/android/app/src/main/pakQ3Q/ui/player.menu b/android/app/src/main/pakQ3Q/ui/player.menu index 8e0e8051..eb4c611b 100644 --- a/android/app/src/main/pakQ3Q/ui/player.menu +++ b/android/app/src/main/pakQ3Q/ui/player.menu @@ -277,8 +277,7 @@ itemDef { border 0 bordercolor 0 0 0 0 visible 1 -// mouseEnter { show message_name } -// mouseExit { hide message_name } + decoration } itemDef {