mirror of
https://github.com/AngelAuraMC/Amethyst-Android.git
synced 2025-09-14 23:28:52 -04:00
Fix thread not attached for MC 1.12 indirect char pipe
This commit is contained in:
parent
423ddb2d10
commit
057ef13c40
@ -86,7 +86,7 @@ public class AWTCanvasView extends TextureView implements TextureView.SurfaceTex
|
|||||||
canvas.drawRGB(0, 0, 0);
|
canvas.drawRGB(0, 0, 0);
|
||||||
|
|
||||||
if (!attached) {
|
if (!attached) {
|
||||||
attached = CallbackBridge.nativeAttachThreadToOther(true, MainActivity.isInputStackCall);
|
attached = CallbackBridge.nativeAttachThreadToOther(true, false, MainActivity.isInputStackCall);
|
||||||
} else {
|
} else {
|
||||||
int[] rgbArray = JREUtils.renderAWTScreenFrame(/* canvas, mWidth, mHeight */);
|
int[] rgbArray = JREUtils.renderAWTScreenFrame(/* canvas, mWidth, mHeight */);
|
||||||
if (rgbArray == null) {
|
if (rgbArray == null) {
|
||||||
|
@ -145,7 +145,9 @@ public class MainActivity extends LoggableActivity implements OnTouchListener, O
|
|||||||
|
|
||||||
mProfile = PojavProfile.getCurrentProfileContent(this);
|
mProfile = PojavProfile.getCurrentProfileContent(this);
|
||||||
mVersionInfo = Tools.getVersionInfo(mProfile.getVersion());
|
mVersionInfo = Tools.getVersionInfo(mProfile.getVersion());
|
||||||
|
// Minecraft 1.12.x special case: use indirect char pipe
|
||||||
|
CallbackBridge.isMinecraft1p12 = mVersionInfo.assets.startsWith("1.12");
|
||||||
|
|
||||||
setTitle("Minecraft " + mProfile.getVersion());
|
setTitle("Minecraft " + mProfile.getVersion());
|
||||||
|
|
||||||
// Minecraft 1.13+
|
// Minecraft 1.13+
|
||||||
|
@ -11,6 +11,7 @@ public class CallbackBridge {
|
|||||||
public static final int CLIPBOARD_COPY = 2000;
|
public static final int CLIPBOARD_COPY = 2000;
|
||||||
public static final int CLIPBOARD_PASTE = 2001;
|
public static final int CLIPBOARD_PASTE = 2001;
|
||||||
|
|
||||||
|
public static boolean isMinecraft1p12;
|
||||||
public static volatile int windowWidth, windowHeight;
|
public static volatile int windowWidth, windowHeight;
|
||||||
public static int mouseX, mouseY;
|
public static int mouseX, mouseY;
|
||||||
public static boolean mouseLeft;
|
public static boolean mouseLeft;
|
||||||
@ -31,7 +32,7 @@ public class CallbackBridge {
|
|||||||
private static boolean threadAttached;
|
private static boolean threadAttached;
|
||||||
public static void sendCursorPos(int x, int y) {
|
public static void sendCursorPos(int x, int y) {
|
||||||
if (!threadAttached) {
|
if (!threadAttached) {
|
||||||
threadAttached = CallbackBridge.nativeAttachThreadToOther(true, MainActivity.isInputStackCall);
|
threadAttached = CallbackBridge.nativeAttachThreadToOther(true, isMinecraft1p12, MainActivity.isInputStackCall);
|
||||||
}
|
}
|
||||||
|
|
||||||
DEBUG_STRING.append("CursorPos=" + x + ", " + y + "\n");
|
DEBUG_STRING.append("CursorPos=" + x + ", " + y + "\n");
|
||||||
@ -124,7 +125,7 @@ public class CallbackBridge {
|
|||||||
private static native void nativeSendData(boolean isAndroid, int type, String data);
|
private static native void nativeSendData(boolean isAndroid, int type, String data);
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public static native boolean nativeAttachThreadToOther(boolean isAndroid, boolean isUsePushPoll);
|
public static native boolean nativeAttachThreadToOther(boolean isAndroid, boolean isMinecraft1p12, boolean isUsePushPoll);
|
||||||
private static native boolean nativeSendChar(int codepoint);
|
private static native boolean nativeSendChar(int codepoint);
|
||||||
// GLFW: GLFWCharModsCallback deprecated, but is Minecraft still use?
|
// GLFW: GLFWCharModsCallback deprecated, but is Minecraft still use?
|
||||||
private static native boolean nativeSendCharMods(int codepoint, int mods);
|
private static native boolean nativeSendCharMods(int codepoint, int mods);
|
||||||
|
@ -24,6 +24,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_Scroll_func(void* window, double xoffset, double yoffset);
|
||||||
typedef void GLFW_invoke_WindowSize_func(void* window, int width, int height);
|
typedef void GLFW_invoke_WindowSize_func(void* window, int width, int height);
|
||||||
|
|
||||||
|
bool isMinecraft1p12;
|
||||||
int grabCursorX, grabCursorY, lastCursorX, lastCursorY;
|
int grabCursorX, grabCursorY, lastCursorX, lastCursorY;
|
||||||
|
|
||||||
jclass inputBridgeClass_ANDROID, inputBridgeClass_JRE;
|
jclass inputBridgeClass_ANDROID, inputBridgeClass_JRE;
|
||||||
@ -87,7 +88,7 @@ jboolean attachThread(bool isAndroid, JNIEnv** secondJNIEnvPtr) {
|
|||||||
LOGD("Debug: Attaching %s thread to %s, javavm.isNull=%d\n", isAndroid ? "Android" : "JRE", isAndroid ? "JRE" : "Android", (isAndroid ? runtimeJavaVMPtr : dalvikJavaVMPtr) == NULL);
|
LOGD("Debug: Attaching %s thread to %s, javavm.isNull=%d\n", isAndroid ? "Android" : "JRE", isAndroid ? "JRE" : "Android", (isAndroid ? runtimeJavaVMPtr : dalvikJavaVMPtr) == NULL);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (*secondJNIEnvPtr != NULL || !isUseStackQueueCall) return JNI_TRUE;
|
if (*secondJNIEnvPtr != NULL || (!isMinecraft1p12 && !isUseStackQueueCall) return JNI_TRUE;
|
||||||
|
|
||||||
if (isAndroid && runtimeJavaVMPtr) {
|
if (isAndroid && runtimeJavaVMPtr) {
|
||||||
(*runtimeJavaVMPtr)->AttachCurrentThread(runtimeJavaVMPtr, secondJNIEnvPtr, NULL);
|
(*runtimeJavaVMPtr)->AttachCurrentThread(runtimeJavaVMPtr, secondJNIEnvPtr, NULL);
|
||||||
@ -129,14 +130,15 @@ void sendData(int type, int i1, int i2, int i3, int i4) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
JNIEXPORT jboolean JNICALL Java_org_lwjgl_glfw_CallbackBridge_nativeAttachThreadToOther(JNIEnv* env, jclass clazz, jboolean isAndroid, jboolean isUseStackQueue) {
|
JNIEXPORT jboolean JNICALL Java_org_lwjgl_glfw_CallbackBridge_nativeAttachThreadToOther(JNIEnv* env, jclass clazz, jboolean isAndroid, jboolean isMinecraft1p12Bool, jboolean isUseStackQueueBool) {
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
LOGD("Debug: JNI attaching thread, isUseStackQueue=%d\n", isUseStackQueue);
|
LOGD("Debug: JNI attaching thread, isUseStackQueue=%d\n", isUseStackQueue);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
jboolean result;
|
jboolean result;
|
||||||
|
|
||||||
isUseStackQueueCall = (int) isUseStackQueue;
|
isMinecraft1p12 = isMinecraft1p12Bool;
|
||||||
|
isUseStackQueueCall = (int) isUseStackQueueBool;
|
||||||
if (isAndroid) {
|
if (isAndroid) {
|
||||||
result = attachThread(true, &runtimeJNIEnvPtr_ANDROID);
|
result = attachThread(true, &runtimeJNIEnvPtr_ANDROID);
|
||||||
} else {
|
} else {
|
||||||
@ -144,7 +146,7 @@ JNIEXPORT jboolean JNICALL Java_org_lwjgl_glfw_CallbackBridge_nativeAttachThread
|
|||||||
// getJavaInputBridge(&inputBridgeClass_JRE, &inputBridgeMethod_JRE);
|
// getJavaInputBridge(&inputBridgeClass_JRE, &inputBridgeMethod_JRE);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isUseStackQueue && isAndroid && result) {
|
if ((isMinecraft1p12 || isUseStackQueueCall) && isAndroid && result) {
|
||||||
isPrepareGrabPos = true;
|
isPrepareGrabPos = true;
|
||||||
getJavaInputBridge(&inputBridgeClass_ANDROID, &inputBridgeMethod_ANDROID);
|
getJavaInputBridge(&inputBridgeClass_ANDROID, &inputBridgeMethod_ANDROID);
|
||||||
}
|
}
|
||||||
@ -183,11 +185,11 @@ JNIEXPORT jboolean JNICALL Java_org_lwjgl_glfw_CallbackBridge_nativeIsGrabbing(J
|
|||||||
|
|
||||||
JNIEXPORT jboolean JNICALL Java_org_lwjgl_glfw_CallbackBridge_nativeSendChar(JNIEnv* env, jclass clazz, jint codepoint) {
|
JNIEXPORT jboolean JNICALL Java_org_lwjgl_glfw_CallbackBridge_nativeSendChar(JNIEnv* env, jclass clazz, jint codepoint) {
|
||||||
if (GLFW_invoke_Char && isInputReady) {
|
if (GLFW_invoke_Char && isInputReady) {
|
||||||
// if (isUseStackQueueCall) {
|
if (isMinecraft1p12 || isUseStackQueueCall) {
|
||||||
sendData(EVENT_TYPE_CHAR, codepoint, 0, 0, 0);
|
sendData(EVENT_TYPE_CHAR, codepoint, 0, 0, 0);
|
||||||
/* } else {
|
} else {
|
||||||
GLFW_invoke_Char(showingWindow, codepoint);
|
GLFW_invoke_Char(showingWindow, codepoint);
|
||||||
} */
|
}
|
||||||
return JNI_TRUE;
|
return JNI_TRUE;
|
||||||
}
|
}
|
||||||
return JNI_FALSE;
|
return JNI_FALSE;
|
||||||
@ -195,11 +197,11 @@ JNIEXPORT jboolean JNICALL Java_org_lwjgl_glfw_CallbackBridge_nativeSendChar(JNI
|
|||||||
|
|
||||||
JNIEXPORT jboolean JNICALL Java_org_lwjgl_glfw_CallbackBridge_nativeSendCharMods(JNIEnv* env, jclass clazz, jint codepoint, jint mods) {
|
JNIEXPORT jboolean JNICALL Java_org_lwjgl_glfw_CallbackBridge_nativeSendCharMods(JNIEnv* env, jclass clazz, jint codepoint, jint mods) {
|
||||||
if (GLFW_invoke_CharMods && isInputReady) {
|
if (GLFW_invoke_CharMods && isInputReady) {
|
||||||
// if (isUseStackQueueCall) {
|
if (isMinecraft1p12 || isUseStackQueueCall) {
|
||||||
sendData(EVENT_TYPE_CHAR_MODS, codepoint, mods, 0, 0);
|
sendData(EVENT_TYPE_CHAR_MODS, codepoint, mods, 0, 0);
|
||||||
/* } else {
|
} else {
|
||||||
GLFW_invoke_CharMods(showingWindow, codepoint, mods);
|
GLFW_invoke_CharMods(showingWindow, codepoint, mods);
|
||||||
} */
|
}
|
||||||
return JNI_TRUE;
|
return JNI_TRUE;
|
||||||
}
|
}
|
||||||
return JNI_FALSE;
|
return JNI_FALSE;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user