From ad1987d748369a7266019669f0fb0b74a6cde664 Mon Sep 17 00:00:00 2001 From: Elias Naur Date: Tue, 27 Dec 2005 13:40:21 +0000 Subject: [PATCH] Win32: Moved handleMessages to java side (update()) --- src/java/org/lwjgl/opengl/Win32Display.java | 29 ++++++++++++++++++--- src/native/win32/Window.h | 2 -- src/native/win32/org_lwjgl_input_Keyboard.c | 4 +-- src/native/win32/org_lwjgl_input_Mouse.c | 8 ++---- 4 files changed, 29 insertions(+), 14 deletions(-) diff --git a/src/java/org/lwjgl/opengl/Win32Display.java b/src/java/org/lwjgl/opengl/Win32Display.java index 084b75d1..7cba86a9 100644 --- a/src/java/org/lwjgl/opengl/Win32Display.java +++ b/src/java/org/lwjgl/opengl/Win32Display.java @@ -120,8 +120,18 @@ final class Win32Display implements DisplayImplementation { public native int getButtonCount(); public native void createMouse() throws LWJGLException; public native void destroyMouse(); - public native void pollMouse(IntBuffer coord_buffer, ByteBuffer buttons); - public native int readMouse(IntBuffer buffer, int buffer_position); + public void pollMouse(IntBuffer coord_buffer, ByteBuffer buttons) { + update(); + nPollMouse(coord_buffer, buttons); + } + private native void nPollMouse(IntBuffer coord_buffer, ByteBuffer buttons); + + public int readMouse(IntBuffer buffer, int buffer_position) { + update(); + return nReadMouse(buffer, buffer_position); + } + private native int nReadMouse(IntBuffer buffer, int buffer_position); + public native void grabMouse(boolean grab); public int getNativeCursorCapabilities() { return Cursor.CURSOR_ONE_BIT_TRANSPARENCY; @@ -135,8 +145,19 @@ final class Win32Display implements DisplayImplementation { /* Keyboard */ public native void createKeyboard() throws LWJGLException; public native void destroyKeyboard(); - public native void pollKeyboard(ByteBuffer keyDownBuffer); - public native int readKeyboard(IntBuffer buffer, int buffer_position); + + public void pollKeyboard(ByteBuffer keyDownBuffer) { + update(); + nPollKeyboard(keyDownBuffer); + } + private native void nPollKeyboard(ByteBuffer keyDownBuffer); + + public int readKeyboard(IntBuffer buffer, int buffer_position) { + update(); + return nReadKeyboard(buffer, buffer_position); + } + private native int nReadKeyboard(IntBuffer buffer, int buffer_position); + public native int isStateKeySet(int key); public native ByteBuffer nCreateCursor(int width, int height, int xHotspot, int yHotspot, int numImages, IntBuffer images, int images_offset, IntBuffer delays, int delays_offset) throws LWJGLException; diff --git a/src/native/win32/Window.h b/src/native/win32/Window.h index 60a4d608..7e115165 100644 --- a/src/native/win32/Window.h +++ b/src/native/win32/Window.h @@ -66,8 +66,6 @@ WINDOW_H_API void handleMouseButton(int button, int state); - WINDOW_H_API void handleMessages(void); - WINDOW_H_API bool getCurrentFullscreen(); /* * Handle native Win32 messages diff --git a/src/native/win32/org_lwjgl_input_Keyboard.c b/src/native/win32/org_lwjgl_input_Keyboard.c index 9f23ce35..eec17568 100644 --- a/src/native/win32/org_lwjgl_input_Keyboard.c +++ b/src/native/win32/org_lwjgl_input_Keyboard.c @@ -137,7 +137,7 @@ JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Win32Display_destroyKeyboard * Method: nPoll * Signature: (I)V */ -JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Win32Display_pollKeyboard +JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Win32Display_nPollKeyboard (JNIEnv * env, jobject self, jobject buffer) { HRESULT ret; @@ -171,7 +171,7 @@ JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Win32Display_pollKeyboard IDirectInputDevice_GetDeviceState(lpdiKeyboard, (DWORD)buffer_size, keyboardBuffer); } -JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_Win32Display_readKeyboard +JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_Win32Display_nReadKeyboard (JNIEnv * env, jobject self, jobject buffer_obj, jint buffer_position) { UINT scan_code; diff --git a/src/native/win32/org_lwjgl_input_Mouse.c b/src/native/win32/org_lwjgl_input_Mouse.c index ea17f95a..27d96bd9 100644 --- a/src/native/win32/org_lwjgl_input_Mouse.c +++ b/src/native/win32/org_lwjgl_input_Mouse.c @@ -315,15 +315,13 @@ static void readDXBuffer(JNIEnv *env) { } } -JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_Win32Display_readMouse +JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_Win32Display_nReadMouse (JNIEnv * env, jobject self, jobject buffer_obj, jint buffer_position) { jint* buffer_ptr = (jint *)(*env)->GetDirectBufferAddress(env, buffer_obj) + buffer_position; int buffer_size = ((*env)->GetDirectBufferCapacity(env, buffer_obj))/sizeof(jint) - buffer_position; if (mouse_grabbed) { readDXBuffer(env); - } else { - handleMessages(); } return copyEvents(&event_queue, buffer_ptr, buffer_size); } @@ -348,7 +346,7 @@ JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Win32Display_destroyMouse(JNIEnv *e ShutdownMouse(env); } -JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Win32Display_pollMouse(JNIEnv * env, jobject self, jobject coord_buffer_obj, jobject button_buffer_obj) { +JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Win32Display_nPollMouse(JNIEnv * env, jobject self, jobject coord_buffer_obj, jobject button_buffer_obj) { UpdateMouseFields(env, coord_buffer_obj, button_buffer_obj); } @@ -469,8 +467,6 @@ static void UpdateMouseFields(JNIEnv *env, jobject coord_buffer_obj, jobject but return; } - handleMessages(); - if (mouse_grabbed) { hRes = IDirectInputDevice_GetDeviceState(mDIDevice, sizeof(DIMOUSESTATE), &diMouseState); if (hRes != DI_OK) {