*** empty log message ***

This commit is contained in:
Elias Naur 2003-10-08 07:49:43 +00:00
parent 859f7bf50e
commit fc925baab4
9 changed files with 32 additions and 36 deletions

View File

@ -56,7 +56,7 @@ public class Cursor {
/** /**
* The native handle to the 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 * 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. * Gets the native handle associated with the cursor object.
*/ */
public int getHandle() { public long getHandle() {
return nativeHandle; return nativeHandle;
} }
/** /**
* Native method to create a native cursor * 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 * Native method to destroy a native cursor
*/ */
private static native void nDestroyCursor(int handle); private static native void nDestroyCursor(long handle);
} }

View File

@ -146,7 +146,7 @@ public class Mouse {
} }
/** Native method to set the native cursor */ /** 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 * Gets the minimum size of a native cursor. Can only be called if

View File

@ -8,22 +8,23 @@
extern "C" { extern "C" {
#endif #endif
/* Inaccessible static: _00024assertionsDisabled */ /* Inaccessible static: _00024assertionsDisabled */
/* Inaccessible static: initialized */
/* Inaccessible static: class_00024org_00024lwjgl_00024input_00024Cursor */ /* Inaccessible static: class_00024org_00024lwjgl_00024input_00024Cursor */
/* /*
* Class: org_lwjgl_input_Cursor * Class: org_lwjgl_input_Cursor
* Method: nCreateCursor * 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); (JNIEnv *, jclass, jint, jint, jint, jint, jint, jobject, jint, jobject, jint);
/* /*
* Class: org_lwjgl_input_Cursor * Class: org_lwjgl_input_Cursor
* Method: nDestroyCursor * Method: nDestroyCursor
* Signature: (I)V * Signature: (J)V
*/ */
JNIEXPORT void JNICALL Java_org_lwjgl_input_Cursor_nDestroyCursor JNIEXPORT void JNICALL Java_org_lwjgl_input_Cursor_nDestroyCursor
(JNIEnv *, jclass, jint); (JNIEnv *, jclass, jlong);
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@ -37,10 +37,10 @@ JNIEXPORT jint JNICALL Java_org_lwjgl_input_Mouse_nGetNativeCursorCaps
/* /*
* Class: org_lwjgl_input_Mouse * Class: org_lwjgl_input_Mouse
* Method: nSetNativeCursor * Method: nSetNativeCursor
* Signature: (I)V * Signature: (J)V
*/ */
JNIEXPORT void JNICALL Java_org_lwjgl_input_Mouse_nSetNativeCursor JNIEXPORT void JNICALL Java_org_lwjgl_input_Mouse_nSetNativeCursor
(JNIEnv *, jclass, jint); (JNIEnv *, jclass, jlong);
/* /*
* Class: org_lwjgl_input_Mouse * Class: org_lwjgl_input_Mouse

View File

@ -7,7 +7,7 @@
* Method: nCreateCursor * Method: nCreateCursor
* Signature: (IIIIIII)I * 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) (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; const int *delays = NULL;
@ -39,7 +39,7 @@ JNIEXPORT jint JNICALL Java_org_lwjgl_input_Cursor_nCreateCursor
* Signature: (I)V * Signature: (I)V
*/ */
JNIEXPORT void JNICALL Java_org_lwjgl_input_Cursor_nDestroyCursor 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; Cursor cursor = (Cursor)cursor_handle;
XFreeCursor(getCurrentDisplay(), cursor); XFreeCursor(getCurrentDisplay(), cursor);

View File

@ -204,7 +204,7 @@ JNIEXPORT jint JNICALL Java_org_lwjgl_input_Mouse_nGetNativeCursorCaps
* Signature: (I)V * Signature: (I)V
*/ */
JNIEXPORT void JNICALL Java_org_lwjgl_input_Mouse_nSetNativeCursor 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 (cursor_handle != 0) {
Cursor cursor = (Cursor)cursor_handle; Cursor cursor = (Cursor)cursor_handle;

View File

@ -46,16 +46,8 @@
#define NUM_BUTTONS 7 #define NUM_BUTTONS 7
static unsigned char button_state[NUM_BUTTONS]; static unsigned char button_state[NUM_BUTTONS];
static int last_x;
static pascal OSStatus doMouseDragged(EventHandlerCallRef next_handler, EventRef event, void *user_data) { static int last_y;
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 pascal OSStatus doMouseDown(EventHandlerCallRef next_handler, EventRef event, void *user_data) { static pascal OSStatus doMouseDown(EventHandlerCallRef next_handler, EventRef event, void *user_data) {
printf("Mouse down\n"); printf("Mouse down\n");
@ -69,14 +61,12 @@ printf("Mouse up\n");
static pascal OSStatus doMouseWheel(EventHandlerCallRef next_handler, EventRef event, void *user_data) { static pascal OSStatus doMouseWheel(EventHandlerCallRef next_handler, EventRef event, void *user_data) {
printf("Mouse wheel\n"); printf("Mouse wheel\n");
return eventNotHandledErr; // allow the event to propagate return noErr;
} }
bool registerMouseHandler(JNIEnv* env, WindowRef win_ref) { bool registerMouseHandler(JNIEnv* env, WindowRef win_ref) {
bool error = registerHandler(env, win_ref, doMouseDown, kEventClassMouse, kEventMouseDown); bool error = registerHandler(env, win_ref, doMouseDown, kEventClassMouse, kEventMouseDown);
error = error || registerHandler(env, win_ref, doMouseUp, kEventClassMouse, kEventMouseUp); 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); error = error || registerHandler(env, win_ref, doMouseWheel, kEventClassMouse, kEventMouseWheelMoved);
return !error; 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 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) { 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) { 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_nDestroy(JNIEnv * env, jclass clazz) {
} }
JNIEXPORT void JNICALL Java_org_lwjgl_input_Mouse_nPoll(JNIEnv * env, jclass clazz) { JNIEXPORT void JNICALL Java_org_lwjgl_input_Mouse_nPoll(JNIEnv * env, jclass clazz) {
CGMouseDelta x; Point cursor_pos;
CGMouseDelta y; GetMouse(&cursor_pos);
CGGetLastMouseDelta(&x, &y); int dx = cursor_pos.v - last_x;
if (x != 0 || y != 0) int dy = cursor_pos.h - last_y;
printf("delta x %d y %d\n", x, 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);
} }

View File

@ -7,7 +7,7 @@
* Method: nCreateCursor * Method: nCreateCursor
* Signature: (IIIIIIIII)I * 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) (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; 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 * Signature: (I)V
*/ */
JNIEXPORT void JNICALL Java_org_lwjgl_input_Cursor_nDestroyCursor 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; HCURSOR cursor = (HCURSOR)cursor_handle;
DestroyCursor(cursor); DestroyCursor(cursor);

View File

@ -163,7 +163,7 @@ JNIEXPORT jint JNICALL Java_org_lwjgl_input_Mouse_nGetNativeCursorCaps
* Signature: (I)V * Signature: (I)V
*/ */
JNIEXPORT void JNICALL Java_org_lwjgl_input_Mouse_nSetNativeCursor 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 (cursor_handle != 0) {
if (mDIDevice == NULL) if (mDIDevice == NULL)