mirror of
https://github.com/AngelAuraMC/Amethyst-Android.git
synced 2025-09-13 14:51:51 -04:00
[Bug fix] Trigger mouse/touch input cause crash
This commit is contained in:
parent
69f70d628b
commit
add4bc80b2
@ -14,7 +14,7 @@ struct GLFWInputEvent {
|
|||||||
struct GLFWInputEvent glfwInputEventArr[100];
|
struct GLFWInputEvent glfwInputEventArr[100];
|
||||||
int glfwInputEventIndex;
|
int glfwInputEventIndex;
|
||||||
|
|
||||||
int *grabCursorX, *grabCursorY, *lastCursorX, *lastCursorY;
|
int grabCursorX, grabCursorY, lastCursorX, lastCursorY;
|
||||||
|
|
||||||
#define EVENT_TYPE_CHAR 1000
|
#define EVENT_TYPE_CHAR 1000
|
||||||
#define EVENT_TYPE_CHAR_MODS 1001
|
#define EVENT_TYPE_CHAR_MODS 1001
|
||||||
@ -115,20 +115,20 @@ void getJavaInputBridge(jclass* clazz, jmethodID* method) {
|
|||||||
void invokeCursorPos(int x, int y) {
|
void invokeCursorPos(int x, int y) {
|
||||||
if (isGrabbing) {
|
if (isGrabbing) {
|
||||||
if (!isPrepareGrabPos) {
|
if (!isPrepareGrabPos) {
|
||||||
*grabCursorX += x - *lastCursorX;
|
grabCursorX += x - lastCursorX;
|
||||||
*grabCursorY += y - *lastCursorY;
|
grabCursorY += y - lastCursorY;
|
||||||
} else {
|
} else {
|
||||||
isPrepareGrabPos = false;
|
isPrepareGrabPos = false;
|
||||||
*lastCursorX = x;
|
lastCursorX = x;
|
||||||
*lastCursorY = y;
|
lastCursorY = y;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!isUseStackQueueCall && GLFW_invoke_CursorPos) {
|
if (!isUseStackQueueCall && GLFW_invoke_CursorPos) {
|
||||||
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;
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
void addInputToQueue(GLFWInputEvent event) {
|
void addInputToQueue(GLFWInputEvent event) {
|
||||||
@ -141,8 +141,8 @@ void addInputToQueue(GLFWInputEvent event) {
|
|||||||
*/
|
*/
|
||||||
JNIEXPORT void JNICALL Java_org_lwjgl_glfw_CallbackBridge_nativeAttachThreadToOther(JNIEnv* env, jclass clazz, jboolean isAndroid, jboolean isUseStackQueue) {
|
JNIEXPORT void JNICALL Java_org_lwjgl_glfw_CallbackBridge_nativeAttachThreadToOther(JNIEnv* env, jclass clazz, jboolean isAndroid, jboolean isUseStackQueue) {
|
||||||
glfwInputEventIndex = -1;
|
glfwInputEventIndex = -1;
|
||||||
// isUseStackQueueCall = 1;
|
isUseStackQueueCall = 1;
|
||||||
isUseStackQueueCall = (int) isUseStackQueue;
|
// isUseStackQueueCall = (int) isUseStackQueue;
|
||||||
if (isUseStackQueue) {
|
if (isUseStackQueue) {
|
||||||
isPrepareGrabPos = true;
|
isPrepareGrabPos = true;
|
||||||
} else if (isAndroid) {
|
} else if (isAndroid) {
|
||||||
@ -178,16 +178,16 @@ JNIEXPORT void JNICALL Java_org_lwjgl_glfw_GLFW_nglfwPollEvents(JNIEnv* env, jcl
|
|||||||
/*
|
/*
|
||||||
if (debugTimes < 1000) {
|
if (debugTimes < 1000) {
|
||||||
debugTimes++;
|
debugTimes++;
|
||||||
LOGI("INPUT: IsUseStackQueue=%d, CurrentInputLength=%d, CursorX=%d, CursorY=%d", isUseStackQueueCall, glfwInputEventIndex, *lastCursorX, *lastCursorY);
|
LOGI("INPUT: IsUseStackQueue=%d, CurrentInputLength=%d, CursorX=%d, CursorY=%d", isUseStackQueueCall, glfwInputEventIndex, lastCursorX, lastCursorY);
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
if (isUseStackQueueCall) {
|
if (isUseStackQueueCall) {
|
||||||
if (diffX != *lastCursorX || diffY != *lastCursorY) {
|
if (diffX != lastCursorX || diffY != lastCursorY) {
|
||||||
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));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user