diff --git a/app_pojavlauncher/src/main/assets/components/arc_dns_injector/version b/app_pojavlauncher/src/main/assets/components/arc_dns_injector/version index 02de90fae5..67353d36f5 100644 --- a/app_pojavlauncher/src/main/assets/components/arc_dns_injector/version +++ b/app_pojavlauncher/src/main/assets/components/arc_dns_injector/version @@ -1 +1 @@ -1687691695196 \ No newline at end of file +1716170694497 \ No newline at end of file diff --git a/app_pojavlauncher/src/main/assets/components/forge_installer/version b/app_pojavlauncher/src/main/assets/components/forge_installer/version index 50f4262789..f9ebf9a63a 100644 --- a/app_pojavlauncher/src/main/assets/components/forge_installer/version +++ b/app_pojavlauncher/src/main/assets/components/forge_installer/version @@ -1 +1 @@ -1692525087345 \ No newline at end of file +1716170694527 \ No newline at end of file diff --git a/app_pojavlauncher/src/main/assets/components/lwjgl3/version b/app_pojavlauncher/src/main/assets/components/lwjgl3/version index a0b3ccbded..dd8b53ff4f 100644 --- a/app_pojavlauncher/src/main/assets/components/lwjgl3/version +++ b/app_pojavlauncher/src/main/assets/components/lwjgl3/version @@ -1 +1 @@ -1703946470579 \ No newline at end of file +1716170694562 \ No newline at end of file diff --git a/app_pojavlauncher/src/main/jni/ctxbridges/gl_bridge.c b/app_pojavlauncher/src/main/jni/ctxbridges/gl_bridge.c index a0efdd9414..545a1dcd07 100644 --- a/app_pojavlauncher/src/main/jni/ctxbridges/gl_bridge.c +++ b/app_pojavlauncher/src/main/jni/ctxbridges/gl_bridge.c @@ -117,10 +117,10 @@ void gl_make_current(gl_render_window_t* bundle) { return; } bool hasSetMainWindow = false; - if(pojav_environ->mainWindowBundle == NULL) { - pojav_environ->mainWindowBundle = (basic_render_window_t*)bundle; - __android_log_print(ANDROID_LOG_INFO, g_LogTag, "Main window bundle is now %p", pojav_environ->mainWindowBundle); - pojav_environ->mainWindowBundle->newNativeSurface = pojav_environ->pojavWindow; + if(solcraft_environ->mainWindowBundle == NULL) { + solcraft_environ->mainWindowBundle = (basic_render_window_t*)bundle; + __android_log_print(ANDROID_LOG_INFO, g_LogTag, "Main window bundle is now %p", solcraft_environ->mainWindowBundle); + solcraft_environ->mainWindowBundle->newNativeSurface = solcraft_environ->pojavWindow; hasSetMainWindow = true; } __android_log_print(ANDROID_LOG_INFO, g_LogTag, "Making current, surface=%p, nativeSurface=%p, newNativeSurface=%p", bundle->surface, bundle->nativeSurface, bundle->newNativeSurface); @@ -131,9 +131,9 @@ void gl_make_current(gl_render_window_t* bundle) { currentBundle = bundle; }else { if(hasSetMainWindow) { - pojav_environ->mainWindowBundle->newNativeSurface = NULL; - gl_swap_surface((gl_render_window_t*)pojav_environ->mainWindowBundle); - pojav_environ->mainWindowBundle = NULL; + solcraft_environ->mainWindowBundle->newNativeSurface = NULL; + gl_swap_surface((gl_render_window_t*)solcraft_environ->mainWindowBundle); + solcraft_environ->mainWindowBundle = NULL; } __android_log_print(ANDROID_LOG_ERROR, g_LogTag, "eglMakeCurrent returned with error: %04x", eglGetError_p()); } @@ -159,15 +159,15 @@ void gl_swap_buffers() { } void gl_setup_window() { - if(pojav_environ->mainWindowBundle != NULL) { + if(solcraft_environ->mainWindowBundle != NULL) { __android_log_print(ANDROID_LOG_INFO, g_LogTag, "Main window bundle is not NULL, changing state"); - pojav_environ->mainWindowBundle->state = STATE_RENDERER_NEW_WINDOW; - pojav_environ->mainWindowBundle->newNativeSurface = pojav_environ->pojavWindow; + solcraft_environ->mainWindowBundle->state = STATE_RENDERER_NEW_WINDOW; + solcraft_environ->mainWindowBundle->newNativeSurface = solcraft_environ->pojavWindow; } } void gl_swap_interval(int swapInterval) { - if(pojav_environ->force_vsync) swapInterval = 1; + if(solcraft_environ->force_vsync) swapInterval = 1; eglSwapInterval_p(g_EglDisplay, swapInterval); } diff --git a/app_pojavlauncher/src/main/jni/ctxbridges/osm_bridge.c b/app_pojavlauncher/src/main/jni/ctxbridges/osm_bridge.c index 9f6e5c6137..eedb553d02 100644 --- a/app_pojavlauncher/src/main/jni/ctxbridges/osm_bridge.c +++ b/app_pojavlauncher/src/main/jni/ctxbridges/osm_bridge.c @@ -94,16 +94,16 @@ void osm_make_current(osm_render_window_t* bundle) { } bool hasSetMainWindow = false; currentBundle = bundle; - if(pojav_environ->mainWindowBundle == NULL) { - pojav_environ->mainWindowBundle = (basic_render_window_t*) bundle; - __android_log_print(ANDROID_LOG_INFO, g_LogTag, "Main window bundle is now %p", pojav_environ->mainWindowBundle); - pojav_environ->mainWindowBundle->newNativeSurface = pojav_environ->pojavWindow; + if(solcraft_environ->mainWindowBundle == NULL) { + solcraft_environ->mainWindowBundle = (basic_render_window_t*) bundle; + __android_log_print(ANDROID_LOG_INFO, g_LogTag, "Main window bundle is now %p", solcraft_environ->mainWindowBundle); + solcraft_environ->mainWindowBundle->newNativeSurface = solcraft_environ->pojavWindow; hasSetMainWindow = true; } if(bundle->nativeSurface == NULL) { //prepare the buffer for our first render! osm_swap_surfaces(bundle); - if(hasSetMainWindow) pojav_environ->mainWindowBundle->state = STATE_RENDERER_ALIVE; + if(hasSetMainWindow) solcraft_environ->mainWindowBundle->state = STATE_RENDERER_ALIVE; } osm_set_no_render_buffer(&bundle->buffer); osm_apply_current_ll(); @@ -129,15 +129,15 @@ void osm_swap_buffers() { } void osm_setup_window() { - if(pojav_environ->mainWindowBundle != NULL) { + if(solcraft_environ->mainWindowBundle != NULL) { __android_log_print(ANDROID_LOG_INFO, g_LogTag, "Main window bundle is not NULL, changing state"); - pojav_environ->mainWindowBundle->state = STATE_RENDERER_NEW_WINDOW; - pojav_environ->mainWindowBundle->newNativeSurface = pojav_environ->pojavWindow; + solcraft_environ->mainWindowBundle->state = STATE_RENDERER_NEW_WINDOW; + solcraft_environ->mainWindowBundle->newNativeSurface = solcraft_environ->pojavWindow; } } void osm_swap_interval(int swapInterval) { - if(pojav_environ->mainWindowBundle != NULL && pojav_environ->mainWindowBundle->nativeSurface != NULL) { - setNativeWindowSwapInterval(pojav_environ->mainWindowBundle->nativeSurface, swapInterval); + if(solcraft_environ->mainWindowBundle != NULL && solcraft_environ->mainWindowBundle->nativeSurface != NULL) { + setNativeWindowSwapInterval(solcraft_environ->mainWindowBundle->nativeSurface, swapInterval); } } \ No newline at end of file diff --git a/app_pojavlauncher/src/main/jni/ctxbridges/osmesa_loader.c b/app_pojavlauncher/src/main/jni/ctxbridges/osmesa_loader.c index 764be70762..d5d6d6f58f 100644 --- a/app_pojavlauncher/src/main/jni/ctxbridges/osmesa_loader.c +++ b/app_pojavlauncher/src/main/jni/ctxbridges/osmesa_loader.c @@ -23,13 +23,13 @@ void (*glReadPixels_p) (GLint x, GLint y, GLsizei width, GLsizei height, GLenum void dlsym_OSMesa() { char* main_osm_libname = getenv("POJAVEXEC_OSMESA"); char* main_path = NULL; - if(pojav_environ->config_renderer == RENDERER_VK_ZINK) { + if(solcraft_environ->config_renderer == RENDERER_VK_ZINK) { if(main_osm_libname == NULL) main_osm_libname = "libOSMesa.so"; if(asprintf(&main_path, "%s/%s", getenv("POJAV_NATIVEDIR"), main_osm_libname) == -1) { abort(); } free(main_path); - } else if(pojav_environ->config_renderer == RENDERER_VIRGL) { + } else if(solcraft_environ->config_renderer == RENDERER_VIRGL) { if(asprintf(&main_path, "%s/libOSMesa_znL.so", getenv("POJAV_NATIVEDIR")) == -1) { abort(); } diff --git a/app_pojavlauncher/src/main/jni/egl_bridge.c b/app_pojavlauncher/src/main/jni/egl_bridge.c index e5443ce4f1..c851545607 100644 --- a/app_pojavlauncher/src/main/jni/egl_bridge.c +++ b/app_pojavlauncher/src/main/jni/egl_bridge.c @@ -70,7 +70,7 @@ void* egl_make_current(void* window); EXTERNAL_API void pojavTerminate() { printf("EGLBridge: Terminating\n"); - switch (pojav_environ->config_renderer) { + switch (solcraft_environ->config_renderer) { case RENDERER_GL4ES: { eglMakeCurrent_p(potatoBridge.eglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); eglDestroySurface_p(potatoBridge.eglDisplay, potatoBridge.eglSurface); @@ -91,14 +91,14 @@ EXTERNAL_API void pojavTerminate() { } JNIEXPORT void JNICALL Java_net_kdt_pojavlaunch_utils_JREUtils_setupBridgeWindow(JNIEnv* env, ABI_COMPAT jclass clazz, jobject surface) { - pojav_environ->pojavWindow = ANativeWindow_fromSurface(env, surface); + solcraft_environ->pojavWindow = ANativeWindow_fromSurface(env, surface); if(br_setup_window != NULL) br_setup_window(); } JNIEXPORT void JNICALL Java_net_kdt_pojavlaunch_utils_JREUtils_releaseBridgeWindow(ABI_COMPAT JNIEnv *env, ABI_COMPAT jclass clazz) { - ANativeWindow_release(pojav_environ->pojavWindow); + ANativeWindow_release(solcraft_environ->pojavWindow); } /*If you don't want your renderer for @@ -106,16 +106,16 @@ the Mesa class to crash in your launcher don't touch the code here */ EXTERNAL_API void* pojavGetCurrentContext() { - if(pojav_environ->config_renderer == RENDERER_VK_ZINK || pojav_environ->config_renderer == RENDERER_GL4ES) { + if(solcraft_environ->config_renderer == RENDERER_VK_ZINK || solcraft_environ->config_renderer == RENDERER_GL4ES) { return br_get_current(); - } else if(pojav_environ->config_renderer == RENDERER_VIRGL) { + } else if(solcraft_environ->config_renderer == RENDERER_VIRGL) { return (void *)OSMesaGetCurrentContext_p(); } } //Switches specifically provided for other renderers void loadSymbols() { - switch (pojav_environ->config_renderer) { + switch (solcraft_environ->config_renderer) { case RENDERER_VIRGL: dlsym_OSMesa(); dlsym_EGL(); @@ -216,7 +216,7 @@ void load_vulkan() { } bool loadSymbolsVirGL() { - pojav_environ->config_renderer = RENDERER_VIRGL; + solcraft_environ->config_renderer = RENDERER_VIRGL; loadSymbols(); char* fileName = calloc(1, 1024); @@ -237,12 +237,12 @@ int pojavInitOpenGL() { // Only affects GL4ES as of now const char *forceVsync = getenv("FORCE_VSYNC"); if (strcmp(forceVsync, "true") == 0) - pojav_environ->force_vsync = true; + solcraft_environ->force_vsync = true; // NOTE: Override for now. const char *renderer = getenv("POJAV_RENDERER"); if (strncmp("virgl", renderer, 15) == 0) { - pojav_environ->config_renderer = RENDERER_VIRGL; + solcraft_environ->config_renderer = RENDERER_VIRGL; setenv("GALLIUM_DRIVER","virpipe",1); #ifndef ADRENO_POSSIBLE setenv("MESA_GL_VERSION_OVERRIDE", "3.3", 0); @@ -254,17 +254,17 @@ int pojavInitOpenGL() { } loadSymbolsVirGL(); } else if (strncmp("opengles", renderer, 8) == 0) { - pojav_environ->config_renderer = RENDERER_GL4ES; + solcraft_environ->config_renderer = RENDERER_GL4ES; set_gl_bridge_tbl(); } else if (strcmp(renderer, "vulkan_zink") == 0 || strcmp(renderer, "vulkan_zink_standard") == 0) { - pojav_environ->config_renderer = RENDERER_VK_ZINK; + solcraft_environ->config_renderer = RENDERER_VK_ZINK; load_vulkan(); setenv("MESA_LOADER_DRIVER_OVERRIDE","zink",1); setenv("GALLIUM_DRIVER","zink",1); set_osm_bridge_tbl(); } else if (strcmp(renderer, "vulkan_zink_legacy") == 0) { setenv("POJAV_ZINK_PREFER_SYSTEM_DRIVER", "1", 1); - pojav_environ->config_renderer = RENDERER_VK_ZINK; + solcraft_environ->config_renderer = RENDERER_VK_ZINK; load_vulkan(); setenv("MESA_LOADER_DRIVER_OVERRIDE","zink",1); setenv("GALLIUM_DRIVER","zink",1); @@ -272,22 +272,22 @@ int pojavInitOpenGL() { setenv("MESA_GLSL_VERSION_OVERRIDE", "150",false); set_osm_bridge_tbl(); } else if (strcmp(renderer, "malihw_panfrost") == 0) { - pojav_environ->config_renderer = RENDERER_VK_ZINK; + solcraft_environ->config_renderer = RENDERER_VK_ZINK; setenv("GALLIUM_DRIVER", "panfrost", 1); setenv("PAN_DEBUG","gofaster",1); set_osm_bridge_tbl(); } else if (strcmp(renderer, "adrhw_freedreno") == 0) { - pojav_environ->config_renderer = RENDERER_VK_ZINK; + solcraft_environ->config_renderer = RENDERER_VK_ZINK; setenv("GALLIUM_DRIVER", "freedreno", 1); setenv("MESA_LOADER_DRIVER_OVERRIDE", "kgsl", 1); set_osm_bridge_tbl(); } - if(pojav_environ->config_renderer == RENDERER_VK_ZINK || pojav_environ->config_renderer == RENDERER_GL4ES) { + if(solcraft_environ->config_renderer == RENDERER_VK_ZINK || solcraft_environ->config_renderer == RENDERER_GL4ES) { if(br_init()) { br_setup_window(); } } - if (pojav_environ->config_renderer == RENDERER_VIRGL) { + if (solcraft_environ->config_renderer == RENDERER_VIRGL) { if (potatoBridge.eglDisplay == NULL || potatoBridge.eglDisplay == EGL_NO_DISPLAY) { potatoBridge.eglDisplay = eglGetDisplay_p(EGL_DEFAULT_DISPLAY); if (potatoBridge.eglDisplay == EGL_NO_DISPLAY) { @@ -297,7 +297,7 @@ int pojavInitOpenGL() { } printf("EGLBridge: Initializing\n"); - // printf("EGLBridge: ANativeWindow pointer = %p\n", pojav_environ->pojavWindow); + // printf("EGLBridge: ANativeWindow pointer = %p\n", solcraft_environ->pojavWindow); //(*env)->ThrowNew(env,(*env)->FindClass(env,"java/lang/Exception"),"Trace exception"); if (!eglInitialize_p(potatoBridge.eglDisplay, NULL, NULL)) { printf("EGLBridge: Error eglInitialize() failed: %s\n", eglGetError_p()); @@ -331,11 +331,11 @@ int pojavInitOpenGL() { return 0; } - ANativeWindow_setBuffersGeometry(pojav_environ->pojavWindow, 0, 0, vid); + ANativeWindow_setBuffersGeometry(solcraft_environ->pojavWindow, 0, 0, vid); eglBindAPI_p(EGL_OPENGL_ES_API); - potatoBridge.eglSurface = eglCreateWindowSurface_p(potatoBridge.eglDisplay, config, pojav_environ->pojavWindow, NULL); + potatoBridge.eglSurface = eglCreateWindowSurface_p(potatoBridge.eglDisplay, config, solcraft_environ->pojavWindow, NULL); if (!potatoBridge.eglSurface) { printf("EGLBridge: Error eglCreateWindowSurface failed: %p\n", eglGetError_p()); @@ -357,12 +357,12 @@ int pojavInitOpenGL() { potatoBridge.eglDisplay, potatoBridge.eglSurface ); - if (pojav_environ->config_renderer != RENDERER_VIRGL) { + if (solcraft_environ->config_renderer != RENDERER_VIRGL) { return 1; } } - if (pojav_environ->config_renderer == RENDERER_VIRGL) { + if (solcraft_environ->config_renderer == RENDERER_VIRGL) { // Init EGL context and vtest server const EGLint ctx_attribs[] = { EGL_CONTEXT_CLIENT_VERSION, 3, @@ -376,14 +376,14 @@ int pojavInitOpenGL() { usleep(100*1000); // need enough time for the server to init } - if (pojav_environ->config_renderer == RENDERER_VIRGL) { + if (solcraft_environ->config_renderer == RENDERER_VIRGL) { if(OSMesaCreateContext_p == NULL) { printf("OSMDroid: %s\n",dlerror()); return 0; } - printf("OSMDroid: width=%i;height=%i, reserving %i bytes for frame buffer\n", pojav_environ->savedWidth, pojav_environ->savedHeight, - pojav_environ->savedWidth * 4 * pojav_environ->savedHeight); - gbuffer = calloc(pojav_environ->savedWidth *4, pojav_environ->savedHeight +1); + printf("OSMDroid: width=%i;height=%i, reserving %i bytes for frame buffer\n", solcraft_environ->savedWidth, solcraft_environ->savedHeight, + solcraft_environ->savedWidth * 4 * solcraft_environ->savedHeight); + gbuffer = calloc(solcraft_environ->savedWidth *4, solcraft_environ->savedHeight +1); if (gbuffer) { printf("OSMDroid: created frame buffer\n"); return 1; @@ -397,10 +397,10 @@ int pojavInitOpenGL() { } EXTERNAL_API int pojavInit() { - ANativeWindow_acquire(pojav_environ->pojavWindow); - pojav_environ->savedWidth = ANativeWindow_getWidth(pojav_environ->pojavWindow); - pojav_environ->savedHeight = ANativeWindow_getHeight(pojav_environ->pojavWindow); - ANativeWindow_setBuffersGeometry(pojav_environ->pojavWindow,pojav_environ->savedWidth,pojav_environ->savedHeight,AHARDWAREBUFFER_FORMAT_R8G8B8X8_UNORM); + ANativeWindow_acquire(solcraft_environ->pojavWindow); + solcraft_environ->savedWidth = ANativeWindow_getWidth(solcraft_environ->pojavWindow); + solcraft_environ->savedHeight = ANativeWindow_getHeight(solcraft_environ->pojavWindow); + ANativeWindow_setBuffersGeometry(solcraft_environ->pojavWindow,solcraft_environ->savedWidth,solcraft_environ->savedHeight,AHARDWAREBUFFER_FORMAT_R8G8B8X8_UNORM); pojavInitOpenGL(); return 1; } @@ -409,7 +409,7 @@ EXTERNAL_API void pojavSetWindowHint(int hint, int value) { if (hint != GLFW_CLIENT_API) return; switch (value) { case GLFW_NO_API: - pojav_environ->config_renderer = RENDERER_VULKAN; + solcraft_environ->config_renderer = RENDERER_VULKAN; /* Nothing to do: initialization is handled in Java-side */ // pojavInitVulkan(); break; @@ -430,9 +430,9 @@ EXTERNAL_API void pojavSwapBuffers() { if (stopSwapBuffers) { return; } - if(pojav_environ->config_renderer == RENDERER_VK_ZINK || pojav_environ->config_renderer == RENDERER_GL4ES) { + if(solcraft_environ->config_renderer == RENDERER_VK_ZINK || solcraft_environ->config_renderer == RENDERER_GL4ES) { br_swap_buffers(); - } else if(pojav_environ->config_renderer == RENDERER_VIRGL) { + } else if(solcraft_environ->config_renderer == RENDERER_VIRGL) { glFinish_p(); vtest_swap_buffers_p(); } @@ -452,7 +452,7 @@ void* egl_make_current(void* window) { printf("EGLBridge: eglMakeCurrent() succeed!\n"); } - if (pojav_environ->config_renderer == RENDERER_VIRGL) { + if (solcraft_environ->config_renderer == RENDERER_VIRGL) { printf("VirGL: vtest_main = %p\n", vtest_main_p); printf("VirGL: Calling VTest server's main function\n"); vtest_main_p(3, (const char*[]){"vtest", "--no-loop-or-fork", "--use-gles", NULL, NULL}); @@ -461,11 +461,11 @@ void* egl_make_current(void* window) { EXTERNAL_API void pojavMakeCurrent(void* window) { if(getenv("POJAV_BIG_CORE_AFFINITY") != NULL) bigcore_set_affinity(); - if(pojav_environ->config_renderer == RENDERER_VK_ZINK || pojav_environ->config_renderer == RENDERER_GL4ES) { + if(solcraft_environ->config_renderer == RENDERER_VK_ZINK || solcraft_environ->config_renderer == RENDERER_GL4ES) { br_make_current((basic_render_window_t*)window); - } else if(pojav_environ->config_renderer == RENDERER_VIRGL) { + } else if(solcraft_environ->config_renderer == RENDERER_VIRGL) { printf("OSMDroid: making current\n"); - OSMesaMakeCurrent_p((OSMesaContext)window,gbuffer,GL_UNSIGNED_BYTE,pojav_environ->savedWidth,pojav_environ->savedHeight); + OSMesaMakeCurrent_p((OSMesaContext)window,gbuffer,GL_UNSIGNED_BYTE,solcraft_environ->savedWidth,solcraft_environ->savedHeight); printf("OSMDroid: vendor: %s\n",glGetString_p(GL_VENDOR)); printf("OSMDroid: renderer: %s\n",glGetString_p(GL_RENDERER)); glClear_p(GL_COLOR_BUFFER_BIT); @@ -481,13 +481,13 @@ EXTERNAL_API void pojavMakeCurrent(void* window) { } EXTERNAL_API void* pojavCreateContext(void* contextSrc) { - if (pojav_environ->config_renderer == RENDERER_VULKAN) { - return (void *) pojav_environ->pojavWindow; + if (solcraft_environ->config_renderer == RENDERER_VULKAN) { + return (void *) solcraft_environ->pojavWindow; } - if (pojav_environ->config_renderer == RENDERER_VK_ZINK || pojav_environ->config_renderer == RENDERER_GL4ES) { + if (solcraft_environ->config_renderer == RENDERER_VK_ZINK || solcraft_environ->config_renderer == RENDERER_GL4ES) { return br_init_context((basic_render_window_t*)contextSrc); - } else if (pojav_environ->config_renderer == RENDERER_VIRGL) { + } else if (solcraft_environ->config_renderer == RENDERER_VIRGL) { pojavInitOpenGL(); printf("OSMDroid: generating context\n"); void* ctx = OSMesaCreateContext_p(OSMESA_RGBA,contextSrc); @@ -508,7 +508,7 @@ Java_org_lwjgl_vulkan_VK_getVulkanDriverHandle(ABI_COMPAT JNIEnv *env, ABI_COMPA EXTERNAL_API JNIEXPORT void JNICALL Java_org_lwjgl_opengl_GL_nativeRegalMakeCurrent(JNIEnv *env, jclass clazz) { - if (pojav_environ->config_renderer == RENDERER_VIRGL) { + if (solcraft_environ->config_renderer == RENDERER_VIRGL) { /*printf("Regal: making current"); RegalMakeCurrent_func *RegalMakeCurrent = (RegalMakeCurrent_func *) dlsym(RTLD_DEFAULT, "RegalMakeCurrent"); @@ -521,25 +521,25 @@ Java_org_lwjgl_opengl_GL_nativeRegalMakeCurrent(JNIEnv *env, jclass clazz) { EXTERNAL_API JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_GL_getGraphicsBufferAddr(JNIEnv *env, jobject thiz) { - if (pojav_environ->config_renderer == RENDERER_VIRGL) { + if (solcraft_environ->config_renderer == RENDERER_VIRGL) { return &gbuffer; } } EXTERNAL_API JNIEXPORT jintArray JNICALL Java_org_lwjgl_opengl_GL_getNativeWidthHeight(JNIEnv *env, jobject thiz) { - if (pojav_environ->config_renderer == RENDERER_VIRGL) { + if (solcraft_environ->config_renderer == RENDERER_VIRGL) { jintArray ret = (*env)->NewIntArray(env,2); - jint arr[] = {pojav_environ->savedWidth, pojav_environ->savedHeight}; + jint arr[] = {solcraft_environ->savedWidth, solcraft_environ->savedHeight}; (*env)->SetIntArrayRegion(env,ret,0,2,arr); return ret; } } EXTERNAL_API void pojavSwapInterval(int interval) { - if(pojav_environ->config_renderer == RENDERER_VK_ZINK || pojav_environ->config_renderer == RENDERER_GL4ES) { + if(solcraft_environ->config_renderer == RENDERER_VK_ZINK || solcraft_environ->config_renderer == RENDERER_GL4ES) { br_swap_interval(interval); - } else if(pojav_environ->config_renderer == RENDERER_VIRGL) { + } else if(solcraft_environ->config_renderer == RENDERER_VIRGL) { eglSwapInterval_p(potatoBridge.eglDisplay, interval); } } \ No newline at end of file diff --git a/app_pojavlauncher/src/main/jni/environ/environ.c b/app_pojavlauncher/src/main/jni/environ/environ.c index 72633d78fa..ed28207b97 100644 --- a/app_pojavlauncher/src/main/jni/environ/environ.c +++ b/app_pojavlauncher/src/main/jni/environ/environ.c @@ -7,20 +7,20 @@ #include #include #include "environ.h" -struct pojav_environ_s *pojav_environ; +struct solcraft_environ_s *solcraft_environ; __attribute__((constructor)) void env_init() { - char* strptr_env = getenv("POJAV_ENVIRON"); + char* strptr_env = getenv("SCL_ENVIRON"); if(strptr_env == NULL) { __android_log_print(ANDROID_LOG_INFO, "Environ", "No environ found, creating..."); - pojav_environ = malloc(sizeof(struct pojav_environ_s)); - assert(pojav_environ); - memset(pojav_environ, 0 , sizeof(struct pojav_environ_s)); - if(asprintf(&strptr_env, "%p", pojav_environ) == -1) abort(); - setenv("POJAV_ENVIRON", strptr_env, 1); + solcraft_environ = malloc(sizeof(struct solcraft_environ_s)); + assert(solcraft_environ); + memset(solcraft_environ, 0 , sizeof(struct solcraft_environ_s)); + if(asprintf(&strptr_env, "%p", solcraft_environ) == -1) abort(); + setenv("SCL_ENVIRON", strptr_env, 1); free(strptr_env); }else{ __android_log_print(ANDROID_LOG_INFO, "Environ", "Found existing environ: %s", strptr_env); - pojav_environ = (void*) strtoul(strptr_env, NULL, 0x10); + solcraft_environ = (void*) strtoul(strptr_env, NULL, 0x10); } - __android_log_print(ANDROID_LOG_INFO, "Environ", "%p", pojav_environ); + __android_log_print(ANDROID_LOG_INFO, "Environ", "%p", solcraft_environ); } \ No newline at end of file diff --git a/app_pojavlauncher/src/main/jni/environ/environ.h b/app_pojavlauncher/src/main/jni/environ/environ.h index c49ff8aaba..c1b0fbe260 100644 --- a/app_pojavlauncher/src/main/jni/environ/environ.h +++ b/app_pojavlauncher/src/main/jni/environ/environ.h @@ -30,7 +30,7 @@ typedef void GLFW_invoke_MouseButton_func(void* window, int button, int action, typedef void GLFW_invoke_Scroll_func(void* window, double xoffset, double yoffset); typedef void GLFW_invoke_WindowSize_func(void* window, int width, int height); -struct pojav_environ_s { +struct solcraft_environ_s { struct ANativeWindow* pojavWindow; basic_render_window_t* mainWindowBundle; int config_renderer; @@ -72,6 +72,6 @@ struct pojav_environ_s { #undef ADD_CALLBACK_WWIN }; -extern struct pojav_environ_s *pojav_environ; +extern struct solcraft_environ_s *solcraft_environ; #endif //POJAVLAUNCHER_ENVIRON_H diff --git a/app_pojavlauncher/src/main/jni/input_bridge_v3.c b/app_pojavlauncher/src/main/jni/input_bridge_v3.c index ef708d250e..5e13b1ad26 100644 --- a/app_pojavlauncher/src/main/jni/input_bridge_v3.c +++ b/app_pojavlauncher/src/main/jni/input_bridge_v3.c @@ -37,48 +37,48 @@ jint (*orig_ProcessImpl_forkAndExec)(JNIEnv *env, jobject process, jint mode, jb static void registerFunctions(JNIEnv *env); jint JNI_OnLoad(JavaVM* vm, __attribute__((unused)) void* reserved) { - if (pojav_environ->dalvikJavaVMPtr == NULL) { + if (solcraft_environ->dalvikJavaVMPtr == NULL) { __android_log_print(ANDROID_LOG_INFO, "Native", "Saving DVM environ..."); //Save dalvik global JavaVM pointer - pojav_environ->dalvikJavaVMPtr = vm; - (*vm)->GetEnv(vm, (void**) &pojav_environ->dalvikJNIEnvPtr_ANDROID, JNI_VERSION_1_4); - pojav_environ->bridgeClazz = (*pojav_environ->dalvikJNIEnvPtr_ANDROID)->NewGlobalRef(pojav_environ->dalvikJNIEnvPtr_ANDROID,(*pojav_environ->dalvikJNIEnvPtr_ANDROID) ->FindClass(pojav_environ->dalvikJNIEnvPtr_ANDROID,"org/lwjgl/glfw/CallbackBridge")); - pojav_environ->method_accessAndroidClipboard = (*pojav_environ->dalvikJNIEnvPtr_ANDROID)->GetStaticMethodID(pojav_environ->dalvikJNIEnvPtr_ANDROID, pojav_environ->bridgeClazz, "accessAndroidClipboard", "(ILjava/lang/String;)Ljava/lang/String;"); - pojav_environ->method_onGrabStateChanged = (*pojav_environ->dalvikJNIEnvPtr_ANDROID)->GetStaticMethodID(pojav_environ->dalvikJNIEnvPtr_ANDROID, pojav_environ->bridgeClazz, "onGrabStateChanged", "(Z)V"); - pojav_environ->isUseStackQueueCall = JNI_FALSE; - } else if (pojav_environ->dalvikJavaVMPtr != vm) { + solcraft_environ->dalvikJavaVMPtr = vm; + (*vm)->GetEnv(vm, (void**) &solcraft_environ->dalvikJNIEnvPtr_ANDROID, JNI_VERSION_1_4); + solcraft_environ->bridgeClazz = (*solcraft_environ->dalvikJNIEnvPtr_ANDROID)->NewGlobalRef(solcraft_environ->dalvikJNIEnvPtr_ANDROID,(*solcraft_environ->dalvikJNIEnvPtr_ANDROID) ->FindClass(solcraft_environ->dalvikJNIEnvPtr_ANDROID,"org/lwjgl/glfw/CallbackBridge")); + solcraft_environ->method_accessAndroidClipboard = (*solcraft_environ->dalvikJNIEnvPtr_ANDROID)->GetStaticMethodID(solcraft_environ->dalvikJNIEnvPtr_ANDROID, solcraft_environ->bridgeClazz, "accessAndroidClipboard", "(ILjava/lang/String;)Ljava/lang/String;"); + solcraft_environ->method_onGrabStateChanged = (*solcraft_environ->dalvikJNIEnvPtr_ANDROID)->GetStaticMethodID(solcraft_environ->dalvikJNIEnvPtr_ANDROID, solcraft_environ->bridgeClazz, "onGrabStateChanged", "(Z)V"); + solcraft_environ->isUseStackQueueCall = JNI_FALSE; + } else if (solcraft_environ->dalvikJavaVMPtr != vm) { __android_log_print(ANDROID_LOG_INFO, "Native", "Saving JVM environ..."); - pojav_environ->runtimeJavaVMPtr = vm; - (*vm)->GetEnv(vm, (void**) &pojav_environ->runtimeJNIEnvPtr_JRE, JNI_VERSION_1_4); - pojav_environ->vmGlfwClass = (*pojav_environ->runtimeJNIEnvPtr_JRE)->NewGlobalRef(pojav_environ->runtimeJNIEnvPtr_JRE, (*pojav_environ->runtimeJNIEnvPtr_JRE)->FindClass(pojav_environ->runtimeJNIEnvPtr_JRE, "org/lwjgl/glfw/GLFW")); - pojav_environ->method_glftSetWindowAttrib = (*pojav_environ->runtimeJNIEnvPtr_JRE)->GetStaticMethodID(pojav_environ->runtimeJNIEnvPtr_JRE, pojav_environ->vmGlfwClass, "glfwSetWindowAttrib", "(JII)V"); - pojav_environ->method_internalWindowSizeChanged = (*pojav_environ->runtimeJNIEnvPtr_JRE)->GetStaticMethodID(pojav_environ->runtimeJNIEnvPtr_JRE, pojav_environ->vmGlfwClass, "internalWindowSizeChanged", "(JII)V"); - jfieldID field_keyDownBuffer = (*pojav_environ->runtimeJNIEnvPtr_JRE)->GetStaticFieldID(pojav_environ->runtimeJNIEnvPtr_JRE, pojav_environ->vmGlfwClass, "keyDownBuffer", "Ljava/nio/ByteBuffer;"); - jobject keyDownBufferJ = (*pojav_environ->runtimeJNIEnvPtr_JRE)->GetStaticObjectField(pojav_environ->runtimeJNIEnvPtr_JRE, pojav_environ->vmGlfwClass, field_keyDownBuffer); - pojav_environ->keyDownBuffer = (*pojav_environ->runtimeJNIEnvPtr_JRE)->GetDirectBufferAddress(pojav_environ->runtimeJNIEnvPtr_JRE, keyDownBufferJ); - jfieldID field_mouseDownBuffer = (*pojav_environ->runtimeJNIEnvPtr_JRE)->GetStaticFieldID(pojav_environ->runtimeJNIEnvPtr_JRE, pojav_environ->vmGlfwClass, "mouseDownBuffer", "Ljava/nio/ByteBuffer;"); - jobject mouseDownBufferJ = (*pojav_environ->runtimeJNIEnvPtr_JRE)->GetStaticObjectField(pojav_environ->runtimeJNIEnvPtr_JRE, pojav_environ->vmGlfwClass, field_mouseDownBuffer); - pojav_environ->mouseDownBuffer = (*pojav_environ->runtimeJNIEnvPtr_JRE)->GetDirectBufferAddress(pojav_environ->runtimeJNIEnvPtr_JRE, mouseDownBufferJ); + solcraft_environ->runtimeJavaVMPtr = vm; + (*vm)->GetEnv(vm, (void**) &solcraft_environ->runtimeJNIEnvPtr_JRE, JNI_VERSION_1_4); + solcraft_environ->vmGlfwClass = (*solcraft_environ->runtimeJNIEnvPtr_JRE)->NewGlobalRef(solcraft_environ->runtimeJNIEnvPtr_JRE, (*solcraft_environ->runtimeJNIEnvPtr_JRE)->FindClass(solcraft_environ->runtimeJNIEnvPtr_JRE, "org/lwjgl/glfw/GLFW")); + solcraft_environ->method_glftSetWindowAttrib = (*solcraft_environ->runtimeJNIEnvPtr_JRE)->GetStaticMethodID(solcraft_environ->runtimeJNIEnvPtr_JRE, solcraft_environ->vmGlfwClass, "glfwSetWindowAttrib", "(JII)V"); + solcraft_environ->method_internalWindowSizeChanged = (*solcraft_environ->runtimeJNIEnvPtr_JRE)->GetStaticMethodID(solcraft_environ->runtimeJNIEnvPtr_JRE, solcraft_environ->vmGlfwClass, "internalWindowSizeChanged", "(JII)V"); + jfieldID field_keyDownBuffer = (*solcraft_environ->runtimeJNIEnvPtr_JRE)->GetStaticFieldID(solcraft_environ->runtimeJNIEnvPtr_JRE, solcraft_environ->vmGlfwClass, "keyDownBuffer", "Ljava/nio/ByteBuffer;"); + jobject keyDownBufferJ = (*solcraft_environ->runtimeJNIEnvPtr_JRE)->GetStaticObjectField(solcraft_environ->runtimeJNIEnvPtr_JRE, solcraft_environ->vmGlfwClass, field_keyDownBuffer); + solcraft_environ->keyDownBuffer = (*solcraft_environ->runtimeJNIEnvPtr_JRE)->GetDirectBufferAddress(solcraft_environ->runtimeJNIEnvPtr_JRE, keyDownBufferJ); + jfieldID field_mouseDownBuffer = (*solcraft_environ->runtimeJNIEnvPtr_JRE)->GetStaticFieldID(solcraft_environ->runtimeJNIEnvPtr_JRE, solcraft_environ->vmGlfwClass, "mouseDownBuffer", "Ljava/nio/ByteBuffer;"); + jobject mouseDownBufferJ = (*solcraft_environ->runtimeJNIEnvPtr_JRE)->GetStaticObjectField(solcraft_environ->runtimeJNIEnvPtr_JRE, solcraft_environ->vmGlfwClass, field_mouseDownBuffer); + solcraft_environ->mouseDownBuffer = (*solcraft_environ->runtimeJNIEnvPtr_JRE)->GetDirectBufferAddress(solcraft_environ->runtimeJNIEnvPtr_JRE, mouseDownBufferJ); hookExec(); installLinkerBugMitigation(); installEMUIIteratorMititgation(); } - if(pojav_environ->dalvikJavaVMPtr == vm) { + if(solcraft_environ->dalvikJavaVMPtr == vm) { //perform in all DVM instances, not only during first ever set up JNIEnv *env; (*vm)->GetEnv(vm, (void**) &env, JNI_VERSION_1_4); registerFunctions(env); } - pojav_environ->isGrabbing = JNI_FALSE; + solcraft_environ->isGrabbing = JNI_FALSE; return JNI_VERSION_1_4; } #define ADD_CALLBACK_WWIN(NAME) \ JNIEXPORT jlong JNICALL Java_org_lwjgl_glfw_GLFW_nglfwSet##NAME##Callback(JNIEnv * env, jclass cls, jlong window, jlong callbackptr) { \ - void** oldCallback = (void**) &pojav_environ->GLFW_invoke_##NAME; \ - pojav_environ->GLFW_invoke_##NAME = (GLFW_invoke_##NAME##_func*) (uintptr_t) callbackptr; \ + void** oldCallback = (void**) &solcraft_environ->GLFW_invoke_##NAME; \ + solcraft_environ->GLFW_invoke_##NAME = (GLFW_invoke_##NAME##_func*) (uintptr_t) callbackptr; \ return (jlong) (uintptr_t) *oldCallback; \ } @@ -95,50 +95,50 @@ ADD_CALLBACK_WWIN(WindowSize) #undef ADD_CALLBACK_WWIN void handleFramebufferSizeJava(long window, int w, int h) { - (*pojav_environ->runtimeJNIEnvPtr_JRE)->CallStaticVoidMethod(pojav_environ->runtimeJNIEnvPtr_JRE, pojav_environ->vmGlfwClass, pojav_environ->method_internalWindowSizeChanged, (long)window, w, h); + (*solcraft_environ->runtimeJNIEnvPtr_JRE)->CallStaticVoidMethod(solcraft_environ->runtimeJNIEnvPtr_JRE, solcraft_environ->vmGlfwClass, solcraft_environ->method_internalWindowSizeChanged, (long)window, w, h); } void pojavPumpEvents(void* window) { - if(pojav_environ->isPumpingEvents) return; + if(solcraft_environ->isPumpingEvents) return; // prevent further calls until we exit the loop // by spec, they will be called on the same thread so no synchronization here - pojav_environ->isPumpingEvents = true; + solcraft_environ->isPumpingEvents = true; - if((pojav_environ->cLastX != pojav_environ->cursorX || pojav_environ->cLastY != pojav_environ->cursorY) && pojav_environ->GLFW_invoke_CursorPos) { - pojav_environ->cLastX = pojav_environ->cursorX; - pojav_environ->cLastY = pojav_environ->cursorY; - pojav_environ->GLFW_invoke_CursorPos(window, floor(pojav_environ->cursorX), - floor(pojav_environ->cursorY)); + if((solcraft_environ->cLastX != solcraft_environ->cursorX || solcraft_environ->cLastY != solcraft_environ->cursorY) && solcraft_environ->GLFW_invoke_CursorPos) { + solcraft_environ->cLastX = solcraft_environ->cursorX; + solcraft_environ->cLastY = solcraft_environ->cursorY; + solcraft_environ->GLFW_invoke_CursorPos(window, floor(solcraft_environ->cursorX), + floor(solcraft_environ->cursorY)); } - size_t index = pojav_environ->outEventIndex; - size_t targetIndex = pojav_environ->outTargetIndex; + size_t index = solcraft_environ->outEventIndex; + size_t targetIndex = solcraft_environ->outTargetIndex; while (targetIndex != index) { - GLFWInputEvent event = pojav_environ->events[index]; + GLFWInputEvent event = solcraft_environ->events[index]; switch (event.type) { case EVENT_TYPE_CHAR: - if(pojav_environ->GLFW_invoke_Char) pojav_environ->GLFW_invoke_Char(window, event.i1); + if(solcraft_environ->GLFW_invoke_Char) solcraft_environ->GLFW_invoke_Char(window, event.i1); break; case EVENT_TYPE_CHAR_MODS: - if(pojav_environ->GLFW_invoke_CharMods) pojav_environ->GLFW_invoke_CharMods(window, event.i1, event.i2); + if(solcraft_environ->GLFW_invoke_CharMods) solcraft_environ->GLFW_invoke_CharMods(window, event.i1, event.i2); break; case EVENT_TYPE_KEY: - if(pojav_environ->GLFW_invoke_Key) pojav_environ->GLFW_invoke_Key(window, event.i1, event.i2, event.i3, event.i4); + if(solcraft_environ->GLFW_invoke_Key) solcraft_environ->GLFW_invoke_Key(window, event.i1, event.i2, event.i3, event.i4); break; case EVENT_TYPE_MOUSE_BUTTON: - if(pojav_environ->GLFW_invoke_MouseButton) pojav_environ->GLFW_invoke_MouseButton(window, event.i1, event.i2, event.i3); + if(solcraft_environ->GLFW_invoke_MouseButton) solcraft_environ->GLFW_invoke_MouseButton(window, event.i1, event.i2, event.i3); break; case EVENT_TYPE_SCROLL: - if(pojav_environ->GLFW_invoke_Scroll) pojav_environ->GLFW_invoke_Scroll(window, event.i1, event.i2); + if(solcraft_environ->GLFW_invoke_Scroll) solcraft_environ->GLFW_invoke_Scroll(window, event.i1, event.i2); break; case EVENT_TYPE_FRAMEBUFFER_SIZE: - handleFramebufferSizeJava(pojav_environ->showingWindow, event.i1, event.i2); - if(pojav_environ->GLFW_invoke_FramebufferSize) pojav_environ->GLFW_invoke_FramebufferSize(window, event.i1, event.i2); + handleFramebufferSizeJava(solcraft_environ->showingWindow, event.i1, event.i2); + if(solcraft_environ->GLFW_invoke_FramebufferSize) solcraft_environ->GLFW_invoke_FramebufferSize(window, event.i1, event.i2); break; case EVENT_TYPE_WINDOW_SIZE: - handleFramebufferSizeJava(pojav_environ->showingWindow, event.i1, event.i2); - if(pojav_environ->GLFW_invoke_WindowSize) pojav_environ->GLFW_invoke_WindowSize(window, event.i1, event.i2); + handleFramebufferSizeJava(solcraft_environ->showingWindow, event.i1, event.i2); + if(solcraft_environ->GLFW_invoke_WindowSize) solcraft_environ->GLFW_invoke_WindowSize(window, event.i1, event.i2); break; } @@ -148,54 +148,54 @@ void pojavPumpEvents(void* window) { } // The out target index is updated by the rewinder - pojav_environ->isPumpingEvents = false; + solcraft_environ->isPumpingEvents = false; } /** Setup the amount of event that will get pumped into each window */ void pojavComputeEventTarget() { - size_t counter = atomic_load_explicit(&pojav_environ->eventCounter, memory_order_acquire); - size_t index = pojav_environ->outEventIndex; + size_t counter = atomic_load_explicit(&solcraft_environ->eventCounter, memory_order_acquire); + size_t index = solcraft_environ->outEventIndex; unsigned targetIndex = index + counter; if (targetIndex >= EVENT_WINDOW_SIZE) targetIndex -= EVENT_WINDOW_SIZE; // Only accessed by one unique thread, no need for atomic store - pojav_environ->inEventCount = counter; - pojav_environ->outTargetIndex = targetIndex; + solcraft_environ->inEventCount = counter; + solcraft_environ->outTargetIndex = targetIndex; } /** Apply index offsets after events have been pumped */ void pojavRewindEvents() { - pojav_environ->outEventIndex = pojav_environ->outTargetIndex; + solcraft_environ->outEventIndex = solcraft_environ->outTargetIndex; // New events may have arrived while pumping, so remove only the difference before the start and end of execution - atomic_fetch_sub_explicit(&pojav_environ->eventCounter, pojav_environ->inEventCount, memory_order_acquire); + atomic_fetch_sub_explicit(&solcraft_environ->eventCounter, solcraft_environ->inEventCount, memory_order_acquire); } JNIEXPORT void JNICALL Java_org_lwjgl_glfw_GLFW_nglfwGetCursorPos(JNIEnv *env, __attribute__((unused)) jclass clazz, __attribute__((unused)) jlong window, jobject xpos, jobject ypos) { - *(double*)(*env)->GetDirectBufferAddress(env, xpos) = pojav_environ->cursorX; - *(double*)(*env)->GetDirectBufferAddress(env, ypos) = pojav_environ->cursorY; + *(double*)(*env)->GetDirectBufferAddress(env, xpos) = solcraft_environ->cursorX; + *(double*)(*env)->GetDirectBufferAddress(env, ypos) = solcraft_environ->cursorY; } JNIEXPORT void JNICALL JavaCritical_org_lwjgl_glfw_GLFW_nglfwGetCursorPosA(__attribute__((unused)) jlong window, jint lengthx, jdouble* xpos, jint lengthy, jdouble* ypos) { - *xpos = pojav_environ->cursorX; - *ypos = pojav_environ->cursorY; + *xpos = solcraft_environ->cursorX; + *ypos = solcraft_environ->cursorY; } JNIEXPORT void JNICALL Java_org_lwjgl_glfw_GLFW_nglfwGetCursorPosA(JNIEnv *env, __attribute__((unused)) jclass clazz, __attribute__((unused)) jlong window, jdoubleArray xpos, jdoubleArray ypos) { - (*env)->SetDoubleArrayRegion(env, xpos, 0,1, &pojav_environ->cursorX); - (*env)->SetDoubleArrayRegion(env, ypos, 0,1, &pojav_environ->cursorY); + (*env)->SetDoubleArrayRegion(env, xpos, 0,1, &solcraft_environ->cursorX); + (*env)->SetDoubleArrayRegion(env, ypos, 0,1, &solcraft_environ->cursorY); } JNIEXPORT void JNICALL JavaCritical_org_lwjgl_glfw_GLFW_glfwSetCursorPos(__attribute__((unused)) jlong window, jdouble xpos, jdouble ypos) { - pojav_environ->cLastX = pojav_environ->cursorX = xpos; - pojav_environ->cLastY = pojav_environ->cursorY = ypos; + solcraft_environ->cLastX = solcraft_environ->cursorX = xpos; + solcraft_environ->cLastY = solcraft_environ->cursorY = ypos; } JNIEXPORT void JNICALL @@ -207,17 +207,17 @@ Java_org_lwjgl_glfw_GLFW_glfwSetCursorPos(__attribute__((unused)) JNIEnv *env, _ void sendData(int type, int i1, int i2, int i3, int i4) { - GLFWInputEvent *event = &pojav_environ->events[pojav_environ->inEventIndex]; + GLFWInputEvent *event = &solcraft_environ->events[solcraft_environ->inEventIndex]; event->type = type; event->i1 = i1; event->i2 = i2; event->i3 = i3; event->i4 = i4; - if (++pojav_environ->inEventIndex >= EVENT_WINDOW_SIZE) - pojav_environ->inEventIndex -= EVENT_WINDOW_SIZE; + if (++solcraft_environ->inEventIndex >= EVENT_WINDOW_SIZE) + solcraft_environ->inEventIndex -= EVENT_WINDOW_SIZE; - atomic_fetch_add_explicit(&pojav_environ->eventCounter, 1, memory_order_acquire); + atomic_fetch_add_explicit(&solcraft_environ->eventCounter, 1, memory_order_acquire); } /** @@ -244,14 +244,14 @@ void hookExec() { orig_ProcessImpl_forkAndExec = dlsym(RTLD_DEFAULT, "Java_java_lang_UNIXProcess_forkAndExec"); if (!orig_ProcessImpl_forkAndExec) { orig_ProcessImpl_forkAndExec = dlsym(RTLD_DEFAULT, "Java_java_lang_ProcessImpl_forkAndExec"); - cls = (*pojav_environ->runtimeJNIEnvPtr_JRE)->FindClass(pojav_environ->runtimeJNIEnvPtr_JRE, "java/lang/ProcessImpl"); + cls = (*solcraft_environ->runtimeJNIEnvPtr_JRE)->FindClass(solcraft_environ->runtimeJNIEnvPtr_JRE, "java/lang/ProcessImpl"); } else { - cls = (*pojav_environ->runtimeJNIEnvPtr_JRE)->FindClass(pojav_environ->runtimeJNIEnvPtr_JRE, "java/lang/UNIXProcess"); + cls = (*solcraft_environ->runtimeJNIEnvPtr_JRE)->FindClass(solcraft_environ->runtimeJNIEnvPtr_JRE, "java/lang/UNIXProcess"); } JNINativeMethod methods[] = { {"forkAndExec", "(I[B[B[BI[BI[B[IZ)I", (void *)&hooked_ProcessImpl_forkAndExec} }; - (*pojav_environ->runtimeJNIEnvPtr_JRE)->RegisterNatives(pojav_environ->runtimeJNIEnvPtr_JRE, cls, methods, 1); + (*solcraft_environ->runtimeJNIEnvPtr_JRE)->RegisterNatives(solcraft_environ->runtimeJNIEnvPtr_JRE, cls, methods, 1); printf("Registered forkAndExec\n"); } @@ -280,7 +280,7 @@ jlong ndlopen_bugfix(__attribute__((unused)) JNIEnv *env, void installLinkerBugMitigation() { if(android_get_device_api_level() >= 30) return; __android_log_print(ANDROID_LOG_INFO, "Api29LinkerFix", "API < 30 detected, installing linker bug mitigation"); - JNIEnv* env = pojav_environ->runtimeJNIEnvPtr_JRE; + JNIEnv* env = solcraft_environ->runtimeJNIEnvPtr_JRE; jclass dynamicLinkLoader = (*env)->FindClass(env, "org/lwjgl/system/linux/DynamicLinkLoader"); if(dynamicLinkLoader == NULL) { __android_log_print(ANDROID_LOG_ERROR, "Api29LinkerFix", "Failed to find the target class"); @@ -317,7 +317,7 @@ jint getLibraryPath_fix(__attribute__((unused)) JNIEnv *env, void installEMUIIteratorMititgation() { if(getenv("POJAV_EMUI_ITERATOR_MITIGATE") == NULL) return; __android_log_print(ANDROID_LOG_INFO, "EMUIIteratorFix", "Installing..."); - JNIEnv* env = pojav_environ->runtimeJNIEnvPtr_JRE; + JNIEnv* env = solcraft_environ->runtimeJNIEnvPtr_JRE; jclass sharedLibraryUtil = (*env)->FindClass(env, "org/lwjgl/system/SharedLibraryUtil"); if(sharedLibraryUtil == NULL) { __android_log_print(ANDROID_LOG_ERROR, "EMUIIteratorFix", "Failed to find the target class"); @@ -334,7 +334,7 @@ void installEMUIIteratorMititgation() { } void critical_set_stackqueue(jboolean use_input_stack_queue) { - pojav_environ->isUseStackQueueCall = (int) use_input_stack_queue; + solcraft_environ->isUseStackQueueCall = (int) use_input_stack_queue; } void noncritical_set_stackqueue(__attribute__((unused)) JNIEnv *env, __attribute__((unused)) jclass clazz, jboolean use_input_stack_queue) { @@ -343,13 +343,13 @@ void noncritical_set_stackqueue(__attribute__((unused)) JNIEnv *env, __attribute JNIEXPORT jstring JNICALL Java_org_lwjgl_glfw_CallbackBridge_nativeClipboard(JNIEnv* env, __attribute__((unused)) jclass clazz, jint action, jbyteArray copySrc) { #ifdef DEBUG - LOGD("Debug: Clipboard access is going on\n", pojav_environ->isUseStackQueueCall); + LOGD("Debug: Clipboard access is going on\n", solcraft_environ->isUseStackQueueCall); #endif JNIEnv *dalvikEnv; - (*pojav_environ->dalvikJavaVMPtr)->AttachCurrentThread(pojav_environ->dalvikJavaVMPtr, &dalvikEnv, NULL); + (*solcraft_environ->dalvikJavaVMPtr)->AttachCurrentThread(solcraft_environ->dalvikJavaVMPtr, &dalvikEnv, NULL); assert(dalvikEnv != NULL); - assert(pojav_environ->bridgeClazz != NULL); + assert(solcraft_environ->bridgeClazz != NULL); LOGD("Clipboard: Converting string\n"); char *copySrcC; @@ -360,23 +360,23 @@ JNIEXPORT jstring JNICALL Java_org_lwjgl_glfw_CallbackBridge_nativeClipboard(JNI } LOGD("Clipboard: Calling 2nd\n"); - jstring pasteDst = convertStringJVM(dalvikEnv, env, (jstring) (*dalvikEnv)->CallStaticObjectMethod(dalvikEnv, pojav_environ->bridgeClazz, pojav_environ->method_accessAndroidClipboard, action, copyDst)); + jstring pasteDst = convertStringJVM(dalvikEnv, env, (jstring) (*dalvikEnv)->CallStaticObjectMethod(dalvikEnv, solcraft_environ->bridgeClazz, solcraft_environ->method_accessAndroidClipboard, action, copyDst)); if (copySrc) { (*dalvikEnv)->DeleteLocalRef(dalvikEnv, copyDst); (*env)->ReleaseByteArrayElements(env, copySrc, (jbyte *)copySrcC, 0); } - (*pojav_environ->dalvikJavaVMPtr)->DetachCurrentThread(pojav_environ->dalvikJavaVMPtr); + (*solcraft_environ->dalvikJavaVMPtr)->DetachCurrentThread(solcraft_environ->dalvikJavaVMPtr); return pasteDst; } JNIEXPORT jboolean JNICALL JavaCritical_org_lwjgl_glfw_CallbackBridge_nativeSetInputReady(jboolean inputReady) { #ifdef DEBUG - LOGD("Debug: Changing input state, isReady=%d, pojav_environ->isUseStackQueueCall=%d\n", inputReady, pojav_environ->isUseStackQueueCall); + LOGD("Debug: Changing input state, isReady=%d, solcraft_environ->isUseStackQueueCall=%d\n", inputReady, solcraft_environ->isUseStackQueueCall); #endif __android_log_print(ANDROID_LOG_INFO, "NativeInput", "Input ready: %i", inputReady); - pojav_environ->isInputReady = inputReady; - return pojav_environ->isUseStackQueueCall; + solcraft_environ->isInputReady = inputReady; + return solcraft_environ->isUseStackQueueCall; } JNIEXPORT jboolean JNICALL Java_org_lwjgl_glfw_CallbackBridge_nativeSetInputReady(__attribute__((unused)) JNIEnv* env, __attribute__((unused)) jclass clazz, jboolean inputReady) { @@ -385,18 +385,18 @@ JNIEXPORT jboolean JNICALL Java_org_lwjgl_glfw_CallbackBridge_nativeSetInputRead JNIEXPORT void JNICALL Java_org_lwjgl_glfw_CallbackBridge_nativeSetGrabbing(__attribute__((unused)) JNIEnv* env, __attribute__((unused)) jclass clazz, jboolean grabbing) { JNIEnv *dalvikEnv; - (*pojav_environ->dalvikJavaVMPtr)->AttachCurrentThread(pojav_environ->dalvikJavaVMPtr, &dalvikEnv, NULL); - (*dalvikEnv)->CallStaticVoidMethod(dalvikEnv, pojav_environ->bridgeClazz, pojav_environ->method_onGrabStateChanged, grabbing); - (*pojav_environ->dalvikJavaVMPtr)->DetachCurrentThread(pojav_environ->dalvikJavaVMPtr); - pojav_environ->isGrabbing = grabbing; + (*solcraft_environ->dalvikJavaVMPtr)->AttachCurrentThread(solcraft_environ->dalvikJavaVMPtr, &dalvikEnv, NULL); + (*dalvikEnv)->CallStaticVoidMethod(dalvikEnv, solcraft_environ->bridgeClazz, solcraft_environ->method_onGrabStateChanged, grabbing); + (*solcraft_environ->dalvikJavaVMPtr)->DetachCurrentThread(solcraft_environ->dalvikJavaVMPtr); + solcraft_environ->isGrabbing = grabbing; } jboolean critical_send_char(jchar codepoint) { - if (pojav_environ->GLFW_invoke_Char && pojav_environ->isInputReady) { - if (pojav_environ->isUseStackQueueCall) { + if (solcraft_environ->GLFW_invoke_Char && solcraft_environ->isInputReady) { + if (solcraft_environ->isUseStackQueueCall) { sendData(EVENT_TYPE_CHAR, codepoint, 0, 0, 0); } else { - pojav_environ->GLFW_invoke_Char((void*) pojav_environ->showingWindow, (unsigned int) codepoint); + solcraft_environ->GLFW_invoke_Char((void*) solcraft_environ->showingWindow, (unsigned int) codepoint); } return JNI_TRUE; } @@ -408,11 +408,11 @@ jboolean noncritical_send_char(__attribute__((unused)) JNIEnv* env, __attribute_ } jboolean critical_send_char_mods(jchar codepoint, jint mods) { - if (pojav_environ->GLFW_invoke_CharMods && pojav_environ->isInputReady) { - if (pojav_environ->isUseStackQueueCall) { + if (solcraft_environ->GLFW_invoke_CharMods && solcraft_environ->isInputReady) { + if (solcraft_environ->isUseStackQueueCall) { sendData(EVENT_TYPE_CHAR_MODS, (int) codepoint, mods, 0, 0); } else { - pojav_environ->GLFW_invoke_CharMods((void*) pojav_environ->showingWindow, codepoint, mods); + solcraft_environ->GLFW_invoke_CharMods((void*) solcraft_environ->showingWindow, codepoint, mods); } return JNI_TRUE; } @@ -424,8 +424,8 @@ jboolean noncritical_send_char_mods(__attribute__((unused)) JNIEnv* env, __attri } /* JNIEXPORT void JNICALL Java_org_lwjgl_glfw_CallbackBridge_nativeSendCursorEnter(JNIEnv* env, jclass clazz, jint entered) { - if (pojav_environ->GLFW_invoke_CursorEnter && pojav_environ->isInputReady) { - pojav_environ->GLFW_invoke_CursorEnter(pojav_environ->showingWindow, entered); + if (solcraft_environ->GLFW_invoke_CursorEnter && solcraft_environ->isInputReady) { + solcraft_environ->GLFW_invoke_CursorEnter(solcraft_environ->showingWindow, entered); } } */ @@ -434,30 +434,30 @@ void critical_send_cursor_pos(jfloat x, jfloat y) { #ifdef DEBUG LOGD("Sending cursor position \n"); #endif - if (pojav_environ->GLFW_invoke_CursorPos && pojav_environ->isInputReady) { + if (solcraft_environ->GLFW_invoke_CursorPos && solcraft_environ->isInputReady) { #ifdef DEBUG - LOGD("pojav_environ->GLFW_invoke_CursorPos && pojav_environ->isInputReady \n"); + LOGD("solcraft_environ->GLFW_invoke_CursorPos && solcraft_environ->isInputReady \n"); #endif - if (!pojav_environ->isCursorEntered) { - if (pojav_environ->GLFW_invoke_CursorEnter) { - pojav_environ->isCursorEntered = true; - if (pojav_environ->isUseStackQueueCall) { + if (!solcraft_environ->isCursorEntered) { + if (solcraft_environ->GLFW_invoke_CursorEnter) { + solcraft_environ->isCursorEntered = true; + if (solcraft_environ->isUseStackQueueCall) { sendData(EVENT_TYPE_CURSOR_ENTER, 1, 0, 0, 0); } else { - pojav_environ->GLFW_invoke_CursorEnter((void*) pojav_environ->showingWindow, 1); + solcraft_environ->GLFW_invoke_CursorEnter((void*) solcraft_environ->showingWindow, 1); } - } else if (pojav_environ->isGrabbing) { + } else if (solcraft_environ->isGrabbing) { // Some Minecraft versions does not use GLFWCursorEnterCallback // This is a smart check, as Minecraft will not in grab mode if already not. - pojav_environ->isCursorEntered = true; + solcraft_environ->isCursorEntered = true; } } - if (!pojav_environ->isUseStackQueueCall) { - pojav_environ->GLFW_invoke_CursorPos((void*) pojav_environ->showingWindow, (double) (x), (double) (y)); + if (!solcraft_environ->isUseStackQueueCall) { + solcraft_environ->GLFW_invoke_CursorPos((void*) solcraft_environ->showingWindow, (double) (x), (double) (y)); } else { - pojav_environ->cursorX = x; - pojav_environ->cursorY = y; + solcraft_environ->cursorX = x; + solcraft_environ->cursorY = y; } } } @@ -470,12 +470,12 @@ void noncritical_send_cursor_pos(__attribute__((unused)) JNIEnv* env, __attribut __typeof__ (b) _b = (b); \ _a > _b ? _a : _b; }) void critical_send_key(jint key, jint scancode, jint action, jint mods) { - if (pojav_environ->GLFW_invoke_Key && pojav_environ->isInputReady) { - pojav_environ->keyDownBuffer[max(0, key-31)] = (jbyte) action; - if (pojav_environ->isUseStackQueueCall) { + if (solcraft_environ->GLFW_invoke_Key && solcraft_environ->isInputReady) { + solcraft_environ->keyDownBuffer[max(0, key-31)] = (jbyte) action; + if (solcraft_environ->isUseStackQueueCall) { sendData(EVENT_TYPE_KEY, key, scancode, action, mods); } else { - pojav_environ->GLFW_invoke_Key((void*) pojav_environ->showingWindow, key, scancode, action, mods); + solcraft_environ->GLFW_invoke_Key((void*) solcraft_environ->showingWindow, key, scancode, action, mods); } } } @@ -484,12 +484,12 @@ void noncritical_send_key(__attribute__((unused)) JNIEnv* env, __attribute__((un } void critical_send_mouse_button(jint button, jint action, jint mods) { - if (pojav_environ->GLFW_invoke_MouseButton && pojav_environ->isInputReady) { - pojav_environ->mouseDownBuffer[max(0, button)] = (jbyte) action; - if (pojav_environ->isUseStackQueueCall) { + if (solcraft_environ->GLFW_invoke_MouseButton && solcraft_environ->isInputReady) { + solcraft_environ->mouseDownBuffer[max(0, button)] = (jbyte) action; + if (solcraft_environ->isUseStackQueueCall) { sendData(EVENT_TYPE_MOUSE_BUTTON, button, action, mods, 0); } else { - pojav_environ->GLFW_invoke_MouseButton((void*) pojav_environ->showingWindow, button, action, mods); + solcraft_environ->GLFW_invoke_MouseButton((void*) solcraft_environ->showingWindow, button, action, mods); } } } @@ -499,22 +499,22 @@ void noncritical_send_mouse_button(__attribute__((unused)) JNIEnv* env, __attrib } void critical_send_screen_size(jint width, jint height) { - pojav_environ->savedWidth = width; - pojav_environ->savedHeight = height; - if (pojav_environ->isInputReady) { - if (pojav_environ->GLFW_invoke_FramebufferSize) { - if (pojav_environ->isUseStackQueueCall) { + solcraft_environ->savedWidth = width; + solcraft_environ->savedHeight = height; + if (solcraft_environ->isInputReady) { + if (solcraft_environ->GLFW_invoke_FramebufferSize) { + if (solcraft_environ->isUseStackQueueCall) { sendData(EVENT_TYPE_FRAMEBUFFER_SIZE, width, height, 0, 0); } else { - pojav_environ->GLFW_invoke_FramebufferSize((void*) pojav_environ->showingWindow, width, height); + solcraft_environ->GLFW_invoke_FramebufferSize((void*) solcraft_environ->showingWindow, width, height); } } - if (pojav_environ->GLFW_invoke_WindowSize) { - if (pojav_environ->isUseStackQueueCall) { + if (solcraft_environ->GLFW_invoke_WindowSize) { + if (solcraft_environ->isUseStackQueueCall) { sendData(EVENT_TYPE_WINDOW_SIZE, width, height, 0, 0); } else { - pojav_environ->GLFW_invoke_WindowSize((void*) pojav_environ->showingWindow, width, height); + solcraft_environ->GLFW_invoke_WindowSize((void*) solcraft_environ->showingWindow, width, height); } } } @@ -525,11 +525,11 @@ void noncritical_send_screen_size(__attribute__((unused)) JNIEnv* env, __attribu } void critical_send_scroll(jdouble xoffset, jdouble yoffset) { - if (pojav_environ->GLFW_invoke_Scroll && pojav_environ->isInputReady) { - if (pojav_environ->isUseStackQueueCall) { + if (solcraft_environ->GLFW_invoke_Scroll && solcraft_environ->isInputReady) { + if (solcraft_environ->isUseStackQueueCall) { sendData(EVENT_TYPE_SCROLL, (int)xoffset, (int)yoffset, 0, 0); } else { - pojav_environ->GLFW_invoke_Scroll((void*) pojav_environ->showingWindow, (double) xoffset, (double) yoffset); + solcraft_environ->GLFW_invoke_Scroll((void*) solcraft_environ->showingWindow, (double) xoffset, (double) yoffset); } } } @@ -540,20 +540,20 @@ void noncritical_send_scroll(__attribute__((unused)) JNIEnv* env, __attribute__( JNIEXPORT void JNICALL Java_org_lwjgl_glfw_GLFW_nglfwSetShowingWindow(__attribute__((unused)) JNIEnv* env, __attribute__((unused)) jclass clazz, jlong window) { - pojav_environ->showingWindow = (long) window; + solcraft_environ->showingWindow = (long) window; } JNIEXPORT void JNICALL Java_org_lwjgl_glfw_CallbackBridge_nativeSetWindowAttrib(__attribute__((unused)) JNIEnv* env, __attribute__((unused)) jclass clazz, jint attrib, jint value) { - if (!pojav_environ->showingWindow || !pojav_environ->isUseStackQueueCall) { + if (!solcraft_environ->showingWindow || !solcraft_environ->isUseStackQueueCall) { // If the window is not shown, there is nothing to do yet. // For Minecraft < 1.13, calling to JNI functions here crashes the JVM for some reason, therefore it is skipped for now. return; } - (*pojav_environ->runtimeJNIEnvPtr_JRE)->CallStaticVoidMethod( - pojav_environ->runtimeJNIEnvPtr_JRE, - pojav_environ->vmGlfwClass, pojav_environ->method_glftSetWindowAttrib, - (jlong) pojav_environ->showingWindow, attrib, value + (*solcraft_environ->runtimeJNIEnvPtr_JRE)->CallStaticVoidMethod( + solcraft_environ->runtimeJNIEnvPtr_JRE, + solcraft_environ->vmGlfwClass, solcraft_environ->method_glftSetWindowAttrib, + (jlong) solcraft_environ->showingWindow, attrib, value ); } const static JNINativeMethod critical_fcns[] = { diff --git a/app_pojavlauncher/src/main/jni/jre_launcher.c b/app_pojavlauncher/src/main/jni/jre_launcher.c index 6662ba3836..5e53af1d4b 100644 --- a/app_pojavlauncher/src/main/jni/jre_launcher.c +++ b/app_pojavlauncher/src/main/jni/jre_launcher.c @@ -161,7 +161,7 @@ JNIEXPORT jint JNICALL Java_com_oracle_dalvik_VMLauncher_launchJVM(JNIEnv *env, //Signal trapper ready // Save dalvik JNIEnv pointer for JVM launch thread - pojav_environ->dalvikJNIEnvPtr_ANDROID = env; + solcraft_environ->dalvikJNIEnvPtr_ANDROID = env; if (argsArray == NULL) { LOGE("Args array null, returning");