*** empty log message ***

This commit is contained in:
Elias Naur 2003-10-08 10:05:34 +00:00
parent fc925baab4
commit 50b8c3941c
3 changed files with 41 additions and 68 deletions

View File

@ -1,61 +0,0 @@
/*
* 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 specific window functions.
*
* @author Scott Palmer <cfxmarvin@users.sourceforge.net>
* @version $Revision$
*/
#include "org_lwjgl_Window.h"
JNIEXPORT void JNICALL Java_org_lwjgl_Window_nSetTitle
(JNIEnv * env, jobject obj, jstring title_obj)
{
const char * title = env->GetStringUTFChars(title_obj, NULL);
//setWindowTitle(title);
env->ReleaseStringUTFChars(title_obj, title);
}
/*
* Class: org_lwjgl_Window
* Method: tick
* Signature: ()V
*/
JNIEXPORT void JNICALL Java_org_lwjgl_Window_tick
(JNIEnv *env, jobject obj)
{
//handleMessages(env, obj);
}

View File

@ -45,22 +45,34 @@
#define NUM_BUTTONS 7
static jfieldID fid_dx;
static jfieldID fid_dy;
static jfieldID fid_dwheel;
static jfieldID fid_buttons;
static unsigned char button_state[NUM_BUTTONS];
static int last_x;
static int last_y;
static int wheel_dz;
static pascal OSStatus doMouseDown(EventHandlerCallRef next_handler, EventRef event, void *user_data) {
printf("Mouse down\n");
lock();
unlock();
return eventNotHandledErr; // allow the event to propagate
}
static pascal OSStatus doMouseUp(EventHandlerCallRef next_handler, EventRef event, void *user_data) {
printf("Mouse up\n");
lock();
unlock();
return eventNotHandledErr; // allow the event to propagate
}
static pascal OSStatus doMouseWheel(EventHandlerCallRef next_handler, EventRef event, void *user_data) {
printf("Mouse wheel\n");
lock();
unlock();
return noErr;
}
@ -80,6 +92,10 @@ JNIEXPORT jint JNICALL Java_org_lwjgl_input_Mouse_nGetButtonCount(JNIEnv *, jcla
}
JNIEXPORT void JNICALL Java_org_lwjgl_input_Mouse_initIDs(JNIEnv * env, jclass clazz) {
fid_dx = env->GetStaticFieldID(clazz, "dx", "I");
fid_dy = env->GetStaticFieldID(clazz, "dy", "I");
fid_dwheel = env->GetStaticFieldID(clazz, "dwheel", "I");
fid_buttons = env->GetStaticFieldID(clazz, "buttons", "[Z");
}
JNIEXPORT jint JNICALL Java_org_lwjgl_input_Mouse_nGetNativeCursorCaps(JNIEnv *env, jclass clazz) {
@ -97,18 +113,32 @@ JNIEXPORT jint JNICALL Java_org_lwjgl_input_Mouse_nGetMaxCursorSize(JNIEnv *env,
JNIEXPORT void JNICALL Java_org_lwjgl_input_Mouse_nCreate(JNIEnv * env, jclass clazz) {
last_x = 0;
last_y = 0;
wheel_dz = 0;
CGAssociateMouseAndMouseCursorPosition(FALSE);
}
JNIEXPORT void JNICALL Java_org_lwjgl_input_Mouse_nDestroy(JNIEnv * env, jclass clazz) {
CGAssociateMouseAndMouseCursorPosition(TRUE);
}
JNIEXPORT void JNICALL Java_org_lwjgl_input_Mouse_nPoll(JNIEnv * env, jclass clazz) {
Point cursor_pos;
lock();
/*Point cursor_pos;
GetMouse(&cursor_pos);
int dx = cursor_pos.v - last_x;
int dy = cursor_pos.h - last_y;
last_x += dx;
last_y += dy;
last_y += dy;*/
CGMouseDelta dx, dy;
CGGetLastMouseDelta(&dx, &dy);
env->SetStaticIntField(clazz, fid_dx, (jint)dx);
env->SetStaticIntField(clazz, fid_dy, (jint)dy);
env->SetStaticIntField(clazz, fid_dwheel, (jint)wheel_dz);
jbooleanArray buttons_array = (jbooleanArray)env->GetStaticObjectField(clazz, fid_buttons);
env->SetBooleanArrayRegion(buttons_array, 0, NUM_BUTTONS, button_state);
wheel_dz = 0;
unlock();
/*
if (dx != 0 || dy != 0)
printf("dx %d dy %d, lx %d ly %d\n", dx, dy, last_x, last_y);
printf("dx %d dy %d, lx %d ly %d\n", dx, dy, last_x, last_y);*/
}

View File

@ -77,14 +77,14 @@ static pascal OSStatus doMiniaturized(EventHandlerCallRef next_handler, EventRef
lock();
miniaturized = true;
unlock();
return noErr;
return eventNotHandledErr;
}
static pascal OSStatus doMaximize(EventHandlerCallRef next_handler, EventRef event, void *user_data) {
lock();
miniaturized = false;
unlock();
return noErr;
return eventNotHandledErr;
}
static pascal OSStatus doActivate(EventHandlerCallRef next_handler, EventRef event, void *user_data) {
@ -92,14 +92,14 @@ static pascal OSStatus doActivate(EventHandlerCallRef next_handler, EventRef eve
miniaturized = false;
activated = true;
unlock();
return noErr;
return eventNotHandledErr;
}
static pascal OSStatus doDeactivate(EventHandlerCallRef next_handler, EventRef event, void *user_data) {
lock();
activated = false;
unlock();
return noErr;
return eventNotHandledErr;
}
static pascal OSStatus doQuit(EventHandlerCallRef next_handler, EventRef event, void *user_data) {
@ -232,6 +232,10 @@ JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Window_nCreate(JNIEnv *env, jclass
}
ShowWindow(win_ref);
SelectWindow(win_ref);
CGPoint p = {x, y};
CGWarpMouseCursorPosition(p);
CGPostMouseEvent(p, FALSE, 1, TRUE);
CGPostMouseEvent(p, FALSE, 1, FALSE);
}
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Window_nSetTitle(JNIEnv * env, jclass clazz, jstring title_obj) {