Win32: Moved handleMessages to java side (update())

This commit is contained in:
Elias Naur 2005-12-27 13:40:21 +00:00
parent 9bd5c0b9b4
commit ad1987d748
4 changed files with 29 additions and 14 deletions

View File

@ -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;

View File

@ -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

View File

@ -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;

View File

@ -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) {