From b1d847e0d8256bdb2182a7b6fb91715bfe810232 Mon Sep 17 00:00:00 2001 From: Simon Date: Fri, 23 Sep 2022 23:10:32 +0100 Subject: [PATCH] Mouse working in main menu and game library loads, intro plays, but crashing in a sequence atm --- Projects/Android/jni/JKVR/VrInputCommon.cpp | 14 +------ Projects/Android/jni/OpenJK/Android_gles.mk | 2 +- .../jni/OpenJK/code/android/android_main.cpp | 15 +++----- .../jni/OpenJK/code/android/in_android.cpp | 13 ++++--- .../jni/OpenJK/code/cgame/FxScheduler.cpp | 4 +- .../jni/OpenJK/code/client/cl_input.cpp | 10 ++++- .../jni/OpenJK/code/rd-vanilla/tr_init.cpp | 2 +- .../Android/jni/OpenJK/code/ui/ui_local.h | 1 + .../Android/jni/OpenJK/code/ui/ui_main.cpp | 38 +++++++++++++++++++ 9 files changed, 66 insertions(+), 33 deletions(-) diff --git a/Projects/Android/jni/JKVR/VrInputCommon.cpp b/Projects/Android/jni/JKVR/VrInputCommon.cpp index 2085e1a..6947c7a 100644 --- a/Projects/Android/jni/JKVR/VrInputCommon.cpp +++ b/Projects/Android/jni/JKVR/VrInputCommon.cpp @@ -215,19 +215,9 @@ float clamp(float _min, float _val, float _max) } void interactWithTouchScreen(bool reset, ovrInputStateTrackedRemote *newState, ovrInputStateTrackedRemote *oldState) { - static float cursorX = 0.25f; - static float cursorY = 0.125f; - if (reset) - { - cursorX = 0.25f; - cursorY = 0.125f; - } - - cursorX += (float)(vr.weaponangles_delta[YAW] / 180.0); - cursorX = clamp(0.0, cursorX, 0.5); - cursorY += (float)(-vr.weaponangles_delta[PITCH] / 220.0); - cursorY = clamp(0.0, cursorY, 0.4); + float cursorX = (float)(-vr.weaponangles[YAW] / 90.0) + 0.5f; + float cursorY = (float)(vr.weaponangles[PITCH] / 90.0) + 0.5f; PortableMouseAbs(cursorX, cursorY); } \ No newline at end of file diff --git a/Projects/Android/jni/OpenJK/Android_gles.mk b/Projects/Android/jni/OpenJK/Android_gles.mk index 7410728..f1ce5c1 100644 --- a/Projects/Android/jni/OpenJK/Android_gles.mk +++ b/Projects/Android/jni/OpenJK/Android_gles.mk @@ -16,7 +16,7 @@ LOCAL_LDLIBS := $(JK3_BASE_LDLIBS) LOCAL_LDLIBS += -lGLESv3 -landroid -lEGL -ldl -llog LOCAL_STATIC_LIBRARIES := libpng libjpeg -# LOCAL_SHARED_LIBRARIES := gl4es +LOCAL_SHARED_LIBRARIES := gl4es LOCAL_C_INCLUDES := $(JK3_BASE_C_INCLUDES) $(SUPPORT_LIBS)/libpng $(TOP_DIR) $(SPDir)/rd-vanilla $(SPDir)/rd-common diff --git a/Projects/Android/jni/OpenJK/code/android/android_main.cpp b/Projects/Android/jni/OpenJK/code/android/android_main.cpp index 14efc72..57f0b78 100644 --- a/Projects/Android/jni/OpenJK/code/android/android_main.cpp +++ b/Projects/Android/jni/OpenJK/code/android/android_main.cpp @@ -749,7 +749,6 @@ void *Sys_LoadGameDll( const char *name, void *(QDECL **moduleAPI)(int, ...) ) char *fn; char filename[MAX_OSPATH]; - //Com_sprintf (filename, sizeof(filename), "%s" ARCH_STRING DLL_EXT, name); #if 0 libHandle = Sys_LoadLibrary( filename ); @@ -762,6 +761,7 @@ void *Sys_LoadGameDll( const char *name, void *(QDECL **moduleAPI)(int, ...) ) #endif + Com_sprintf (filename, sizeof(filename), "%s" ARCH_STRING DLL_EXT, name); char lib_path[512]; char *libdir = (char*)getenv("JK_LIBDIR"); sprintf(lib_path,"%s/lib%s", libdir,filename); @@ -864,12 +864,11 @@ void *Sys_LoadSPGameDll( const char *name, GetGameAPIProc **GetGameAPI ) assert( GetGameAPI ); Com_sprintf (filename, sizeof(filename), "%s" ARCH_STRING DLL_EXT, name); + char lib_path[512]; + char *libdir = (char*)getenv("JK_LIBDIR"); + sprintf(lib_path,"%s/lib%s", libdir,filename); + libHandle = dlopen (lib_path, RTLD_LAZY ); -#if defined(MACOS_X) && !defined(_JK2EXE) - //First, look for the old-style mac .bundle that's inside a pk3 - //It's actually zipped, and the zipfile has the same name as 'name' - libHandle = Sys_LoadMachOBundle( filename ); -#endif if (!libHandle) { char *basepath = Cvar_VariableString( "fs_basepath" ); @@ -881,10 +880,8 @@ void *Sys_LoadSPGameDll( const char *name, GetGameAPIProc **GetGameAPI ) #endif const char *searchPaths[] = { + libdir, homepath, -#ifdef MACOS_X - apppath, -#endif basepath, cdpath, }; diff --git a/Projects/Android/jni/OpenJK/code/android/in_android.cpp b/Projects/Android/jni/OpenJK/code/android/in_android.cpp index d4da5e1..4484083 100644 --- a/Projects/Android/jni/OpenJK/code/android/in_android.cpp +++ b/Projects/Android/jni/OpenJK/code/android/in_android.cpp @@ -221,7 +221,6 @@ void PortableMouse(float dx,float dy) mdx += dx; mdy += dy; - //Sys_QueEvent( t, SE_MOUSE, mx, my, 0, NULL ); } @@ -229,11 +228,13 @@ int absx=0,absy=0; void JKVR_GetScreenRes(int *width, int *height); void PortableMouseAbs(float x,float y) { - int width; - int height; - JKVR_GetScreenRes(&width, &height); - absx = x * width; - absy = y * height; + //int width; + //int height; + //JKVR_GetScreenRes(&width, &height); + absx = x * 640; + absy = y * 480; + + CL_MouseEvent(absx, absy, 0); } diff --git a/Projects/Android/jni/OpenJK/code/cgame/FxScheduler.cpp b/Projects/Android/jni/OpenJK/code/cgame/FxScheduler.cpp index 5942efd..5a6a156 100644 --- a/Projects/Android/jni/OpenJK/code/cgame/FxScheduler.cpp +++ b/Projects/Android/jni/OpenJK/code/cgame/FxScheduler.cpp @@ -1378,7 +1378,7 @@ void CFxScheduler::AddScheduledEffects( bool portal ) CreateEffect( effect->mpTemplate, effect->mClientID, theFxHelper.mTime - effect->mStartTime ); } - else if (effect->mBoltNum == -1) + else if (effect->mBoltNum == (char)-1) {// normal effect if ( effect->mEntNum != -1 ) // -1 { @@ -1397,7 +1397,7 @@ void CFxScheduler::AddScheduledEffects( bool portal ) else { //bolted on effect // do we need to go and re-get the bolt matrix again? Since it takes time lets try to do it only once - if ((effect->mModelNum != oldModelNum) || (effect->mEntNum != oldEntNum) || (effect->mBoltNum != oldBoltIndex)) + if ((effect->mModelNum != oldModelNum) || (effect->mEntNum != oldEntNum) || (effect->mBoltNum != (char)oldBoltIndex)) { const centity_t ¢ = cg_entities[effect->mEntNum]; if (cent.gent->ghoul2.IsValid()) diff --git a/Projects/Android/jni/OpenJK/code/client/cl_input.cpp b/Projects/Android/jni/OpenJK/code/client/cl_input.cpp index 5707644..d1194cf 100644 --- a/Projects/Android/jni/OpenJK/code/client/cl_input.cpp +++ b/Projects/Android/jni/OpenJK/code/client/cl_input.cpp @@ -438,14 +438,19 @@ void CL_KeyMove( usercmd_t *cmd ) { cmd->upmove = ClampChar( up ); } -void _UI_MouseEvent( int dx, int dy ); +void _UI_MouseEventAbs( int x, int y ); /* ================= CL_MouseEvent ================= */ -void CL_MouseEvent( int dx, int dy, int time ) { +void CL_MouseEvent( int x, int y, int time ) { + if ( Key_GetCatcher( ) & KEYCATCH_UI ) { + _UI_MouseEventAbs( x, y ); + } + + /* if ( Key_GetCatcher( ) & KEYCATCH_UI ) { _UI_MouseEvent( dx, dy ); } @@ -453,6 +458,7 @@ void CL_MouseEvent( int dx, int dy, int time ) { cl.mouseDx[cl.mouseIndex] += dx; cl.mouseDy[cl.mouseIndex] += dy; } + */ } /* diff --git a/Projects/Android/jni/OpenJK/code/rd-vanilla/tr_init.cpp b/Projects/Android/jni/OpenJK/code/rd-vanilla/tr_init.cpp index 0b1ffec..86e72ce 100644 --- a/Projects/Android/jni/OpenJK/code/rd-vanilla/tr_init.cpp +++ b/Projects/Android/jni/OpenJK/code/rd-vanilla/tr_init.cpp @@ -779,7 +779,7 @@ static void InitOpenGL( void ) // set default state GL_SetDefaultState(); - R_Splash(); //get something on screen asap + //R_Splash(); //get something on screen asap } else { diff --git a/Projects/Android/jni/OpenJK/code/ui/ui_local.h b/Projects/Android/jni/OpenJK/code/ui/ui_local.h index e39c4f9..acfabc0 100644 --- a/Projects/Android/jni/OpenJK/code/ui/ui_local.h +++ b/Projects/Android/jni/OpenJK/code/ui/ui_local.h @@ -212,6 +212,7 @@ extern uiInfo_t uiInfo; void _UI_Init( qboolean inGameLoad ); void _UI_DrawRect( float x, float y, float width, float height, float size, const float *color ); void _UI_MouseEvent( int dx, int dy ); +void _UI_MouseEventAbs( int x, int y ); void _UI_KeyEvent( int key, qboolean down ); void UI_Report(void); diff --git a/Projects/Android/jni/OpenJK/code/ui/ui_main.cpp b/Projects/Android/jni/OpenJK/code/ui/ui_main.cpp index 1b448b4..009433a 100644 --- a/Projects/Android/jni/OpenJK/code/ui/ui_main.cpp +++ b/Projects/Android/jni/OpenJK/code/ui/ui_main.cpp @@ -4037,6 +4037,44 @@ void _UI_MouseEvent( int dx, int dy ) } +/* +================= +UI_MouseEventAbs +================= +*/ +//JLFMOUSE CALLED EACH FRAME IN UI +void _UI_MouseEventAbs( int x, int y ) +{ + // update mouse screen position + uiInfo.uiDC.cursorx = x; + if (uiInfo.uiDC.cursorx < 0) + { + uiInfo.uiDC.cursorx = 0; + } + else if (uiInfo.uiDC.cursorx > SCREEN_WIDTH) + { + uiInfo.uiDC.cursorx = SCREEN_WIDTH; + } + + uiInfo.uiDC.cursory = y; + if (uiInfo.uiDC.cursory < 0) + { + uiInfo.uiDC.cursory = 0; + } + else if (uiInfo.uiDC.cursory > SCREEN_HEIGHT) + { + uiInfo.uiDC.cursory = SCREEN_HEIGHT; + } + + if (Menu_Count() > 0) + { + //menuDef_t *menu = Menu_GetFocused(); + //Menu_HandleMouseMove(menu, uiInfo.uiDC.cursorx, uiInfo.uiDC.cursory); + Display_MouseMove(NULL, uiInfo.uiDC.cursorx, uiInfo.uiDC.cursory); + } + +} + /* ================= UI_KeyEvent