Cursor pos dbg

This commit is contained in:
khanhduytran0 2020-10-16 18:40:15 +07:00
parent 7368171664
commit 98d78eb0e2

View File

@ -159,10 +159,22 @@ JNIEXPORT jboolean JNICALL Java_org_lwjgl_glfw_CallbackBridge_nativeIsGrabbing(J
return isGrabbing; return isGrabbing;
} }
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 (isUsePushPollCall) {
if (diffX != lastCursorX || diffY != lastCursorY) {
if (logTimes < 1000) {
logTimes++;
LOGI("Mouse pos diff! x=%d, y=%d", lastCursorX, lastCursorY);
}
diffX = lastCursorX;
diffY = lastCursorY;
}
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));
}
for (int i = 0; i < glfwInputEventIndex; i++) { for (int i = 0; i < glfwInputEventIndex; i++) {
struct GLFWInputEvent curr = glfwInputEventArr[i]; struct GLFWInputEvent curr = glfwInputEventArr[i];
@ -221,7 +233,7 @@ JNIEXPORT jboolean JNICALL Java_org_lwjgl_glfw_CallbackBridge_nativeSendChar(JNI
if (isUsePushPollCall) { if (isUsePushPollCall) {
struct GLFWInputEvent curr = glfwInputEventArr[glfwInputEventIndex++]; struct GLFWInputEvent curr = glfwInputEventArr[glfwInputEventIndex++];
curr.type = EVENT_TYPE_CHAR; curr.type = EVENT_TYPE_CHAR;
curr.ui1 = codepoint; curr.ui1 = (unsigned int) codepoint;
} else } else
GLFW_invoke_Char(showingWindow, codepoint); GLFW_invoke_Char(showingWindow, codepoint);
return JNI_TRUE; return JNI_TRUE;
@ -234,7 +246,7 @@ JNIEXPORT jboolean JNICALL Java_org_lwjgl_glfw_CallbackBridge_nativeSendCharMods
if (isUsePushPollCall) { if (isUsePushPollCall) {
struct GLFWInputEvent curr = glfwInputEventArr[glfwInputEventIndex++]; struct GLFWInputEvent curr = glfwInputEventArr[glfwInputEventIndex++];
curr.type = EVENT_TYPE_CHAR_MODS; curr.type = EVENT_TYPE_CHAR_MODS;
curr.ui1 = codepoint; curr.ui1 = (unsigned int) codepoint;
curr.i2 = mods; curr.i2 = mods;
} else } else
GLFW_invoke_CharMods(showingWindow, codepoint, mods); GLFW_invoke_CharMods(showingWindow, codepoint, mods);