From 3ae8c8112988677385141d655ebcd6aecb775be6 Mon Sep 17 00:00:00 2001 From: Brian Matzon Date: Sat, 27 Nov 2004 10:17:15 +0000 Subject: [PATCH] only generate events if mouse is actually alive --- src/native/win32/org_lwjgl_input_Mouse.cpp | 37 +++++++++++++--------- 1 file changed, 22 insertions(+), 15 deletions(-) diff --git a/src/native/win32/org_lwjgl_input_Mouse.cpp b/src/native/win32/org_lwjgl_input_Mouse.cpp index a4b5f98f..1ee94e41 100644 --- a/src/native/win32/org_lwjgl_input_Mouse.cpp +++ b/src/native/win32/org_lwjgl_input_Mouse.cpp @@ -161,27 +161,33 @@ JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Win32Display_enableMouseBuffer(JNIE } void handleMouseScrolled(int event_dwheel) { - accum_dwheel += event_dwheel; - putMouseEvent(-1, 0, event_dwheel); + if(mCreate_success) { + accum_dwheel += event_dwheel; + putMouseEvent(-1, 0, event_dwheel); + } } void handleMouseMoved(int x, int y) { - y = transformY(y); - int dx = x - last_x; - int dy = y - last_y; - accum_dx += dx; - accum_dy += dy; - last_x = x; - last_y = y; - if (mouse_grabbed) { - putMouseEventWithCoords(-1, 0, dx, dy, 0); - } else { - putMouseEventWithCoords(-1, 0, x, y, 0); - } + if(mCreate_success) { + y = transformY(y); + int dx = x - last_x; + int dy = y - last_y; + accum_dx += dx; + accum_dy += dy; + last_x = x; + last_y = y; + if (mouse_grabbed) { + putMouseEventWithCoords(-1, 0, dx, dy, 0); + } else { + putMouseEventWithCoords(-1, 0, x, y, 0); + } + } } void handleMouseButton(int button, int state) { - putMouseEvent(button, state, 0); + if(mCreate_success) { + putMouseEvent(button, state, 0); + } } static void copyDXEvents(int num_di_events, DIDEVICEOBJECTDATA *di_buffer) { @@ -354,6 +360,7 @@ static void ShutdownMouse() { lpdi->Release(); lpdi = NULL; } + mCreate_success = false; } /** * Enumerates the capabilities of the Mouse attached to the system