diff --git a/src/java/org/lwjgl/input/Cursor.java b/src/java/org/lwjgl/input/Cursor.java index 4908ff85..3d177197 100644 --- a/src/java/org/lwjgl/input/Cursor.java +++ b/src/java/org/lwjgl/input/Cursor.java @@ -56,7 +56,7 @@ public class Cursor { /** * The native handle to the cursor */ - private final int nativeHandle; + private final long nativeHandle; /** * Constructs a new Cursor, with the given parameters. Mouse must have been created before you can create @@ -123,17 +123,17 @@ public class Cursor { /** * Gets the native handle associated with the cursor object. */ - public int getHandle() { + public long getHandle() { return nativeHandle; } /** * Native method to create a native cursor */ - private static native int nCreateCursor(int width, int height, int xHotspot, int yHotspot, int numImages, IntBuffer images, int images_offset, IntBuffer delays, int delays_offset); + private static native long nCreateCursor(int width, int height, int xHotspot, int yHotspot, int numImages, IntBuffer images, int images_offset, IntBuffer delays, int delays_offset); /** * Native method to destroy a native cursor */ - private static native void nDestroyCursor(int handle); + private static native void nDestroyCursor(long handle); } diff --git a/src/java/org/lwjgl/input/Mouse.java b/src/java/org/lwjgl/input/Mouse.java index 962b7317..bc62bd51 100644 --- a/src/java/org/lwjgl/input/Mouse.java +++ b/src/java/org/lwjgl/input/Mouse.java @@ -146,7 +146,7 @@ public class Mouse { } /** Native method to set the native cursor */ - private static native void nSetNativeCursor(int handle) throws Exception; + private static native void nSetNativeCursor(long handle) throws Exception; /** * Gets the minimum size of a native cursor. Can only be called if diff --git a/src/native/common/org_lwjgl_input_Cursor.h b/src/native/common/org_lwjgl_input_Cursor.h index 30d56e0a..2d2e868f 100644 --- a/src/native/common/org_lwjgl_input_Cursor.h +++ b/src/native/common/org_lwjgl_input_Cursor.h @@ -8,22 +8,23 @@ extern "C" { #endif /* Inaccessible static: _00024assertionsDisabled */ +/* Inaccessible static: initialized */ /* Inaccessible static: class_00024org_00024lwjgl_00024input_00024Cursor */ /* * Class: org_lwjgl_input_Cursor * Method: nCreateCursor - * Signature: (IIIIILjava/nio/IntBuffer;ILjava/nio/IntBuffer;I)I + * Signature: (IIIIILjava/nio/IntBuffer;ILjava/nio/IntBuffer;I)J */ -JNIEXPORT jint JNICALL Java_org_lwjgl_input_Cursor_nCreateCursor +JNIEXPORT jlong JNICALL Java_org_lwjgl_input_Cursor_nCreateCursor (JNIEnv *, jclass, jint, jint, jint, jint, jint, jobject, jint, jobject, jint); /* * Class: org_lwjgl_input_Cursor * Method: nDestroyCursor - * Signature: (I)V + * Signature: (J)V */ JNIEXPORT void JNICALL Java_org_lwjgl_input_Cursor_nDestroyCursor - (JNIEnv *, jclass, jint); + (JNIEnv *, jclass, jlong); #ifdef __cplusplus } diff --git a/src/native/common/org_lwjgl_input_Mouse.h b/src/native/common/org_lwjgl_input_Mouse.h index 0d0c09fe..64520c16 100644 --- a/src/native/common/org_lwjgl_input_Mouse.h +++ b/src/native/common/org_lwjgl_input_Mouse.h @@ -37,10 +37,10 @@ JNIEXPORT jint JNICALL Java_org_lwjgl_input_Mouse_nGetNativeCursorCaps /* * Class: org_lwjgl_input_Mouse * Method: nSetNativeCursor - * Signature: (I)V + * Signature: (J)V */ JNIEXPORT void JNICALL Java_org_lwjgl_input_Mouse_nSetNativeCursor - (JNIEnv *, jclass, jint); + (JNIEnv *, jclass, jlong); /* * Class: org_lwjgl_input_Mouse diff --git a/src/native/linux/org_lwjgl_input_Cursor.cpp b/src/native/linux/org_lwjgl_input_Cursor.cpp index 1514bf4a..faad405f 100644 --- a/src/native/linux/org_lwjgl_input_Cursor.cpp +++ b/src/native/linux/org_lwjgl_input_Cursor.cpp @@ -7,7 +7,7 @@ * Method: nCreateCursor * Signature: (IIIIIII)I */ -JNIEXPORT jint JNICALL Java_org_lwjgl_input_Cursor_nCreateCursor +JNIEXPORT jlong JNICALL Java_org_lwjgl_input_Cursor_nCreateCursor (JNIEnv *env, jclass clazz, jint width, jint height, jint x_hotspot, jint y_hotspot, jint num_images, jobject image_buffer, jint images_offset, jobject delay_buffer, jint delays_offset) { const int *delays = NULL; @@ -39,7 +39,7 @@ JNIEXPORT jint JNICALL Java_org_lwjgl_input_Cursor_nCreateCursor * Signature: (I)V */ JNIEXPORT void JNICALL Java_org_lwjgl_input_Cursor_nDestroyCursor - (JNIEnv *env, jclass clazz, jint cursor_handle) + (JNIEnv *env, jclass clazz, jlong cursor_handle) { Cursor cursor = (Cursor)cursor_handle; XFreeCursor(getCurrentDisplay(), cursor); diff --git a/src/native/linux/org_lwjgl_input_Mouse.cpp b/src/native/linux/org_lwjgl_input_Mouse.cpp index 4e2e8d44..792c86d8 100644 --- a/src/native/linux/org_lwjgl_input_Mouse.cpp +++ b/src/native/linux/org_lwjgl_input_Mouse.cpp @@ -204,7 +204,7 @@ JNIEXPORT jint JNICALL Java_org_lwjgl_input_Mouse_nGetNativeCursorCaps * Signature: (I)V */ JNIEXPORT void JNICALL Java_org_lwjgl_input_Mouse_nSetNativeCursor - (JNIEnv *env, jclass clazz, jint cursor_handle) + (JNIEnv *env, jclass clazz, jlong cursor_handle) { if (cursor_handle != 0) { Cursor cursor = (Cursor)cursor_handle; diff --git a/src/native/macosx/org_lwjgl_input_Mouse.cpp b/src/native/macosx/org_lwjgl_input_Mouse.cpp index bcdb9865..4d4ef307 100644 --- a/src/native/macosx/org_lwjgl_input_Mouse.cpp +++ b/src/native/macosx/org_lwjgl_input_Mouse.cpp @@ -46,16 +46,8 @@ #define NUM_BUTTONS 7 static unsigned char button_state[NUM_BUTTONS]; - -static pascal OSStatus doMouseDragged(EventHandlerCallRef next_handler, EventRef event, void *user_data) { -printf("Mouse dragged\n"); - return eventNotHandledErr; // allow the event to propagate -} - -static pascal OSStatus doMouseMoved(EventHandlerCallRef next_handler, EventRef event, void *user_data) { -printf("Mouse moved\n"); - return eventNotHandledErr; // allow the event to propagate -} +static int last_x; +static int last_y; static pascal OSStatus doMouseDown(EventHandlerCallRef next_handler, EventRef event, void *user_data) { printf("Mouse down\n"); @@ -69,14 +61,12 @@ printf("Mouse up\n"); static pascal OSStatus doMouseWheel(EventHandlerCallRef next_handler, EventRef event, void *user_data) { printf("Mouse wheel\n"); - return eventNotHandledErr; // allow the event to propagate + return noErr; } bool registerMouseHandler(JNIEnv* env, WindowRef win_ref) { bool error = registerHandler(env, win_ref, doMouseDown, kEventClassMouse, kEventMouseDown); error = error || registerHandler(env, win_ref, doMouseUp, kEventClassMouse, kEventMouseUp); - error = error || registerHandler(env, win_ref, doMouseMoved, kEventClassMouse, kEventMouseMoved); - error = error || registerHandler(env, win_ref, doMouseDragged, kEventClassMouse, kEventMouseDragged); error = error || registerHandler(env, win_ref, doMouseWheel, kEventClassMouse, kEventMouseWheelMoved); return !error; } @@ -95,7 +85,7 @@ JNIEXPORT void JNICALL Java_org_lwjgl_input_Mouse_initIDs(JNIEnv * env, jclass c JNIEXPORT jint JNICALL Java_org_lwjgl_input_Mouse_nGetNativeCursorCaps(JNIEnv *env, jclass clazz) { } -JNIEXPORT void JNICALL Java_org_lwjgl_input_Mouse_nSetNativeCursor(JNIEnv *env, jclass clazz, jint cursor_handle) { +JNIEXPORT void JNICALL Java_org_lwjgl_input_Mouse_nSetNativeCursor(JNIEnv *env, jclass clazz, jlong cursor_handle) { } JNIEXPORT jint JNICALL Java_org_lwjgl_input_Mouse_nGetMinCursorSize(JNIEnv *env, jclass clazz) { @@ -105,15 +95,20 @@ JNIEXPORT jint JNICALL Java_org_lwjgl_input_Mouse_nGetMaxCursorSize(JNIEnv *env, } JNIEXPORT void JNICALL Java_org_lwjgl_input_Mouse_nCreate(JNIEnv * env, jclass clazz) { + last_x = 0; + last_y = 0; } JNIEXPORT void JNICALL Java_org_lwjgl_input_Mouse_nDestroy(JNIEnv * env, jclass clazz) { } JNIEXPORT void JNICALL Java_org_lwjgl_input_Mouse_nPoll(JNIEnv * env, jclass clazz) { - CGMouseDelta x; - CGMouseDelta y; - CGGetLastMouseDelta(&x, &y); - if (x != 0 || y != 0) - printf("delta x %d y %d\n", x, y); + Point cursor_pos; + GetMouse(&cursor_pos); + int dx = cursor_pos.v - last_x; + int dy = cursor_pos.h - last_y; + last_x += dx; + last_y += dy; + if (dx != 0 || dy != 0) + printf("dx %d dy %d, lx %d ly %d\n", dx, dy, last_x, last_y); } diff --git a/src/native/win32/org_lwjgl_input_Cursor.cpp b/src/native/win32/org_lwjgl_input_Cursor.cpp index 85371e35..f97ece51 100755 --- a/src/native/win32/org_lwjgl_input_Cursor.cpp +++ b/src/native/win32/org_lwjgl_input_Cursor.cpp @@ -7,7 +7,7 @@ * Method: nCreateCursor * Signature: (IIIIIIIII)I */ -JNIEXPORT jint JNICALL Java_org_lwjgl_input_Cursor_nCreateCursor +JNIEXPORT jlong JNICALL Java_org_lwjgl_input_Cursor_nCreateCursor (JNIEnv *env, jclass clazz, jint width, jint height, jint x_hotspot, jint y_hotspot, jint num_images, jobject image_buffer, jint images_offset, jobject delay_buffer, jint delays_offset) { int *pixels = (int *)env->GetDirectBufferAddress(image_buffer) + images_offset; @@ -104,7 +104,7 @@ JNIEXPORT jint JNICALL Java_org_lwjgl_input_Cursor_nCreateCursor * Signature: (I)V */ JNIEXPORT void JNICALL Java_org_lwjgl_input_Cursor_nDestroyCursor - (JNIEnv *env, jclass clazz, jint cursor_handle) + (JNIEnv *env, jclass clazz, jlong cursor_handle) { HCURSOR cursor = (HCURSOR)cursor_handle; DestroyCursor(cursor); diff --git a/src/native/win32/org_lwjgl_input_Mouse.cpp b/src/native/win32/org_lwjgl_input_Mouse.cpp index 1ab8e81a..7ab86d83 100644 --- a/src/native/win32/org_lwjgl_input_Mouse.cpp +++ b/src/native/win32/org_lwjgl_input_Mouse.cpp @@ -163,7 +163,7 @@ JNIEXPORT jint JNICALL Java_org_lwjgl_input_Mouse_nGetNativeCursorCaps * Signature: (I)V */ JNIEXPORT void JNICALL Java_org_lwjgl_input_Mouse_nSetNativeCursor - (JNIEnv *env, jclass clazz, jint cursor_handle) + (JNIEnv *env, jclass clazz, jlong cursor_handle) { if (cursor_handle != 0) { if (mDIDevice == NULL)