Skip to content

Commit

Permalink
Move to environ
Browse files Browse the repository at this point in the history
  • Loading branch information
The Judge committed Sep 19, 2024
1 parent 1ccae63 commit 90adbd7
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 48 deletions.
Binary file modified src/main/jni/OpenOVR/libDrvOpenXR.a
Binary file not shown.
Binary file modified src/main/jni/OpenOVR/libOCCore.a
Binary file not shown.
5 changes: 3 additions & 2 deletions src/main/jni/egl_bridge.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include <string.h>
#include <pthread.h>
#include "utils.h"
#include "environ/environ.h"
#include "GL/gl.h"

typedef EGLDisplay eglGetDisplay_t (EGLNativeDisplayType display_id);
Expand Down Expand Up @@ -184,9 +185,9 @@ void pojavMakeCurrent(void* window) {
xrEglContext = window;

if (success == EGL_FALSE) {
printf("EGLBridge: Error: eglMakeCurrent() failed: %p\n", eglGetError());
printf("XREGLBridge: Error: eglMakeCurrent() failed: %p\n", eglGetError());
} else {
printf("EGLBridge: eglMakeCurrent() succeed!\n");
printf("XREGLBridge: eglMakeCurrent() succeed!\n");
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/main/jni/environ/environ.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ struct pojav_environ_s {
JavaVM* dalvikJavaVMPtr;
JNIEnv* dalvikJNIEnvPtr_ANDROID;
jobject activity;
XrInstanceCreateInfoAndroidKHR* OpenComposite_Android_Create_Info;
void (*set_oc_vars_p) (void);
XrInstanceCreateInfoAndroidKHR *OpenComposite_Android_Create_Info;
XrGraphicsBindingOpenGLESAndroidKHR *OpenComposite_Android_GLES_Binding_Info;
long showingWindow;
bool isInputReady, isCursorEntered, isUseStackQueueCall, shouldUpdateMouse;
int savedWidth, savedHeight;
Expand Down
8 changes: 6 additions & 2 deletions src/main/jni/input_bridge_v3.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ 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 (pojav_environ->dalvikJavaVMPtr == NULL) {
__android_log_print(ANDROID_LOG_INFO, "Native", "Saving DVM environ...");
//Save dalvik global JavaVM pointer
pojav_environ->dalvikJavaVMPtr = vm;
Expand All @@ -62,7 +62,11 @@ jint JNI_OnLoad(JavaVM* vm, __attribute__((unused)) void* reserved) {
hookExec();
installLinkerBugMitigation();
installEMUIIteratorMititgation();
pojav_environ->set_oc_vars_p();

pojav_environ->OpenComposite_Android_Create_Info = malloc(sizeof(XrInstanceCreateInfoAndroidKHR));
pojav_environ->OpenComposite_Android_Create_Info->type = XR_TYPE_INSTANCE_CREATE_INFO_ANDROID_KHR;
pojav_environ->OpenComposite_Android_Create_Info->applicationVM = pojav_environ->dalvikJavaVMPtr;
pojav_environ->OpenComposite_Android_Create_Info->applicationActivity = pojav_environ->activity;
}

if(pojav_environ->dalvikJavaVMPtr == vm) {
Expand Down
43 changes: 1 addition & 42 deletions src/main/jni/vloader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
#include <GLES3/gl32.h>
#include "log.h"

XrInstanceCreateInfoAndroidKHR* OpenComposite_Android_Create_Info;
XrGraphicsBindingOpenGLESAndroidKHR* OpenComposite_Android_GLES_Binding_Info;
std::string (*OpenComposite_Android_Load_Input_File)(const char *path);

static std::string load_file(const char *path) {
Expand Down Expand Up @@ -45,49 +43,10 @@ static std::string load_file(const char *path) {
return std::move(data);
}

extern "C"
void set_oc_vars() {
OpenComposite_Android_Load_Input_File = load_file;
OpenComposite_Android_Create_Info = new XrInstanceCreateInfoAndroidKHR{
XR_TYPE_INSTANCE_CREATE_INFO_ANDROID_KHR,
nullptr,
pojav_environ->dalvikJavaVMPtr,
pojav_environ->activity
};

PFN_xrInitializeLoaderKHR initializeLoader = nullptr;
XrResult res;

res = xrGetInstanceProcAddr(XR_NULL_HANDLE, "xrInitializeLoaderKHR",
(PFN_xrVoidFunction *) (&initializeLoader));

if(!XR_SUCCEEDED(res)) {
printf("xrGetInstanceProcAddr returned %d.\n", res);
}

XrLoaderInitInfoAndroidKHR loaderInitInfoAndroidKhr = {
XR_TYPE_LOADER_INIT_INFO_ANDROID_KHR,
nullptr,
pojav_environ->dalvikJavaVMPtr,
pojav_environ->activity
};

res = initializeLoader((const XrLoaderInitInfoBaseHeaderKHR *) &loaderInitInfoAndroidKhr);
if(!XR_SUCCEEDED(res)) {
printf("xrInitializeLoaderKHR returned %d.\n", res);
}
}

extern "C"
JNIEXPORT void JNICALL
Java_pojlib_util_VLoader_setAndroidInitInfo(JNIEnv *env, jclass clazz, jobject ctx) {
pojav_environ->activity = env->NewGlobalRef(ctx);

typedef void set_oc_vars_t (void);
set_oc_vars_t* set_oc_vars_p;
set_oc_vars_p = set_oc_vars;

pojav_environ->set_oc_vars_p = set_oc_vars_p;
}

extern "C"
Expand All @@ -109,7 +68,7 @@ Java_org_vivecraft_util_VLoader_setEGLGlobal(JNIEnv* env, jclass clazz) {
};

eglChooseConfig(eglGetCurrentDisplay(), attribs, &cfg, 1, &num_configs);
OpenComposite_Android_GLES_Binding_Info = new XrGraphicsBindingOpenGLESAndroidKHR {
pojav_environ->OpenComposite_Android_GLES_Binding_Info = new XrGraphicsBindingOpenGLESAndroidKHR {
XR_TYPE_GRAPHICS_BINDING_OPENGL_ES_ANDROID_KHR,
nullptr,
(void*)eglGetCurrentDisplay(),
Expand Down

0 comments on commit 90adbd7

Please sign in to comment.