only generate events if mouse is actually alive

This commit is contained in:
Brian Matzon 2004-11-27 10:17:15 +00:00
parent 83dd8b6bbc
commit 3ae8c81129
1 changed files with 22 additions and 15 deletions

View File

@ -161,27 +161,33 @@ JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Win32Display_enableMouseBuffer(JNIE
} }
void handleMouseScrolled(int event_dwheel) { void handleMouseScrolled(int event_dwheel) {
accum_dwheel += event_dwheel; if(mCreate_success) {
putMouseEvent(-1, 0, event_dwheel); accum_dwheel += event_dwheel;
putMouseEvent(-1, 0, event_dwheel);
}
} }
void handleMouseMoved(int x, int y) { void handleMouseMoved(int x, int y) {
y = transformY(y); if(mCreate_success) {
int dx = x - last_x; y = transformY(y);
int dy = y - last_y; int dx = x - last_x;
accum_dx += dx; int dy = y - last_y;
accum_dy += dy; accum_dx += dx;
last_x = x; accum_dy += dy;
last_y = y; last_x = x;
if (mouse_grabbed) { last_y = y;
putMouseEventWithCoords(-1, 0, dx, dy, 0); if (mouse_grabbed) {
} else { putMouseEventWithCoords(-1, 0, dx, dy, 0);
putMouseEventWithCoords(-1, 0, x, y, 0); } else {
} putMouseEventWithCoords(-1, 0, x, y, 0);
}
}
} }
void handleMouseButton(int button, int state) { 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) { static void copyDXEvents(int num_di_events, DIDEVICEOBJECTDATA *di_buffer) {
@ -354,6 +360,7 @@ static void ShutdownMouse() {
lpdi->Release(); lpdi->Release();
lpdi = NULL; lpdi = NULL;
} }
mCreate_success = false;
} }
/** /**
* Enumerates the capabilities of the Mouse attached to the system * Enumerates the capabilities of the Mouse attached to the system