From 6b9b2d302f4abf2ebbedc0b3e124651270ed2263 Mon Sep 17 00:00:00 2001 From: Elias Naur Date: Wed, 15 Oct 2003 08:49:36 +0000 Subject: [PATCH] *** empty log message *** --- src/native/macosx/Makefile.am | 2 +- src/native/macosx/Window.h | 2 +- .../macosx/org_lwjgl_input_Controller.cpp | 56 +++++++++++++++++++ src/native/macosx/org_lwjgl_input_Mouse.cpp | 25 +++++---- src/native/macosx/org_lwjgl_opengl_Window.cpp | 2 +- 5 files changed, 73 insertions(+), 14 deletions(-) create mode 100644 src/native/macosx/org_lwjgl_input_Controller.cpp diff --git a/src/native/macosx/Makefile.am b/src/native/macosx/Makefile.am index 662033eb..61a16f3d 100644 --- a/src/native/macosx/Makefile.am +++ b/src/native/macosx/Makefile.am @@ -6,7 +6,7 @@ INCLUDES = -I../common NATIVE = \ org_lwjgl_Display.cpp \ org_lwjgl_Sys.cpp \ -# org_lwjgl_input_Controller.cpp \ + org_lwjgl_input_Controller.cpp \ org_lwjgl_input_Keyboard.cpp \ org_lwjgl_opengl_MacOSX.cpp \ tools.cpp \ diff --git a/src/native/macosx/Window.h b/src/native/macosx/Window.h index 1983c23a..0ad13ecc 100644 --- a/src/native/macosx/Window.h +++ b/src/native/macosx/Window.h @@ -47,6 +47,6 @@ extern void setQuitRequested(void); extern bool registerKeyboardHandler(JNIEnv* env, WindowRef win_ref); // extern bool registerMouseHandler(JNIEnv* env, WindowRef win_ref); - extern bool isMouseCreatedAndNotNativeCursor(void); + extern bool isMouseCreated(void); #endif /* _LWJGL_WINDOW_H_INCLUDED_ */ diff --git a/src/native/macosx/org_lwjgl_input_Controller.cpp b/src/native/macosx/org_lwjgl_input_Controller.cpp new file mode 100644 index 00000000..6ec67dc6 --- /dev/null +++ b/src/native/macosx/org_lwjgl_input_Controller.cpp @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2002 Lightweight 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 controller handling. + * + * @author Elias Naur + * @version $Revision$ + */ + +#include "org_lwjgl_input_Controller.h" +#include "common_tools.h" + +JNIEXPORT void JNICALL Java_org_lwjgl_input_Controller_initIDs(JNIEnv * env, jclass clazz) { +} + +JNIEXPORT void JNICALL Java_org_lwjgl_input_Controller_nCreate(JNIEnv *env, jclass clazz) { + throwException(env, "Controller not implemented"); +} + +JNIEXPORT void JNICALL Java_org_lwjgl_input_Controller_nDestroy(JNIEnv *env, jclass clazz) { +} + +JNIEXPORT void JNICALL Java_org_lwjgl_input_Controller_nPoll(JNIEnv * env, jclass clazz) { +} + diff --git a/src/native/macosx/org_lwjgl_input_Mouse.cpp b/src/native/macosx/org_lwjgl_input_Mouse.cpp index 35e0f693..d3e239ec 100644 --- a/src/native/macosx/org_lwjgl_input_Mouse.cpp +++ b/src/native/macosx/org_lwjgl_input_Mouse.cpp @@ -60,7 +60,7 @@ static jfieldID fid_buttons; static unsigned char button_states[NUM_BUTTONS]; /*static int last_x; static int last_y;*/ -static bool native_cursor; +//static bool native_cursor; static bool created; static bool buffer_enabled; static IOHIDDeviceInterface **device_interface; @@ -79,8 +79,8 @@ static int last_dz; static void searchDictionary(CFDictionaryRef dict); static void searchObject(CFTypeRef object); -bool isMouseCreatedAndNotNativeCursor(void) { - return created && !native_cursor; +bool isMouseCreated(void) { + return created/* && !native_cursor*/; } /*static pascal OSStatus doMouseMoved(EventHandlerCallRef next_handler, EventRef event, void *user_data) { @@ -362,19 +362,22 @@ JNIEXPORT void JNICALL Java_org_lwjgl_input_Mouse_initIDs(JNIEnv * env, jclass c } JNIEXPORT jint JNICALL Java_org_lwjgl_input_Mouse_nGetNativeCursorCaps(JNIEnv *env, jclass clazz) { + return 0; } JNIEXPORT void JNICALL Java_org_lwjgl_input_Mouse_nSetNativeCursor(JNIEnv *env, jclass clazz, jlong cursor_handle) { } JNIEXPORT jint JNICALL Java_org_lwjgl_input_Mouse_nGetMinCursorSize(JNIEnv *env, jclass clazz) { + return 16; } JNIEXPORT jint JNICALL Java_org_lwjgl_input_Mouse_nGetMaxCursorSize(JNIEnv *env, jclass clazz) { + return 16; } JNIEXPORT void JNICALL Java_org_lwjgl_input_Mouse_nCreate(JNIEnv * env, jclass clazz) { - native_cursor = false; +// native_cursor = false; buffer_enabled = false; x_axis_cookie = NULL; y_axis_cookie = NULL; @@ -396,10 +399,10 @@ JNIEXPORT void JNICALL Java_org_lwjgl_input_Mouse_nCreate(JNIEnv * env, jclass c 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; } @@ -407,17 +410,17 @@ JNIEXPORT void JNICALL Java_org_lwjgl_input_Mouse_nPoll(JNIEnv * env, jclass cla int dx, dy, dz; pollDevice(); dz = last_dz; - if (!native_cursor) { + //if (!native_cursor) { dx = last_dx; dy = -last_dy; - } else { - /* Point cursor_pos; + /*} else { + Point cursor_pos; GetMouse(&cursor_pos); dx = cursor_pos.v - last_x; dy = cursor_pos.h - last_y; last_x += dx; - last_y += dy;*/ - } + last_y += dy; + }*/ env->SetStaticIntField(clazz, fid_dx, (jint)dx); env->SetStaticIntField(clazz, fid_dy, (jint)dy); env->SetStaticIntField(clazz, fid_dwheel, (jint)dz); diff --git a/src/native/macosx/org_lwjgl_opengl_Window.cpp b/src/native/macosx/org_lwjgl_opengl_Window.cpp index 7ea68d0e..70b6e56b 100644 --- a/src/native/macosx/org_lwjgl_opengl_Window.cpp +++ b/src/native/macosx/org_lwjgl_opengl_Window.cpp @@ -99,7 +99,7 @@ static pascal OSStatus doActivate(EventHandlerCallRef next_handler, EventRef eve lock(); miniaturized = false; activated = true; - if (isMouseCreatedAndNotNativeCursor()) + if (isMouseCreated()) warpCursorToCenter(); unlock(); return eventNotHandledErr;