mirror of
https://github.com/AngelAuraMC/Amethyst-Android.git
synced 2025-09-14 15:17:02 -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);
|
||||
|
||||
if (!attached) {
|
||||
attached = CallbackBridge.nativeAttachThreadToOther(true, MainActivity.isInputStackCall);
|
||||
attached = CallbackBridge.nativeAttachThreadToOther(true, false, MainActivity.isInputStackCall);
|
||||
} else {
|
||||
int[] rgbArray = JREUtils.renderAWTScreenFrame(/* canvas, mWidth, mHeight */);
|
||||
if (rgbArray == null) {
|
||||
|
@ -145,7 +145,9 @@ public class MainActivity extends LoggableActivity implements OnTouchListener, O
|
||||
|
||||
mProfile = PojavProfile.getCurrentProfileContent(this);
|
||||
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());
|
||||
|
||||
// Minecraft 1.13+
|
||||
|
@ -11,6 +11,7 @@ public class CallbackBridge {
|
||||
public static final int CLIPBOARD_COPY = 2000;
|
||||
public static final int CLIPBOARD_PASTE = 2001;
|
||||
|
||||
public static boolean isMinecraft1p12;
|
||||
public static volatile int windowWidth, windowHeight;
|
||||
public static int mouseX, mouseY;
|
||||
public static boolean mouseLeft;
|
||||
@ -31,7 +32,7 @@ public class CallbackBridge {
|
||||
private static boolean threadAttached;
|
||||
public static void sendCursorPos(int x, int y) {
|
||||
if (!threadAttached) {
|
||||
threadAttached = CallbackBridge.nativeAttachThreadToOther(true, MainActivity.isInputStackCall);
|
||||
threadAttached = CallbackBridge.nativeAttachThreadToOther(true, isMinecraft1p12, MainActivity.isInputStackCall);
|
||||
}
|
||||
|
||||
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);
|
||||
*/
|
||||
|
||||
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);
|
||||
// GLFW: GLFWCharModsCallback deprecated, but is Minecraft still use?
|
||||
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_WindowSize_func(void* window, int width, int height);
|
||||
|
||||
bool isMinecraft1p12;
|
||||
int grabCursorX, grabCursorY, lastCursorX, lastCursorY;
|
||||
|
||||
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);
|
||||
#endif
|
||||
|
||||
if (*secondJNIEnvPtr != NULL || !isUseStackQueueCall) return JNI_TRUE;
|
||||
if (*secondJNIEnvPtr != NULL || (!isMinecraft1p12 && !isUseStackQueueCall) return JNI_TRUE;
|
||||
|
||||
if (isAndroid && runtimeJavaVMPtr) {
|
||||
(*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
|
||||
LOGD("Debug: JNI attaching thread, isUseStackQueue=%d\n", isUseStackQueue);
|
||||
#endif
|
||||
|
||||
jboolean result;
|
||||
|
||||
isUseStackQueueCall = (int) isUseStackQueue;
|
||||
isMinecraft1p12 = isMinecraft1p12Bool;
|
||||
isUseStackQueueCall = (int) isUseStackQueueBool;
|
||||
if (isAndroid) {
|
||||
result = attachThread(true, &runtimeJNIEnvPtr_ANDROID);
|
||||
} else {
|
||||
@ -144,7 +146,7 @@ JNIEXPORT jboolean JNICALL Java_org_lwjgl_glfw_CallbackBridge_nativeAttachThread
|
||||
// getJavaInputBridge(&inputBridgeClass_JRE, &inputBridgeMethod_JRE);
|
||||
}
|
||||
|
||||
if (isUseStackQueue && isAndroid && result) {
|
||||
if ((isMinecraft1p12 || isUseStackQueueCall) && isAndroid && result) {
|
||||
isPrepareGrabPos = true;
|
||||
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) {
|
||||
if (GLFW_invoke_Char && isInputReady) {
|
||||
// if (isUseStackQueueCall) {
|
||||
if (isMinecraft1p12 || isUseStackQueueCall) {
|
||||
sendData(EVENT_TYPE_CHAR, codepoint, 0, 0, 0);
|
||||
/* } else {
|
||||
} else {
|
||||
GLFW_invoke_Char(showingWindow, codepoint);
|
||||
} */
|
||||
}
|
||||
return JNI_TRUE;
|
||||
}
|
||||
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) {
|
||||
if (GLFW_invoke_CharMods && isInputReady) {
|
||||
// if (isUseStackQueueCall) {
|
||||
if (isMinecraft1p12 || isUseStackQueueCall) {
|
||||
sendData(EVENT_TYPE_CHAR_MODS, codepoint, mods, 0, 0);
|
||||
/* } else {
|
||||
} else {
|
||||
GLFW_invoke_CharMods(showingWindow, codepoint, mods);
|
||||
} */
|
||||
}
|
||||
return JNI_TRUE;
|
||||
}
|
||||
return JNI_FALSE;
|
||||
|
Loading…
x
Reference in New Issue
Block a user