mirror of
https://github.com/AngelAuraMC/Amethyst-Android.git
synced 2025-09-14 07:05:40 -04:00
Try to fix no input event in 1.13+
This commit is contained in:
parent
615dd370a1
commit
95e827eee3
@ -28,7 +28,7 @@ import android.system.*;
|
|||||||
public class MainActivity extends LoggableActivity implements OnTouchListener, OnClickListener
|
public class MainActivity extends LoggableActivity implements OnTouchListener, OnClickListener
|
||||||
{
|
{
|
||||||
public static final String initText = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA ";
|
public static final String initText = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA ";
|
||||||
public static boolean isPushPollCall;
|
volatile public static boolean isPushPollCall;
|
||||||
|
|
||||||
private static int[] hotbarKeys = {
|
private static int[] hotbarKeys = {
|
||||||
LWJGLGLFWKeycode.GLFW_KEY_1, LWJGLGLFWKeycode.GLFW_KEY_2, LWJGLGLFWKeycode.GLFW_KEY_3,
|
LWJGLGLFWKeycode.GLFW_KEY_1, LWJGLGLFWKeycode.GLFW_KEY_2, LWJGLGLFWKeycode.GLFW_KEY_3,
|
||||||
@ -158,6 +158,7 @@ public class MainActivity extends LoggableActivity implements OnTouchListener, O
|
|||||||
|
|
||||||
// Minecraft 1.13+
|
// Minecraft 1.13+
|
||||||
isPushPollCall = mVersionInfo.arguments != null;
|
isPushPollCall = mVersionInfo.arguments != null;
|
||||||
|
CallbackBridge.nativeAttachThreadToOther(true, isPushPollCall);
|
||||||
|
|
||||||
this.displayMetrics = Tools.getDisplayMetrics(this);
|
this.displayMetrics = Tools.getDisplayMetrics(this);
|
||||||
CallbackBridge.windowWidth = displayMetrics.widthPixels / scaleFactor;
|
CallbackBridge.windowWidth = displayMetrics.widthPixels / scaleFactor;
|
||||||
|
@ -107,7 +107,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);
|
||||||
*/
|
*/
|
||||||
|
|
||||||
private static native void nativeAttachThreadToOther(boolean isAndroid, boolean isUsePushPoll);
|
public static native void nativeAttachThreadToOther(boolean isAndroid, 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);
|
||||||
@ -123,7 +123,6 @@ public class CallbackBridge {
|
|||||||
|
|
||||||
static {
|
static {
|
||||||
System.loadLibrary("pojavexec");
|
System.loadLibrary("pojavexec");
|
||||||
nativeAttachThreadToOther(true, MainActivity.isPushPollCall);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -42,7 +42,7 @@ JNIEnv* secondJNIEnv;
|
|||||||
jclass inputBridgeClass_ANDROID, inputBridgeClass_JRE;
|
jclass inputBridgeClass_ANDROID, inputBridgeClass_JRE;
|
||||||
jmethodID inputBridgeMethod_ANDROID, inputBridgeMethod_JRE;
|
jmethodID inputBridgeMethod_ANDROID, inputBridgeMethod_JRE;
|
||||||
|
|
||||||
jboolean isGrabbing, isUsePushPollCall;
|
jboolean isGrabbing, isUseStackQueueCall;
|
||||||
|
|
||||||
jint JNI_OnLoad(JavaVM* vm, void* reserved) {
|
jint JNI_OnLoad(JavaVM* vm, void* reserved) {
|
||||||
if (dalvikJavaVMPtr == NULL) {
|
if (dalvikJavaVMPtr == NULL) {
|
||||||
@ -121,16 +121,16 @@ void invokeCursorPos(int x, int y) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!isUsePushPollCall)
|
if (!isUseStackQueueCall)
|
||||||
GLFW_invoke_CursorPos(showingWindow, (double) (isGrabbing ? grabCursorX : x), (double) (isGrabbing ? grabCursorY : y));
|
GLFW_invoke_CursorPos(showingWindow, (double) (isGrabbing ? grabCursorX : x), (double) (isGrabbing ? grabCursorY : y));
|
||||||
lastCursorX = x;
|
lastCursorX = x;
|
||||||
lastCursorY = y;
|
lastCursorY = y;
|
||||||
}
|
}
|
||||||
|
|
||||||
JNIEXPORT void JNICALL Java_org_lwjgl_glfw_CallbackBridge_nativeAttachThreadToOther(JNIEnv* env, jclass clazz, jboolean isAndroid, jboolean isUsePushPoll) {
|
JNIEXPORT void JNICALL Java_org_lwjgl_glfw_CallbackBridge_nativeAttachThreadToOther(JNIEnv* env, jclass clazz, jboolean isAndroid, jboolean isUseStackQueue) {
|
||||||
glfwInputEventIndex = -1;
|
glfwInputEventIndex = -1;
|
||||||
isUsePushPollCall = isUsePushPoll;
|
isUseStackQueueCall = (int) isUseStackQueue;
|
||||||
if (isUsePushPoll) {
|
if (isUseStackQueue) {
|
||||||
isPrepareGrabPos = true;
|
isPrepareGrabPos = true;
|
||||||
} else if (isAndroid) {
|
} else if (isAndroid) {
|
||||||
firstJavaVM = dalvikJavaVMPtr;
|
firstJavaVM = dalvikJavaVMPtr;
|
||||||
@ -162,7 +162,8 @@ JNIEXPORT jboolean JNICALL Java_org_lwjgl_glfw_CallbackBridge_nativeIsGrabbing(J
|
|||||||
int diffX, diffY, logTimes;
|
int diffX, diffY, logTimes;
|
||||||
JNIEXPORT void JNICALL Java_org_lwjgl_glfw_GLFW_nglfwPollEvents(JNIEnv* env, jclass clazz) {
|
JNIEXPORT void JNICALL Java_org_lwjgl_glfw_GLFW_nglfwPollEvents(JNIEnv* env, jclass clazz) {
|
||||||
if (!isInputReady) isInputReady = true;
|
if (!isInputReady) isInputReady = true;
|
||||||
if (isUsePushPollCall) {
|
if (isUseStackQueueCall) {
|
||||||
|
/*
|
||||||
LOGI("Mouse pos curr! x=%d, y=%d; Input length=%d", lastCursorX, lastCursorY, glfwInputEventIndex);
|
LOGI("Mouse pos curr! x=%d, y=%d; Input length=%d", lastCursorX, lastCursorY, glfwInputEventIndex);
|
||||||
if (diffX != lastCursorX || diffY != lastCursorY) {
|
if (diffX != lastCursorX || diffY != lastCursorY) {
|
||||||
if (logTimes < 1000) {
|
if (logTimes < 1000) {
|
||||||
@ -172,6 +173,7 @@ JNIEXPORT void JNICALL Java_org_lwjgl_glfw_GLFW_nglfwPollEvents(JNIEnv* env, jcl
|
|||||||
diffX = lastCursorX;
|
diffX = lastCursorX;
|
||||||
diffY = lastCursorY;
|
diffY = lastCursorY;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
if (GLFW_invoke_CursorPos) {
|
if (GLFW_invoke_CursorPos) {
|
||||||
GLFW_invoke_CursorPos(showingWindow, (double) (isGrabbing ? grabCursorX : lastCursorX), (double) (isGrabbing ? grabCursorY : lastCursorY));
|
GLFW_invoke_CursorPos(showingWindow, (double) (isGrabbing ? grabCursorX : lastCursorX), (double) (isGrabbing ? grabCursorY : lastCursorY));
|
||||||
@ -231,7 +233,7 @@ JNIEXPORT void JNICALL Java_org_lwjgl_glfw_GLFW_nglfwPollEvents(JNIEnv* env, jcl
|
|||||||
|
|
||||||
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 (isUsePushPollCall) {
|
if (isUseStackQueueCall) {
|
||||||
struct GLFWInputEvent curr = glfwInputEventArr[glfwInputEventIndex++];
|
struct GLFWInputEvent curr = glfwInputEventArr[glfwInputEventIndex++];
|
||||||
curr.type = EVENT_TYPE_CHAR;
|
curr.type = EVENT_TYPE_CHAR;
|
||||||
curr.ui1 = (unsigned int) codepoint;
|
curr.ui1 = (unsigned int) codepoint;
|
||||||
@ -244,7 +246,7 @@ 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 (isUsePushPollCall) {
|
if (isUseStackQueueCall) {
|
||||||
struct GLFWInputEvent curr = glfwInputEventArr[glfwInputEventIndex++];
|
struct GLFWInputEvent curr = glfwInputEventArr[glfwInputEventIndex++];
|
||||||
curr.type = EVENT_TYPE_CHAR_MODS;
|
curr.type = EVENT_TYPE_CHAR_MODS;
|
||||||
curr.ui1 = (unsigned int) codepoint;
|
curr.ui1 = (unsigned int) codepoint;
|
||||||
@ -267,7 +269,7 @@ JNIEXPORT void JNICALL Java_org_lwjgl_glfw_CallbackBridge_nativeSendCursorPos(JN
|
|||||||
if (!isCursorEntered) {
|
if (!isCursorEntered) {
|
||||||
if (GLFW_invoke_CursorEnter) {
|
if (GLFW_invoke_CursorEnter) {
|
||||||
isCursorEntered = true;
|
isCursorEntered = true;
|
||||||
if (isUsePushPollCall) {
|
if (isUseStackQueueCall) {
|
||||||
struct GLFWInputEvent curr = glfwInputEventArr[glfwInputEventIndex++];
|
struct GLFWInputEvent curr = glfwInputEventArr[glfwInputEventIndex++];
|
||||||
curr.type = EVENT_TYPE_CURSOR_ENTER;
|
curr.type = EVENT_TYPE_CURSOR_ENTER;
|
||||||
curr.i1 = 1;
|
curr.i1 = 1;
|
||||||
@ -286,7 +288,7 @@ JNIEXPORT void JNICALL Java_org_lwjgl_glfw_CallbackBridge_nativeSendCursorPos(JN
|
|||||||
|
|
||||||
JNIEXPORT void JNICALL Java_org_lwjgl_glfw_CallbackBridge_nativeSendFramebufferSize(JNIEnv* env, jclass clazz, jint width, jint height) {
|
JNIEXPORT void JNICALL Java_org_lwjgl_glfw_CallbackBridge_nativeSendFramebufferSize(JNIEnv* env, jclass clazz, jint width, jint height) {
|
||||||
if (GLFW_invoke_FramebufferSize && isInputReady) {
|
if (GLFW_invoke_FramebufferSize && isInputReady) {
|
||||||
if (isUsePushPollCall) {
|
if (isUseStackQueueCall) {
|
||||||
struct GLFWInputEvent curr = glfwInputEventArr[glfwInputEventIndex++];
|
struct GLFWInputEvent curr = glfwInputEventArr[glfwInputEventIndex++];
|
||||||
curr.type = EVENT_TYPE_FRAMEBUFFER_SIZE;
|
curr.type = EVENT_TYPE_FRAMEBUFFER_SIZE;
|
||||||
curr.i1 = width;
|
curr.i1 = width;
|
||||||
@ -298,7 +300,7 @@ JNIEXPORT void JNICALL Java_org_lwjgl_glfw_CallbackBridge_nativeSendFramebufferS
|
|||||||
|
|
||||||
JNIEXPORT void JNICALL Java_org_lwjgl_glfw_CallbackBridge_nativeSendKey(JNIEnv* env, jclass clazz, jint key, jint scancode, jint action, jint mods) {
|
JNIEXPORT void JNICALL Java_org_lwjgl_glfw_CallbackBridge_nativeSendKey(JNIEnv* env, jclass clazz, jint key, jint scancode, jint action, jint mods) {
|
||||||
if (GLFW_invoke_Key && isInputReady) {
|
if (GLFW_invoke_Key && isInputReady) {
|
||||||
if (isUsePushPollCall) {
|
if (isUseStackQueueCall) {
|
||||||
struct GLFWInputEvent curr = glfwInputEventArr[glfwInputEventIndex++];
|
struct GLFWInputEvent curr = glfwInputEventArr[glfwInputEventIndex++];
|
||||||
curr.type = EVENT_TYPE_KEY;
|
curr.type = EVENT_TYPE_KEY;
|
||||||
curr.i1 = key;
|
curr.i1 = key;
|
||||||
@ -316,7 +318,7 @@ JNIEXPORT void JNICALL Java_org_lwjgl_glfw_CallbackBridge_nativeSendMouseButton(
|
|||||||
// Notify to prepare set new grab pos
|
// Notify to prepare set new grab pos
|
||||||
isPrepareGrabPos = true;
|
isPrepareGrabPos = true;
|
||||||
} else if (GLFW_invoke_MouseButton) {
|
} else if (GLFW_invoke_MouseButton) {
|
||||||
if (isUsePushPollCall) {
|
if (isUseStackQueueCall) {
|
||||||
struct GLFWInputEvent curr = glfwInputEventArr[glfwInputEventIndex++];
|
struct GLFWInputEvent curr = glfwInputEventArr[glfwInputEventIndex++];
|
||||||
curr.type = EVENT_TYPE_MOUSE_BUTTON;
|
curr.type = EVENT_TYPE_MOUSE_BUTTON;
|
||||||
curr.i1 = button;
|
curr.i1 = button;
|
||||||
@ -330,7 +332,7 @@ JNIEXPORT void JNICALL Java_org_lwjgl_glfw_CallbackBridge_nativeSendMouseButton(
|
|||||||
|
|
||||||
JNIEXPORT void JNICALL Java_org_lwjgl_glfw_CallbackBridge_nativeSendScroll(JNIEnv* env, jclass clazz, jdouble xoffset, jdouble yoffset) {
|
JNIEXPORT void JNICALL Java_org_lwjgl_glfw_CallbackBridge_nativeSendScroll(JNIEnv* env, jclass clazz, jdouble xoffset, jdouble yoffset) {
|
||||||
if (GLFW_invoke_Scroll && isInputReady) {
|
if (GLFW_invoke_Scroll && isInputReady) {
|
||||||
if (isUsePushPollCall) {
|
if (isUseStackQueueCall) {
|
||||||
struct GLFWInputEvent curr = glfwInputEventArr[glfwInputEventIndex++];
|
struct GLFWInputEvent curr = glfwInputEventArr[glfwInputEventIndex++];
|
||||||
curr.type = EVENT_TYPE_SCROLL;
|
curr.type = EVENT_TYPE_SCROLL;
|
||||||
curr.d1 = (double) xoffset;
|
curr.d1 = (double) xoffset;
|
||||||
@ -342,7 +344,7 @@ JNIEXPORT void JNICALL Java_org_lwjgl_glfw_CallbackBridge_nativeSendScroll(JNIEn
|
|||||||
|
|
||||||
JNIEXPORT void JNICALL Java_org_lwjgl_glfw_CallbackBridge_nativeSendWindowSize(JNIEnv* env, jclass clazz, jint width, jint height) {
|
JNIEXPORT void JNICALL Java_org_lwjgl_glfw_CallbackBridge_nativeSendWindowSize(JNIEnv* env, jclass clazz, jint width, jint height) {
|
||||||
if (GLFW_invoke_WindowSize && isInputReady) {
|
if (GLFW_invoke_WindowSize && isInputReady) {
|
||||||
if (isUsePushPollCall) {
|
if (isUseStackQueueCall) {
|
||||||
struct GLFWInputEvent curr = glfwInputEventArr[glfwInputEventIndex++];
|
struct GLFWInputEvent curr = glfwInputEventArr[glfwInputEventIndex++];
|
||||||
curr.type = EVENT_TYPE_WINDOW_SIZE;
|
curr.type = EVENT_TYPE_WINDOW_SIZE;
|
||||||
curr.i1 = width;
|
curr.i1 = width;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user