mirror of
https://github.com/AngelAuraMC/Amethyst-Android.git
synced 2025-09-13 14:51:51 -04:00
Try use X Y pointer
This commit is contained in:
parent
02862c15f2
commit
21006fd8cb
@ -11,6 +11,9 @@ struct GLFWInputEvent {
|
|||||||
double d1, d2;
|
double d1, d2;
|
||||||
};
|
};
|
||||||
struct GLFWInputEvent* glfwInputEventArr;
|
struct GLFWInputEvent* glfwInputEventArr;
|
||||||
|
|
||||||
|
int *grabCursorX, *grabCursorY, *lastCursorX, *lastCursorY;
|
||||||
|
|
||||||
int glfwInputEventIndex;
|
int glfwInputEventIndex;
|
||||||
|
|
||||||
#define EVENT_TYPE_CHAR 1000
|
#define EVENT_TYPE_CHAR 1000
|
||||||
@ -70,8 +73,6 @@ void JNI_OnUnload(JavaVM* vm, void* reserved) {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
free(glfwInputEventArr);
|
free(glfwInputEventArr);
|
||||||
|
|
||||||
return JNI_VERSION_1_4;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#define ADD_CALLBACK_WWIN(NAME) \
|
#define ADD_CALLBACK_WWIN(NAME) \
|
||||||
@ -114,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) {
|
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 isUseStackQueue) {
|
JNIEXPORT void JNICALL Java_org_lwjgl_glfw_CallbackBridge_nativeAttachThreadToOther(JNIEnv* env, jclass clazz, jboolean isAndroid, jboolean isUseStackQueue) {
|
||||||
@ -137,9 +138,7 @@ JNIEXPORT void JNICALL Java_org_lwjgl_glfw_CallbackBridge_nativeAttachThreadToOt
|
|||||||
isPrepareGrabPos = true;
|
isPrepareGrabPos = true;
|
||||||
|
|
||||||
glfwInputEventArr = calloc(100, sizeof(struct GLFWInputEvent));
|
glfwInputEventArr = calloc(100, sizeof(struct GLFWInputEvent));
|
||||||
}
|
} else if (isAndroid) {
|
||||||
|
|
||||||
if (isAndroid) {
|
|
||||||
firstJavaVM = dalvikJavaVMPtr;
|
firstJavaVM = dalvikJavaVMPtr;
|
||||||
firstJNIEnv = dalvikJNIEnvPtr_ANDROID;
|
firstJNIEnv = dalvikJNIEnvPtr_ANDROID;
|
||||||
secondJavaVM = runtimeJavaVMPtr;
|
secondJavaVM = runtimeJavaVMPtr;
|
||||||
@ -169,29 +168,29 @@ JNIEXPORT jboolean JNICALL Java_org_lwjgl_glfw_CallbackBridge_nativeIsGrabbing(J
|
|||||||
int diffX, diffY, diffGrabX, diffGrabY, debugTimes;
|
int diffX, diffY, diffGrabX, diffGrabY, debugTimes;
|
||||||
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 (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));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i <= glfwInputEventIndex; i++) {
|
for (int i = 0; i <= glfwInputEventIndex; i++) {
|
||||||
struct GLFWInputEvent curr = glfwInputEventArr[i];
|
struct GLFWInputEvent curr = glfwInputEventArr[i];
|
||||||
|
/*
|
||||||
if (debugTimes < 1000) {
|
if (debugTimes < 1000) {
|
||||||
LOGI("INPUT: Got input event %d", curr.type);
|
LOGI("INPUT: Got input event %d", curr.type);
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
switch (curr.type) {
|
switch (curr.type) {
|
||||||
case EVENT_TYPE_CHAR:
|
case EVENT_TYPE_CHAR:
|
||||||
if (GLFW_invoke_Char) {
|
if (GLFW_invoke_Char) {
|
||||||
@ -237,8 +236,8 @@ JNIEXPORT void JNICALL Java_org_lwjgl_glfw_GLFW_nglfwPollEvents(JNIEnv* env, jcl
|
|||||||
LOGW("Unknown GLFW input event: %d", curr.type);
|
LOGW("Unknown GLFW input event: %d", curr.type);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
glfwInputEventIndex = -1;
|
|
||||||
}
|
}
|
||||||
|
glfwInputEventIndex = -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11,8 +11,6 @@ JavaVM* dalvikJavaVMPtr;
|
|||||||
JNIEnv* dalvikJNIEnvPtr_ANDROID;
|
JNIEnv* dalvikJNIEnvPtr_ANDROID;
|
||||||
JNIEnv* dalvikJNIEnvPtr_JRE;
|
JNIEnv* dalvikJNIEnvPtr_JRE;
|
||||||
|
|
||||||
int grabCursorX, grabCursorY, lastCursorX, lastCursorY;
|
|
||||||
|
|
||||||
long showingWindow;
|
long showingWindow;
|
||||||
|
|
||||||
bool isAndroidThreadAttached, isRuntimeThreadAttached, isInputReady, isCursorEntered, isPrepareGrabPos;
|
bool isAndroidThreadAttached, isRuntimeThreadAttached, isInputReady, isCursorEntered, isPrepareGrabPos;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user