From a6c56bd7919c19c46533ca5799009e8a6def0610 Mon Sep 17 00:00:00 2001 From: Elias Naur Date: Tue, 14 Oct 2003 14:29:23 +0000 Subject: [PATCH] *** empty log message *** --- .../org/lwjgl/test/input/HWCursorTest.java | 3 +- src/java/org/lwjgl/test/input/MouseTest.java | 2 +- src/native/common/common_tools.cpp | 2 +- src/native/linux/org_lwjgl_input_Cursor.cpp | 41 ++++++++++++++++ src/native/macosx/Makefile.am | 2 +- src/native/macosx/org_lwjgl_input_Cursor.cpp | 48 +++++++++++++++++++ src/native/macosx/org_lwjgl_input_Mouse.cpp | 13 +++-- src/native/win32/org_lwjgl_input_Cursor.cpp | 41 ++++++++++++++++ 8 files changed, 144 insertions(+), 8 deletions(-) create mode 100644 src/native/macosx/org_lwjgl_input_Cursor.cpp diff --git a/src/java/org/lwjgl/test/input/HWCursorTest.java b/src/java/org/lwjgl/test/input/HWCursorTest.java index 6fcaf1bd..3b1697ac 100644 --- a/src/java/org/lwjgl/test/input/HWCursorTest.java +++ b/src/java/org/lwjgl/test/input/HWCursorTest.java @@ -103,7 +103,8 @@ public class HWCursorTest { System.exit(0); } System.out.println("Maximum native cursor size: " + Mouse.getMaxCursorSize() + ", min size: " + Mouse.getMinCursorSize()); - mouse_x = mouse_y = 0; + mouse_x = 400; + mouse_y = 300; int num_images = 3; int image_size = Mouse.getMaxCursorSize()*Mouse.getMaxCursorSize(); IntBuffer cursor_images = ByteBuffer.allocateDirect(num_images*image_size*4).order(ByteOrder.nativeOrder()).asIntBuffer(); diff --git a/src/java/org/lwjgl/test/input/MouseTest.java b/src/java/org/lwjgl/test/input/MouseTest.java index b6436f0a..cff4f3d9 100644 --- a/src/java/org/lwjgl/test/input/MouseTest.java +++ b/src/java/org/lwjgl/test/input/MouseTest.java @@ -132,7 +132,7 @@ public class MouseTest { } position.x += Mouse.dx; - position.y -= Mouse.dy; + position.y += Mouse.dy; if(position.x<0) { position.x = 0; diff --git a/src/native/common/common_tools.cpp b/src/native/common/common_tools.cpp index 8bb80fc3..30e021cd 100644 --- a/src/native/common/common_tools.cpp +++ b/src/native/common/common_tools.cpp @@ -48,7 +48,7 @@ void putEventElement(event_queue_t *queue, unsigned char byte) { int next_index = (queue->list_end + 1)%EVENT_BUFFER_SIZE; if (next_index == queue->list_start) { #ifdef _DEBUG - printf("Keyboard buffer overflow!\n"); + printf("Event buffer overflow!\n"); #endif return; } diff --git a/src/native/linux/org_lwjgl_input_Cursor.cpp b/src/native/linux/org_lwjgl_input_Cursor.cpp index d087eab4..383e0c13 100644 --- a/src/native/linux/org_lwjgl_input_Cursor.cpp +++ b/src/native/linux/org_lwjgl_input_Cursor.cpp @@ -1,3 +1,44 @@ +/* + * Copyright (c) 2002 Light Weight Java Game Library Project + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of 'Light Weight Java Game Library' nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/** + * $Id$ + * + * Linux cursor handling. + * + * @author elias_naur + * @version $Revision$ + */ + #include "org_lwjgl_input_Cursor.h" #include "extxcursor.h" #include "Window.h" diff --git a/src/native/macosx/Makefile.am b/src/native/macosx/Makefile.am index a4c8a735..662033eb 100644 --- a/src/native/macosx/Makefile.am +++ b/src/native/macosx/Makefile.am @@ -11,7 +11,7 @@ NATIVE = \ org_lwjgl_opengl_MacOSX.cpp \ tools.cpp \ org_lwjgl_input_Mouse.cpp \ -# org_lwjgl_input_Cursor.cpp \ + org_lwjgl_input_Cursor.cpp \ org_lwjgl_opengl_Window.cpp # org_lwjgl_opengl_Pbuffer.cpp diff --git a/src/native/macosx/org_lwjgl_input_Cursor.cpp b/src/native/macosx/org_lwjgl_input_Cursor.cpp new file mode 100644 index 00000000..14979aa9 --- /dev/null +++ b/src/native/macosx/org_lwjgl_input_Cursor.cpp @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2002 Light Weight Java Game Library Project + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of 'Light Weight Java Game Library' nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/** + * $Id$ + * + * Mac OS X cursor handling. + * + * @author elias_naur + * @version $Revision$ + */ + +#include "org_lwjgl_input_Cursor.h" + +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) { +} + +JNIEXPORT void JNICALL Java_org_lwjgl_input_Cursor_nDestroyCursor(JNIEnv *env, jclass clazz, jlong cursor_handle) { +} diff --git a/src/native/macosx/org_lwjgl_input_Mouse.cpp b/src/native/macosx/org_lwjgl_input_Mouse.cpp index 7e746997..35e0f693 100644 --- a/src/native/macosx/org_lwjgl_input_Mouse.cpp +++ b/src/native/macosx/org_lwjgl_input_Mouse.cpp @@ -277,7 +277,7 @@ static bool findDevice(void) { #ifdef _DEBUG printf("Could not find matching devices\n"); #endif - return; + return false; } while (!success && (hid_device = IOIteratorNext(device_iterator)) != NULL) { kern_err = IORegistryEntryCreateCFProperties(hid_device, &dev_props, kCFAllocatorDefault, kNilOptions); @@ -301,8 +301,10 @@ static bool findDevice(void) { static void handleButton(unsigned char button_index, unsigned char state) { button_states[button_index] = state; - putEventElement(&event_queue, button_index); - putEventElement(&event_queue, state); + if (buffer_enabled) { + putEventElement(&event_queue, button_index); + putEventElement(&event_queue, state); + } } static void pollDevice() { @@ -388,13 +390,16 @@ JNIEXPORT void JNICALL Java_org_lwjgl_input_Mouse_nCreate(JNIEnv * env, jclass c return; } CGAssociateMouseAndMouseCursorPosition(FALSE); + CGDisplayHideCursor(CGMainDisplayID()); created = true; } JNIEXPORT void JNICALL Java_org_lwjgl_input_Mouse_nDestroy(JNIEnv * env, jclass clazz) { shutdownDevice(); - if (!native_cursor) + if (!native_cursor) { CGAssociateMouseAndMouseCursorPosition(TRUE); + CGDisplayShowCursor(CGMainDisplayID()); + } created = false; } diff --git a/src/native/win32/org_lwjgl_input_Cursor.cpp b/src/native/win32/org_lwjgl_input_Cursor.cpp index 9983efcb..12b6ee41 100755 --- a/src/native/win32/org_lwjgl_input_Cursor.cpp +++ b/src/native/win32/org_lwjgl_input_Cursor.cpp @@ -1,3 +1,44 @@ +/* + * Copyright (c) 2002 Light Weight Java Game Library Project + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of 'Light Weight Java Game Library' nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/** + * $Id$ + * + * win32 mouse handling. + * + * @author elias_naur + * @version $Revision$ + */ + #include #include "org_lwjgl_input_Cursor.h" #include "Window.h"