From 8a09007ad000d19279e4f0b690fcf03dbfd30e2f Mon Sep 17 00:00:00 2001 From: Simon Date: Sun, 17 Sep 2023 08:46:21 +0100 Subject: [PATCH] Multiple small changes: - Menu option to use motion to reignite saber - Show error dialog if app can't start due to no headset detected - Cvar to allow people to configure custom distance for weapon scopes to engage from HMD - Use faster buffer blit for desktop window --- Projects/Android/AndroidManifest.xml | 2 +- Projects/Android/jni/OpenJK/JKXR/VrCvars.h | 1 + .../Android/jni/OpenJK/JKXR/VrInputCommon.cpp | 1 + .../jni/OpenJK/JKXR/VrInputDefault.cpp | 2 +- .../OpenJK/JKXR/windows/JKXR_SurfaceView.cpp | 1 + .../jni/OpenJK/JKXR/windows/TBXR_Common.cpp | 29 +++++----------- .../jni/OpenJK/code/android/android_main.cpp | 6 ++++ .../Android/jni/OpenJK/code/qcommon/qcommon.h | 19 +++++++++++ .../jni/OpenJK/code/qcommon/stv_version.h | 2 +- .../jni/OpenJK/shared/sys/sys_win32.cpp | 34 +++++++++++++++++++ z_vr_assets_jka/ui/controls.menu | 32 +++++++++++++++++ z_vr_assets_jka/ui/ingamecontrols.menu | 31 +++++++++++++++++ z_vr_assets_jko/ui/controls.menu | 32 +++++++++++++++++ z_vr_assets_jko/ui/ingamecontrols.menu | 32 +++++++++++++++++ 14 files changed, 201 insertions(+), 23 deletions(-) diff --git a/Projects/Android/AndroidManifest.xml b/Projects/Android/AndroidManifest.xml index 3945949..ecd0cc6 100644 --- a/Projects/Android/AndroidManifest.xml +++ b/Projects/Android/AndroidManifest.xml @@ -2,7 +2,7 @@ + android:versionName="1.1.18" android:installLocation="auto" > diff --git a/Projects/Android/jni/OpenJK/JKXR/VrCvars.h b/Projects/Android/jni/OpenJK/JKXR/VrCvars.h index bb49012..77e4275 100644 --- a/Projects/Android/jni/OpenJK/JKXR/VrCvars.h +++ b/Projects/Android/jni/OpenJK/JKXR/VrCvars.h @@ -10,6 +10,7 @@ extern cvar_t *vr_switch_sticks; extern cvar_t *vr_immersive_cinematics; extern cvar_t *vr_screen_dist; extern cvar_t *vr_weapon_velocity_trigger; +extern cvar_t *vr_scope_engage_distance; extern cvar_t *vr_force_velocity_trigger; extern cvar_t *vr_force_distance_trigger; extern cvar_t *vr_two_handed_weapons; diff --git a/Projects/Android/jni/OpenJK/JKXR/VrInputCommon.cpp b/Projects/Android/jni/OpenJK/JKXR/VrInputCommon.cpp index 4f454b7..596c475 100644 --- a/Projects/Android/jni/OpenJK/JKXR/VrInputCommon.cpp +++ b/Projects/Android/jni/OpenJK/JKXR/VrInputCommon.cpp @@ -23,6 +23,7 @@ cvar_t *vr_switch_sticks; cvar_t *vr_immersive_cinematics; cvar_t *vr_screen_dist; cvar_t *vr_weapon_velocity_trigger; +cvar_t * vr_scope_engage_distance; cvar_t *vr_force_velocity_trigger; cvar_t *vr_force_distance_trigger; cvar_t *vr_two_handed_weapons; diff --git a/Projects/Android/jni/OpenJK/JKXR/VrInputDefault.cpp b/Projects/Android/jni/OpenJK/JKXR/VrInputDefault.cpp index d055ad5..b58d57b 100644 --- a/Projects/Android/jni/OpenJK/JKXR/VrInputDefault.cpp +++ b/Projects/Android/jni/OpenJK/JKXR/VrInputDefault.cpp @@ -628,7 +628,7 @@ void HandleInput_Default( ovrInputStateTrackedRemote *pDominantTrackedRemoteNew, cl.frame.ps.stats[STAT_HEALTH] > 0) { if (vr.weapon_stabilised && - VectorLength(vr.weaponoffset) < 0.24f && + VectorLength(vr.weaponoffset) < vr_scope_engage_distance->value && vr.cgzoommode == 0) { sendButtonAction("enterscope", true); } else if ((VectorLength(vr.weaponoffset) > 0.26f || !vr.weapon_stabilised) && diff --git a/Projects/Android/jni/OpenJK/JKXR/windows/JKXR_SurfaceView.cpp b/Projects/Android/jni/OpenJK/JKXR/windows/JKXR_SurfaceView.cpp index f97ea15..3122d1d 100644 --- a/Projects/Android/jni/OpenJK/JKXR/windows/JKXR_SurfaceView.cpp +++ b/Projects/Android/jni/OpenJK/JKXR/windows/JKXR_SurfaceView.cpp @@ -251,6 +251,7 @@ void VR_Init() vr_immersive_cinematics = Cvar_Get("vr_immersive_cinematics", "1", CVAR_ARCHIVE); vr_screen_dist = Cvar_Get( "vr_screen_dist", "3.5", CVAR_ARCHIVE); vr_weapon_velocity_trigger = Cvar_Get( "vr_weapon_velocity_trigger", "2.0", CVAR_ARCHIVE); + vr_scope_engage_distance = Cvar_Get( "vr_scope_engage_distance", "0.25", CVAR_ARCHIVE); vr_force_velocity_trigger = Cvar_Get( "vr_force_velocity_trigger", "2.09", CVAR_ARCHIVE); vr_force_distance_trigger = Cvar_Get( "vr_force_distance_trigger", "0.15", CVAR_ARCHIVE); vr_two_handed_weapons = Cvar_Get ("vr_two_handed_weapons", "1", CVAR_ARCHIVE); diff --git a/Projects/Android/jni/OpenJK/JKXR/windows/TBXR_Common.cpp b/Projects/Android/jni/OpenJK/JKXR/windows/TBXR_Common.cpp index 6e0836d..2a3956e 100644 --- a/Projects/Android/jni/OpenJK/JKXR/windows/TBXR_Common.cpp +++ b/Projects/Android/jni/OpenJK/JKXR/windows/TBXR_Common.cpp @@ -212,35 +212,21 @@ void ovrFramebuffer_SetNone() { GL(glBindFramebuffer(GL_FRAMEBUFFER, 0)); } -PFNGLBLITNAMEDFRAMEBUFFERPROC glBlitNamedFramebuffer = NULL; extern cvar_t* r_mode; qboolean R_GetModeInfo(int* width, int* height, int mode); void ovrFramebuffer_Resolve(ovrFramebuffer* frameBuffer) { - if (glBlitNamedFramebuffer == NULL) - { - glBlitNamedFramebuffer = (PFNGLBLITNAMEDFRAMEBUFFERPROC)SDL_GL_GetProcAddress("glBlitNamedFramebuffer"); - - } - const GLuint colorTexture = frameBuffer->ColorSwapChainImage[frameBuffer->TextureSwapChainIndex].image; int width, height; R_GetModeInfo(&width, &height, r_mode->integer); - glBlitNamedFramebuffer((GLuint)colorTexture, // readFramebuffer - (GLuint)0, // backbuffer // drawFramebuffer - (GLint)0, // srcX0 - (GLint)0, // srcY0 - (GLint)gAppState.Width, // srcX1 - (GLint)gAppState.Height, // srcY1 - (GLint)0, // dstX0 - (GLint)0, // dstY0 - (GLint)width, // dstX1 - (GLint)height, // dstY1 - (GLbitfield)GL_COLOR_BUFFER_BIT, // mask - (GLenum)GL_LINEAR); // filter + glBindFramebuffer(GL_READ_FRAMEBUFFER, colorTexture); + glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0); + glBlitFramebuffer(0, 0, gAppState.Width, gAppState.Height, + 0, 0, width, height, + GL_COLOR_BUFFER_BIT, GL_NEAREST); } void ovrFramebuffer_Acquire(ovrFramebuffer* frameBuffer) { @@ -906,7 +892,10 @@ void TBXR_InitialiseOpenXR() OXR(initResult = xrGetSystem(gAppState.Instance, &systemGetInfo, &gAppState.SystemId)); if (initResult != XR_SUCCESS) { - ALOGE("Failed to get system."); + if (initResult != XR_SUCCESS) { + Sys_Dialog(DT_ERROR, "Unable to create OpenXR System - Please ensure you headset is connected and powered on.", "No VR Headset Detected"); + exit(1); + } exit(1); } diff --git a/Projects/Android/jni/OpenJK/code/android/android_main.cpp b/Projects/Android/jni/OpenJK/code/android/android_main.cpp index d126dff..4e162d9 100644 --- a/Projects/Android/jni/OpenJK/code/android/android_main.cpp +++ b/Projects/Android/jni/OpenJK/code/android/android_main.cpp @@ -37,6 +37,12 @@ char *Sys_Cwd( void ) { return cwd; } +//No support for this on Android atm +dialogResult_t Sys_Dialog(dialogType_t type, const char* message, const char* title) +{ + return DR_OK; +} + /* ================= Sys_ConsoleInput diff --git a/Projects/Android/jni/OpenJK/code/qcommon/qcommon.h b/Projects/Android/jni/OpenJK/code/qcommon/qcommon.h index 88a9846..ad1d650 100644 --- a/Projects/Android/jni/OpenJK/code/qcommon/qcommon.h +++ b/Projects/Android/jni/OpenJK/code/qcommon/qcommon.h @@ -66,6 +66,25 @@ void *MSG_GetSpace (msg_t *buf, int length); void MSG_WriteData (msg_t *buf, const void *data, int length); +typedef enum +{ + DR_YES = 0, + DR_NO = 1, + DR_OK = 0, + DR_CANCEL = 1 +} dialogResult_t; + +typedef enum +{ + DT_INFO, + DT_WARNING, + DT_ERROR, + DT_YES_NO, + DT_OK_CANCEL +} dialogType_t; + +dialogResult_t Sys_Dialog(dialogType_t type, const char* message, const char* title); + struct usercmd_s; struct entityState_s; diff --git a/Projects/Android/jni/OpenJK/code/qcommon/stv_version.h b/Projects/Android/jni/OpenJK/code/qcommon/stv_version.h index 13d4a43..9d6e69a 100644 --- a/Projects/Android/jni/OpenJK/code/qcommon/stv_version.h +++ b/Projects/Android/jni/OpenJK/code/qcommon/stv_version.h @@ -23,7 +23,7 @@ along with this program; if not, see . // Current version of the single player game #include "../win32/AutoVersion.h" -#define JKXR_VERSION "1.1.17-ea" +#define JKXR_VERSION "1.1.18-ea" #ifdef _DEBUG #define Q3_VERSION "(debug)OpenJK: v" VERSION_STRING_DOTTED " JKXR: " JKXR_VERSION diff --git a/Projects/Android/jni/OpenJK/shared/sys/sys_win32.cpp b/Projects/Android/jni/OpenJK/shared/sys/sys_win32.cpp index 2de9664..3825786 100644 --- a/Projects/Android/jni/OpenJK/shared/sys/sys_win32.cpp +++ b/Projects/Android/jni/OpenJK/shared/sys/sys_win32.cpp @@ -34,6 +34,40 @@ static char homePath[ MAX_OSPATH ] = { 0 }; static UINT timerResolution = 0; + + + +/* +============== +Sys_Dialog + +Display a win32 dialog box +============== +*/ +dialogResult_t Sys_Dialog(dialogType_t type, const char* message, const char* title) +{ + UINT uType; + + switch (type) + { + default: + case DT_INFO: uType = MB_ICONINFORMATION | MB_OK; break; + case DT_WARNING: uType = MB_ICONWARNING | MB_OK; break; + case DT_ERROR: uType = MB_ICONERROR | MB_OK; break; + case DT_YES_NO: uType = MB_ICONQUESTION | MB_YESNO; break; + case DT_OK_CANCEL: uType = MB_ICONWARNING | MB_OKCANCEL; break; + } + + switch (MessageBox(NULL, message, title, uType)) + { + default: + case IDOK: return DR_OK; + case IDCANCEL: return DR_CANCEL; + case IDYES: return DR_YES; + case IDNO: return DR_NO; + } +} + /* ============== Sys_Basename diff --git a/z_vr_assets_jka/ui/controls.menu b/z_vr_assets_jka/ui/controls.menu index 029a83f..be82363 100644 --- a/z_vr_assets_jka/ui/controls.menu +++ b/z_vr_assets_jka/ui/controls.menu @@ -1025,6 +1025,38 @@ } } + itemDef + { + name none + group commoncontrols + type ITEM_TYPE_YESNO + text "Motion Ignite Saber:" + cvar "vr_motion_enable_saber" + rect 260 380 340 14 + textalign ITEM_ALIGN_RIGHT + textalignx 174 + textaligny 0 + font 4 + textscale 1 + forecolor 1 1 1 0.0 + visible 0 + descText "Turn disabled saber back on when motion triggered" + action + { + play sound/interface/button1 + } + + mouseenter + { + show button_glow + setitemrect button_glow 260 380 340 20 + } + mouseexit + { + hide button_glow + } + } + //---------------------------------------------------------------------------------------------- // // WEAPON MENU diff --git a/z_vr_assets_jka/ui/ingamecontrols.menu b/z_vr_assets_jka/ui/ingamecontrols.menu index 2f3a1dc..948506f 100644 --- a/z_vr_assets_jka/ui/ingamecontrols.menu +++ b/z_vr_assets_jka/ui/ingamecontrols.menu @@ -1208,6 +1208,37 @@ } } + itemDef + { + name none + group commoncontrols + type ITEM_TYPE_YESNO + text "Motion Ignite Saber:" + cvar "vr_motion_enable_saber" + rect 260 380 340 14 + textalign ITEM_ALIGN_RIGHT + textalignx 174 + textaligny 0 + font 4 + textscale 1 + forecolor .615 .615 .956 0.0 + visible 0 + descText "Turn disabled saber back on when motion triggered" + action + { + play sound/interface/button1 + } + + mouseenter + { + show highlight10 + } + mouseexit + { + hide highlight10 + } + } + //---------------------------------------------------------------------------------------------- // // WEAPON MENU diff --git a/z_vr_assets_jko/ui/controls.menu b/z_vr_assets_jko/ui/controls.menu index 5c9b191..2b3db9f 100644 --- a/z_vr_assets_jko/ui/controls.menu +++ b/z_vr_assets_jko/ui/controls.menu @@ -1515,6 +1515,38 @@ } } + itemDef + { + name none + group commoncontrols + type ITEM_TYPE_YESNO + text "Motion Ignite Saber:" + cvar "vr_motion_enable_saber" + rect 305 371 300 20 + textalign ITEM_ALIGN_RIGHT + textalignx 151 + textaligny -2 + font 2 + textscale 0.8 + forecolor 1 1 1 1 + visible 0 + // appearance_slot 3 + descText "Turn disabled saber back on when motion triggered" + action + { + play sound/interface/button1 + } + + mouseenter + { + show highlight11 + } + mouseexit + { + hide highlight11 + } + } + //---------------------------------------------------------------------------------------------- diff --git a/z_vr_assets_jko/ui/ingamecontrols.menu b/z_vr_assets_jko/ui/ingamecontrols.menu index d997e8f..2cd1790 100644 --- a/z_vr_assets_jko/ui/ingamecontrols.menu +++ b/z_vr_assets_jko/ui/ingamecontrols.menu @@ -1514,6 +1514,38 @@ } } + itemDef + { + name none + group commoncontrols + type ITEM_TYPE_YESNO + text "Motion Ignite Saber:" + cvar "vr_motion_enable_saber" + rect 305 371 300 20 + textalign ITEM_ALIGN_RIGHT + textalignx 151 + textaligny -2 + font 2 + textscale 0.8 + forecolor 1 1 1 1 + visible 0 + // appearance_slot 3 + descText "Turn disabled saber back on when motion triggered" + action + { + play sound/interface/button1 + } + + mouseenter + { + show highlight10 + } + mouseexit + { + hide highlight10 + } + } + //----------------------------------------------------------------------------------------------