mirror of
https://github.com/shadowfacts/lwjgl2-arm64.git
synced 2026-03-17 18:54:40 +01:00
*** empty log message ***
This commit is contained in:
parent
df7a48b3ea
commit
0de7e16140
|
|
@ -10,7 +10,7 @@ NATIVE = \
|
|||
org_lwjgl_input_Keyboard.cpp \
|
||||
org_lwjgl_opengl_MacOSX.cpp \
|
||||
tools.cpp \
|
||||
# org_lwjgl_input_Mouse.cpp \
|
||||
org_lwjgl_input_Mouse.cpp \
|
||||
# org_lwjgl_input_Cursor.cpp \
|
||||
org_lwjgl_opengl_Window.cpp
|
||||
# org_lwjgl_opengl_Pbuffer.cpp
|
||||
|
|
|
|||
|
|
@ -46,5 +46,6 @@
|
|||
#include <Carbon/Carbon.h>
|
||||
extern void setQuitRequested(void);
|
||||
extern bool registerKeyboardHandler(JNIEnv* env, WindowRef win_ref);
|
||||
extern bool registerMouseHandler(JNIEnv* env, WindowRef win_ref);
|
||||
|
||||
#endif /* _LWJGL_WINDOW_H_INCLUDED_ */
|
||||
|
|
|
|||
|
|
@ -76,7 +76,6 @@ static bool hasMoreEvents(void) {
|
|||
static void copyEvent(int event_size, int event_index) {
|
||||
int output_index = event_index*event_size;
|
||||
for (int i = 0; i < event_size; i++) {
|
||||
printf("list start %d end %d\n", list_start, list_end);
|
||||
output_event_buffer[output_index] = input_event_buffer[list_start];
|
||||
list_start = (list_start + 1)%EVENT_BUFFER_SIZE;
|
||||
output_index++;
|
||||
|
|
@ -86,11 +85,6 @@ printf("list start %d end %d\n", list_start, list_end);
|
|||
static bool handleMappedKey(unsigned char mapped_code, unsigned char state) {
|
||||
unsigned char old_state = key_buf[mapped_code];
|
||||
if (old_state != state) {
|
||||
if (state == 1)
|
||||
printf("key down, %x\n", mapped_code);
|
||||
else
|
||||
printf("key up, %x\n", mapped_code);
|
||||
|
||||
key_buf[mapped_code] = state;
|
||||
if (buffer_enabled) {
|
||||
putEventElement(mapped_code);
|
||||
|
|
@ -246,20 +240,6 @@ static pascal OSStatus doKeyModifier(EventHandlerCallRef next_handler, EventRef
|
|||
return noErr;
|
||||
}
|
||||
|
||||
static bool registerHandler(JNIEnv* env, WindowRef win_ref, EventHandlerProcPtr func, UInt32 event_kind) {
|
||||
EventTypeSpec event_type;
|
||||
EventHandlerUPP handler_upp = NewEventHandlerUPP(func);
|
||||
event_type.eventClass = kEventClassKeyboard;
|
||||
event_type.eventKind = event_kind;
|
||||
OSStatus err = InstallWindowEventHandler(win_ref, handler_upp, 1, &event_type, NULL, NULL);
|
||||
DisposeEventHandlerUPP(handler_upp);
|
||||
if (noErr != err) {
|
||||
throwException(env, "Could not register window event handler");
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool registerKeyboardHandler(JNIEnv* env, WindowRef win_ref) {
|
||||
bool error = registerHandler(env, win_ref, doKeyUp, kEventRawKeyUp);
|
||||
error = error || registerHandler(env, win_ref, doKeyDown, kEventRawKeyDown);
|
||||
|
|
@ -396,8 +376,6 @@ JNIEXPORT jint JNICALL Java_org_lwjgl_input_Keyboard_nRead(JNIEnv * env, jclass
|
|||
num_events++;
|
||||
}
|
||||
unlock();
|
||||
if (num_events != 0)
|
||||
printf("num events: %d\n", num_events);
|
||||
return num_events;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,129 +1,71 @@
|
|||
/*
|
||||
* Copyright (c) 2002 Light Weight Java Game Library Project
|
||||
/*
|
||||
* 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
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
*
|
||||
* * 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
|
||||
* * 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
|
||||
* 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$
|
||||
* $Id$
|
||||
*
|
||||
* OSX mouse handling.
|
||||
* Mac OS X mouse handling.
|
||||
*
|
||||
* @author gpierce <me@gregorypierce.com>
|
||||
* @author elias_naur <elias_naur@users.sourceforge.net>
|
||||
* @version $Revision$
|
||||
*/
|
||||
|
||||
#include "Window.h"
|
||||
#include "tools.h"
|
||||
#include "org_lwjgl_input_Mouse.h"
|
||||
#include <ApplicationServices/ApplicationServices.h>
|
||||
|
||||
#define NUM_BUTTONS 2
|
||||
|
||||
|
||||
static jfieldID fid_has_wheel = NULL;
|
||||
static jfieldID fid_button_count = NULL;
|
||||
static jfieldID fid_buttons = NULL;
|
||||
static jfieldID fid_dx = NULL;
|
||||
static jfieldID fid_dy = NULL;
|
||||
static jfieldID fid_dwheel = NULL;
|
||||
|
||||
static unsigned char buttons[NUM_BUTTONS];
|
||||
|
||||
/*
|
||||
* Class: org_lwjgl_input_Mouse
|
||||
* Method: initIDs
|
||||
* Signature: ()V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_org_lwjgl_input_Mouse_initIDs
|
||||
(JNIEnv * env, jclass clazz)
|
||||
{
|
||||
if (fid_has_wheel == NULL)
|
||||
fid_has_wheel = env->GetStaticFieldID(clazz, "hasWheel", "Z");
|
||||
if (fid_button_count == NULL)
|
||||
fid_button_count = env->GetStaticFieldID(clazz, "buttonCount", "I");
|
||||
if (fid_buttons == NULL)
|
||||
fid_buttons = env->GetStaticFieldID(clazz, "buttons", "[Z");
|
||||
if (fid_dx == NULL)
|
||||
fid_dx = env->GetStaticFieldID(clazz, "dx", "I");
|
||||
if (fid_dy == NULL)
|
||||
fid_dy = env->GetStaticFieldID(clazz, "dy", "I");
|
||||
if (fid_dwheel == NULL)
|
||||
fid_dwheel = env->GetStaticFieldID(clazz, "dwheel", "I");
|
||||
bool registerMouseHandler(JNIEnv* env, WindowRef win_ref) {
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Class: org_lwjgl_input_Mouse
|
||||
* Method: nCreate
|
||||
* Signature: ()Z
|
||||
*/
|
||||
JNIEXPORT jboolean JNICALL Java_org_lwjgl_input_Mouse_nCreate
|
||||
(JNIEnv * env, jclass clazz)
|
||||
{
|
||||
env->SetStaticIntField(clazz, fid_button_count, NUM_BUTTONS);
|
||||
env->SetStaticBooleanField(clazz, fid_has_wheel, JNI_TRUE);
|
||||
|
||||
CGDisplayHideCursor( kCGDirectMainDisplay );
|
||||
CGDisplayMoveCursorToPoint( kCGDirectMainDisplay, CGPointZero );
|
||||
CGAssociateMouseAndMouseCursorPosition( FALSE );
|
||||
|
||||
return JNI_TRUE;
|
||||
JNIEXPORT void JNICALL Java_org_lwjgl_input_Mouse_initIDs(JNIEnv * env, jclass clazz) {
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: org_lwjgl_input_Mouse
|
||||
* Method: nDestroy
|
||||
* Signature: ()V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_org_lwjgl_input_Mouse_nDestroy
|
||||
(JNIEnv * env, jclass clazz)
|
||||
{
|
||||
CGAssociateMouseAndMouseCursorPosition( TRUE );
|
||||
CGDisplayShowCursor( kCGDirectMainDisplay );
|
||||
JNIEXPORT jint JNICALL Java_org_lwjgl_input_Mouse_nGetNativeCursorCaps(JNIEnv *env, jclass clazz) {
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Class: org_lwjgl_input_Mouse
|
||||
* Method: nPoll
|
||||
* Signature: ()V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_org_lwjgl_input_Mouse_nPoll
|
||||
(JNIEnv * env, jclass clazz)
|
||||
{
|
||||
|
||||
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)0);
|
||||
|
||||
jbooleanArray buttons_array = (jbooleanArray)env->GetStaticObjectField(clazz, fid_buttons);
|
||||
env->SetBooleanArrayRegion(buttons_array, 0, NUM_BUTTONS, buttons);
|
||||
JNIEXPORT void JNICALL Java_org_lwjgl_input_Mouse_nSetNativeCursor(JNIEnv *env, jclass clazz, jint cursor_handle) {
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL Java_org_lwjgl_input_Mouse_nGetMinCursorSize(JNIEnv *env, jclass clazz) {
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL Java_org_lwjgl_input_Mouse_nGetMaxCursorSize(JNIEnv *env, jclass clazz) {
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_org_lwjgl_input_Mouse_nCreate(JNIEnv * env, jclass clazz) {
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_org_lwjgl_input_Mouse_nDestroy(JNIEnv * env, jclass clazz) {
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_org_lwjgl_input_Mouse_nPoll(JNIEnv * env, jclass clazz) {
|
||||
}
|
||||
|
|
|
|||
|
|
@ -107,32 +107,14 @@ static pascal OSStatus doQuit(EventHandlerCallRef next_handler, EventRef event,
|
|||
return noErr;
|
||||
}
|
||||
|
||||
static bool registerWindowHandler(JNIEnv* env, WindowRef win_ref, EventHandlerProcPtr func, UInt32 event_kind) {
|
||||
EventTypeSpec event_type;
|
||||
OSStatus err;
|
||||
EventHandlerUPP handler_upp = NewEventHandlerUPP(func);
|
||||
event_type.eventClass = kEventClassWindow;
|
||||
event_type.eventKind = event_kind;
|
||||
err = InstallWindowEventHandler(win_ref, handler_upp, 1, &event_type, NULL, NULL);
|
||||
DisposeEventHandlerUPP(handler_upp);
|
||||
if (noErr != err) {
|
||||
throwException(env, "Could not register window event handler");
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool registerEventHandlers(JNIEnv *env) {
|
||||
bool error;
|
||||
error = registerWindowHandler(env, win_ref, doQuit, kEventWindowClose);
|
||||
error = error || registerWindowHandler(env, win_ref, doActivate, kEventWindowActivated);
|
||||
error = error || registerWindowHandler(env, win_ref, doDeactivate, kEventWindowDeactivated);
|
||||
error = error || registerWindowHandler(env, win_ref, doMiniaturized, kEventWindowCollapsed);
|
||||
error = error || registerWindowHandler(env, win_ref, doMaximize, kEventWindowExpanded);
|
||||
if (error)
|
||||
return false;
|
||||
else
|
||||
return registerKeyboardHandler(env, win_ref);
|
||||
error = registerHandler(env, win_ref, doQuit, kEventWindowClose);
|
||||
error = error || registerHandler(env, win_ref, doActivate, kEventWindowActivated);
|
||||
error = error || registerHandler(env, win_ref, doDeactivate, kEventWindowDeactivated);
|
||||
error = error || registerHandler(env, win_ref, doMiniaturized, kEventWindowCollapsed);
|
||||
error = error || registerHandler(env, win_ref, doMaximize, kEventWindowExpanded);
|
||||
return !error && registerKeyboardHandler(env, win_ref) && registerMouseHandler(env, win_ref);
|
||||
}
|
||||
|
||||
static void destroyWindow(void) {
|
||||
|
|
|
|||
|
|
@ -8,6 +8,21 @@ void throwException(JNIEnv* env, const char* msg) {
|
|||
env->ThrowNew(cls, msg);
|
||||
}
|
||||
|
||||
bool registerHandler(JNIEnv* env, WindowRef win_ref, EventHandlerProcPtr func, UInt32 event_kind) {
|
||||
EventTypeSpec event_type;
|
||||
EventHandlerUPP handler_upp = NewEventHandlerUPP(func);
|
||||
event_type.eventClass = kEventClassKeyboard;
|
||||
event_type.eventKind = event_kind;
|
||||
OSStatus err = InstallWindowEventHandler(win_ref, handler_upp, 1, &event_type, NULL, NULL);
|
||||
DisposeEventHandlerUPP(handler_upp);
|
||||
if (noErr != err) {
|
||||
throwException(env, "Could not register window event handler");
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool initLock(JNIEnv* env) {
|
||||
OSStatus err = MPCreateCriticalRegion(&critical_region);
|
||||
if (err != noErr) {
|
||||
|
|
|
|||
|
|
@ -2,11 +2,13 @@
|
|||
#define TOOLS_H
|
||||
|
||||
#include <JavaVM/jni.h>
|
||||
#include <Carbon/Carbon.h>
|
||||
|
||||
#define lock() {lockLWJGL();
|
||||
#define unlock() unlockLWJGL();}
|
||||
|
||||
extern void throwException(JNIEnv* env, const char* msg);
|
||||
extern bool registerHandler(JNIEnv* env, WindowRef win_ref, EventHandlerProcPtr func, UInt32 event_kind);
|
||||
extern bool initLock(JNIEnv* env);
|
||||
extern void destroyLock(void);
|
||||
extern void lockLWJGL(void);
|
||||
|
|
|
|||
Loading…
Reference in a new issue