You can subscribe to this list here.
| 2002 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
(134) |
Sep
(52) |
Oct
(13) |
Nov
(342) |
Dec
(163) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2003 |
Jan
(44) |
Feb
(62) |
Mar
(158) |
Apr
(38) |
May
(70) |
Jun
(58) |
Jul
(104) |
Aug
(207) |
Sep
(83) |
Oct
(122) |
Nov
(23) |
Dec
(49) |
| 2004 |
Jan
(119) |
Feb
(132) |
Mar
(192) |
Apr
(140) |
May
(77) |
Jun
(74) |
Jul
(201) |
Aug
(63) |
Sep
(102) |
Oct
(70) |
Nov
(173) |
Dec
(78) |
| 2005 |
Jan
(174) |
Feb
(197) |
Mar
(105) |
Apr
(59) |
May
(77) |
Jun
(43) |
Jul
(21) |
Aug
(18) |
Sep
(47) |
Oct
(37) |
Nov
(74) |
Dec
(50) |
| 2006 |
Jan
(44) |
Feb
(19) |
Mar
(32) |
Apr
(24) |
May
(31) |
Jun
(55) |
Jul
(138) |
Aug
(28) |
Sep
(12) |
Oct
(41) |
Nov
(58) |
Dec
(24) |
| 2007 |
Jan
(28) |
Feb
(14) |
Mar
(10) |
Apr
(68) |
May
(30) |
Jun
(26) |
Jul
(18) |
Aug
(63) |
Sep
(19) |
Oct
(29) |
Nov
(20) |
Dec
(10) |
| 2008 |
Jan
(38) |
Feb
(7) |
Mar
(37) |
Apr
(120) |
May
(41) |
Jun
(36) |
Jul
(39) |
Aug
(24) |
Sep
(28) |
Oct
(30) |
Nov
(36) |
Dec
(75) |
| 2009 |
Jan
(46) |
Feb
(22) |
Mar
(50) |
Apr
(70) |
May
(134) |
Jun
(105) |
Jul
(75) |
Aug
(34) |
Sep
(38) |
Oct
(34) |
Nov
(19) |
Dec
(20) |
| 2010 |
Jan
(11) |
Feb
(20) |
Mar
(65) |
Apr
(83) |
May
(104) |
Jun
(73) |
Jul
(78) |
Aug
(57) |
Sep
(43) |
Oct
(35) |
Nov
(9) |
Dec
(4) |
| 2011 |
Jan
(21) |
Feb
(11) |
Mar
(18) |
Apr
(10) |
May
(18) |
Jun
(15) |
Jul
(48) |
Aug
(25) |
Sep
(17) |
Oct
(45) |
Nov
(15) |
Dec
(12) |
| 2012 |
Jan
(21) |
Feb
(9) |
Mar
(12) |
Apr
(9) |
May
(9) |
Jun
(5) |
Jul
(1) |
Aug
(10) |
Sep
(12) |
Oct
(1) |
Nov
(28) |
Dec
(5) |
| 2013 |
Jan
(4) |
Feb
(1) |
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2014 |
Jan
|
Feb
(1) |
Mar
(1) |
Apr
|
May
(2) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(1) |
Nov
|
Dec
|
| 2015 |
Jan
(1) |
Feb
|
Mar
|
Apr
|
May
|
Jun
(1) |
Jul
|
Aug
|
Sep
|
Oct
(2) |
Nov
|
Dec
|
| 2016 |
Jan
(2) |
Feb
(1) |
Mar
(1) |
Apr
(1) |
May
(2) |
Jun
|
Jul
(1) |
Aug
(2) |
Sep
|
Oct
|
Nov
(1) |
Dec
|
| 2017 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
(1) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| S | M | T | W | T | F | S |
|---|---|---|---|---|---|---|
|
|
|
|
1
(3) |
2
|
3
(1) |
4
|
|
5
|
6
(5) |
7
(11) |
8
(7) |
9
|
10
(3) |
11
(12) |
|
12
|
13
(2) |
14
(7) |
15
(3) |
16
(3) |
17
|
18
|
|
19
|
20
(11) |
21
(5) |
22
(12) |
23
(10) |
24
(8) |
25
(4) |
|
26
(1) |
27
|
28
(13) |
29
(1) |
30
|
31
|
|
|
From: Elias N. <eli...@us...> - 2003-10-08 07:46:55
|
Update of /cvsroot/java-game-lib/LWJGL/src/native/win32 In directory sc8-pr-cvs1:/tmp/cvs-serv7564/src/native/win32 Modified Files: org_lwjgl_input_Cursor.cpp org_lwjgl_input_Mouse.cpp Log Message: Index: org_lwjgl_input_Cursor.cpp CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/native/win32/org_lwjgl_input_Cursor.cpp =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/win32/org_lwjgl_input_Cursor.cpp,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- org_lwjgl_input_Cursor.cpp 5 Aug 2003 20:07:32 -0000 1.5 +++ org_lwjgl_input_Cursor.cpp 8 Oct 2003 07:46:50 -0000 1.6 @@ -7,7 +7,7 @@ * Method: nCreateCursor * Signature: (IIIIIIIII)I */ -JNIEXPORT jint JNICALL Java_org_lwjgl_input_Cursor_nCreateCursor +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) { int *pixels = (int *)env->GetDirectBufferAddress(image_buffer) + images_offset; @@ -104,7 +104,7 @@ * Signature: (I)V */ JNIEXPORT void JNICALL Java_org_lwjgl_input_Cursor_nDestroyCursor - (JNIEnv *env, jclass clazz, jint cursor_handle) + (JNIEnv *env, jclass clazz, jlong cursor_handle) { HCURSOR cursor = (HCURSOR)cursor_handle; DestroyCursor(cursor); Index: org_lwjgl_input_Mouse.cpp CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/native/win32/org_lwjgl_input_Mouse.cpp =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/win32/org_lwjgl_input_Mouse.cpp,v retrieving revision 1.31 retrieving revision 1.32 diff -u -d -r1.31 -r1.32 --- org_lwjgl_input_Mouse.cpp 7 Oct 2003 14:28:33 -0000 1.31 +++ org_lwjgl_input_Mouse.cpp 8 Oct 2003 07:46:50 -0000 1.32 @@ -163,7 +163,7 @@ * Signature: (I)V */ JNIEXPORT void JNICALL Java_org_lwjgl_input_Mouse_nSetNativeCursor - (JNIEnv *env, jclass clazz, jint cursor_handle) + (JNIEnv *env, jclass clazz, jlong cursor_handle) { if (cursor_handle != 0) { if (mDIDevice == NULL) |
|
From: Elias N. <eli...@us...> - 2003-10-08 07:46:55
|
Update of /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/input In directory sc8-pr-cvs1:/tmp/cvs-serv7564/src/java/org/lwjgl/input Modified Files: Cursor.java Mouse.java Log Message: Index: Cursor.java CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/java/org/lwjgl/input/Cursor.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/input/Cursor.java,v retrieving revision 1.12 retrieving revision 1.13 diff -u -d -r1.12 -r1.13 --- Cursor.java 16 Sep 2003 15:39:46 -0000 1.12 +++ Cursor.java 8 Oct 2003 07:46:50 -0000 1.13 @@ -56,7 +56,7 @@ /** * The native handle to the cursor */ - private final int nativeHandle; + private final long nativeHandle; /** * Constructs a new Cursor, with the given parameters. Mouse must have been created before you can create @@ -123,17 +123,17 @@ /** * Gets the native handle associated with the cursor object. */ - public int getHandle() { + public long getHandle() { return nativeHandle; } /** * Native method to create a native cursor */ - private static native int nCreateCursor(int width, int height, int xHotspot, int yHotspot, int numImages, IntBuffer images, int images_offset, IntBuffer delays, int delays_offset); + private static native long nCreateCursor(int width, int height, int xHotspot, int yHotspot, int numImages, IntBuffer images, int images_offset, IntBuffer delays, int delays_offset); /** * Native method to destroy a native cursor */ - private static native void nDestroyCursor(int handle); + private static native void nDestroyCursor(long handle); } Index: Mouse.java CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/java/org/lwjgl/input/Mouse.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/input/Mouse.java,v retrieving revision 1.27 retrieving revision 1.28 diff -u -d -r1.27 -r1.28 --- Mouse.java 7 Oct 2003 13:10:17 -0000 1.27 +++ Mouse.java 8 Oct 2003 07:46:50 -0000 1.28 @@ -146,7 +146,7 @@ } /** Native method to set the native cursor */ - private static native void nSetNativeCursor(int handle) throws Exception; + private static native void nSetNativeCursor(long handle) throws Exception; /** * Gets the minimum size of a native cursor. Can only be called if |
|
From: Elias N. <eli...@us...> - 2003-10-07 15:10:33
|
Update of /cvsroot/java-game-lib/LWJGL/src/native/macosx In directory sc8-pr-cvs1:/tmp/cvs-serv15601/src/native/macosx Modified Files: org_lwjgl_input_Keyboard.cpp org_lwjgl_input_Mouse.cpp org_lwjgl_opengl_Window.cpp tools.cpp tools.h Log Message: Index: org_lwjgl_input_Keyboard.cpp CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/native/macosx/org_lwjgl_input_Keyboard.cpp =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/macosx/org_lwjgl_input_Keyboard.cpp,v retrieving revision 1.12 retrieving revision 1.13 diff -u -d -r1.12 -r1.13 --- org_lwjgl_input_Keyboard.cpp 7 Oct 2003 12:12:08 -0000 1.12 +++ org_lwjgl_input_Keyboard.cpp 7 Oct 2003 15:10:23 -0000 1.13 @@ -241,9 +241,9 @@ } bool registerKeyboardHandler(JNIEnv* env, WindowRef win_ref) { - bool error = registerHandler(env, win_ref, doKeyUp, kEventRawKeyUp); - error = error || registerHandler(env, win_ref, doKeyDown, kEventRawKeyDown); - error = error || registerHandler(env, win_ref, doKeyModifier, kEventRawKeyModifiersChanged); + bool error = registerHandler(env, win_ref, doKeyUp, kEventClassKeyboard, kEventRawKeyUp); + error = error || registerHandler(env, win_ref, doKeyDown, kEventClassKeyboard, kEventRawKeyDown); + error = error || registerHandler(env, win_ref, doKeyModifier, kEventClassKeyboard, kEventRawKeyModifiersChanged); return !error; } Index: org_lwjgl_input_Mouse.cpp CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/native/macosx/org_lwjgl_input_Mouse.cpp =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/macosx/org_lwjgl_input_Mouse.cpp,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- org_lwjgl_input_Mouse.cpp 7 Oct 2003 12:12:08 -0000 1.6 +++ org_lwjgl_input_Mouse.cpp 7 Oct 2003 15:10:24 -0000 1.7 @@ -43,9 +43,52 @@ #include "tools.h" #include "org_lwjgl_input_Mouse.h" +#define NUM_BUTTONS 7 + +static unsigned char button_state[NUM_BUTTONS]; + +static pascal OSStatus doMouseDragged(EventHandlerCallRef next_handler, EventRef event, void *user_data) { +printf("Mouse dragged\n"); + return eventNotHandledErr; // allow the event to propagate +} + +static pascal OSStatus doMouseMoved(EventHandlerCallRef next_handler, EventRef event, void *user_data) { +printf("Mouse moved\n"); + return eventNotHandledErr; // allow the event to propagate +} + +static pascal OSStatus doMouseDown(EventHandlerCallRef next_handler, EventRef event, void *user_data) { +printf("Mouse down\n"); + return eventNotHandledErr; // allow the event to propagate +} + +static pascal OSStatus doMouseUp(EventHandlerCallRef next_handler, EventRef event, void *user_data) { +printf("Mouse up\n"); + return eventNotHandledErr; // allow the event to propagate +} + +static pascal OSStatus doMouseWheel(EventHandlerCallRef next_handler, EventRef event, void *user_data) { +printf("Mouse wheel\n"); + return eventNotHandledErr; // allow the event to propagate +} + bool registerMouseHandler(JNIEnv* env, WindowRef win_ref) { + bool error = registerHandler(env, win_ref, doMouseDown, kEventClassMouse, kEventMouseDown); + error = error || registerHandler(env, win_ref, doMouseUp, kEventClassMouse, kEventMouseUp); + error = error || registerHandler(env, win_ref, doMouseMoved, kEventClassMouse, kEventMouseMoved); + error = error || registerHandler(env, win_ref, doMouseDragged, kEventClassMouse, kEventMouseDragged); + error = error || registerHandler(env, win_ref, doMouseWheel, kEventClassMouse, kEventMouseWheelMoved); + return !error; } +JNIEXPORT jboolean JNICALL Java_org_lwjgl_input_Mouse_nHasWheel(JNIEnv *, jclass) { + return JNI_TRUE; +} + +JNIEXPORT jint JNICALL Java_org_lwjgl_input_Mouse_nGetButtonCount(JNIEnv *, jclass) { + return NUM_BUTTONS; +} + JNIEXPORT void JNICALL Java_org_lwjgl_input_Mouse_initIDs(JNIEnv * env, jclass clazz) { } @@ -68,4 +111,9 @@ } JNIEXPORT void JNICALL Java_org_lwjgl_input_Mouse_nPoll(JNIEnv * env, jclass clazz) { + CGMouseDelta x; + CGMouseDelta y; + CGGetLastMouseDelta(&x, &y); + if (x != 0 || y != 0) + printf("delta x %d y %d\n", x, y); } Index: org_lwjgl_opengl_Window.cpp CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/native/macosx/org_lwjgl_opengl_Window.cpp =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/macosx/org_lwjgl_opengl_Window.cpp,v retrieving revision 1.15 retrieving revision 1.16 diff -u -d -r1.15 -r1.16 --- org_lwjgl_opengl_Window.cpp 7 Oct 2003 12:12:08 -0000 1.15 +++ org_lwjgl_opengl_Window.cpp 7 Oct 2003 15:10:24 -0000 1.16 @@ -109,11 +109,11 @@ static bool registerEventHandlers(JNIEnv *env) { bool error; - 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); + error = registerHandler(env, win_ref, doQuit, kEventClassWindow, kEventWindowClose); + error = error || registerHandler(env, win_ref, doActivate, kEventClassWindow, kEventWindowActivated); + error = error || registerHandler(env, win_ref, doDeactivate, kEventClassWindow, kEventWindowDeactivated); + error = error || registerHandler(env, win_ref, doMiniaturized, kEventClassWindow, kEventWindowCollapsed); + error = error || registerHandler(env, win_ref, doMaximize, kEventClassWindow, kEventWindowExpanded); return !error && registerKeyboardHandler(env, win_ref) && registerMouseHandler(env, win_ref); } Index: tools.cpp CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/native/macosx/tools.cpp =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/macosx/tools.cpp,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- tools.cpp 7 Oct 2003 12:12:08 -0000 1.4 +++ tools.cpp 7 Oct 2003 15:10:24 -0000 1.5 @@ -8,10 +8,10 @@ env->ThrowNew(cls, msg); } -bool registerHandler(JNIEnv* env, WindowRef win_ref, EventHandlerProcPtr func, UInt32 event_kind) { +bool registerHandler(JNIEnv* env, WindowRef win_ref, EventHandlerProcPtr func, UInt32 event_class, UInt32 event_kind) { EventTypeSpec event_type; EventHandlerUPP handler_upp = NewEventHandlerUPP(func); - event_type.eventClass = kEventClassKeyboard; + event_type.eventClass = event_class; event_type.eventKind = event_kind; OSStatus err = InstallWindowEventHandler(win_ref, handler_upp, 1, &event_type, NULL, NULL); DisposeEventHandlerUPP(handler_upp); @@ -21,7 +21,6 @@ } return false; } - bool initLock(JNIEnv* env) { OSStatus err = MPCreateCriticalRegion(&critical_region); Index: tools.h CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/native/macosx/tools.h =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/macosx/tools.h,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- tools.h 7 Oct 2003 12:12:08 -0000 1.5 +++ tools.h 7 Oct 2003 15:10:24 -0000 1.6 @@ -8,7 +8,7 @@ #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 registerHandler(JNIEnv* env, WindowRef win_ref, EventHandlerProcPtr func, UInt32 event_class, UInt32 event_kind); extern bool initLock(JNIEnv* env); extern void destroyLock(void); extern void lockLWJGL(void); |
|
From: Elias N. <eli...@us...> - 2003-10-07 14:28:38
|
Update of /cvsroot/java-game-lib/LWJGL/src/native/win32 In directory sc8-pr-cvs1:/tmp/cvs-serv6722/src/native/win32 Modified Files: org_lwjgl_input_Mouse.cpp Log Message: Index: org_lwjgl_input_Mouse.cpp CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/native/win32/org_lwjgl_input_Mouse.cpp =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/win32/org_lwjgl_input_Mouse.cpp,v retrieving revision 1.30 retrieving revision 1.31 diff -u -d -r1.30 -r1.31 --- org_lwjgl_input_Mouse.cpp 7 Oct 2003 13:09:59 -0000 1.30 +++ org_lwjgl_input_Mouse.cpp 7 Oct 2003 14:28:33 -0000 1.31 @@ -97,11 +97,11 @@ } JNIEXPORT jboolean JNICALL Java_org_lwjgl_input_Mouse_nHasWheel(JNIEnv *, jclass) { - return mHasWheel; + return mHaswheel; } JNIEXPORT jint JNICALL Java_org_lwjgl_input_Mouse_nGetButtonCount(JNIEnv *, jclass) { - return mButtonCount + return mButtoncount; } /** |
|
From: Elias N. <eli...@us...> - 2003-10-07 13:10:21
|
Update of /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/input In directory sc8-pr-cvs1:/tmp/cvs-serv24871/src/java/org/lwjgl/input Modified Files: Mouse.java Log Message: Index: Mouse.java CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/java/org/lwjgl/input/Mouse.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/input/Mouse.java,v retrieving revision 1.26 retrieving revision 1.27 diff -u -d -r1.26 -r1.27 --- Mouse.java 30 Sep 2003 10:52:05 -0000 1.26 +++ Mouse.java 7 Oct 2003 13:10:17 -0000 1.27 @@ -211,12 +211,18 @@ return; } nCreate(); + hasWheel = nHasWheel(); created = true; currentCursor = null; // set mouse buttons + buttonCount = nGetButtonCount(); buttons = new boolean[buttonCount]; } + + private static native boolean nHasWheel(); + + private static native int nGetButtonCount(); /** * Native method to create the mouse. |
|
From: Elias N. <eli...@us...> - 2003-10-07 13:10:03
|
Update of /cvsroot/java-game-lib/LWJGL/src/native/common In directory sc8-pr-cvs1:/tmp/cvs-serv24751/common Modified Files: org_lwjgl_input_Mouse.h Log Message: Index: org_lwjgl_input_Mouse.h CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/native/common/org_lwjgl_input_Mouse.h =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/common/org_lwjgl_input_Mouse.h,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- org_lwjgl_input_Mouse.h 30 Sep 2003 10:52:05 -0000 1.7 +++ org_lwjgl_input_Mouse.h 7 Oct 2003 13:09:59 -0000 1.8 @@ -68,6 +68,22 @@ /* * Class: org_lwjgl_input_Mouse + * Method: nHasWheel + * Signature: ()Z + */ +JNIEXPORT jboolean JNICALL Java_org_lwjgl_input_Mouse_nHasWheel + (JNIEnv *, jclass); + +/* + * Class: org_lwjgl_input_Mouse + * Method: nGetButtonCount + * Signature: ()I + */ +JNIEXPORT jint JNICALL Java_org_lwjgl_input_Mouse_nGetButtonCount + (JNIEnv *, jclass); + +/* + * Class: org_lwjgl_input_Mouse * Method: nCreate * Signature: ()V */ |
|
From: Elias N. <eli...@us...> - 2003-10-07 13:10:03
|
Update of /cvsroot/java-game-lib/LWJGL/src/native/win32 In directory sc8-pr-cvs1:/tmp/cvs-serv24751/win32 Modified Files: org_lwjgl_input_Mouse.cpp Log Message: Index: org_lwjgl_input_Mouse.cpp CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/native/win32/org_lwjgl_input_Mouse.cpp =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/win32/org_lwjgl_input_Mouse.cpp,v retrieving revision 1.29 retrieving revision 1.30 diff -u -d -r1.29 -r1.30 --- org_lwjgl_input_Mouse.cpp 30 Sep 2003 11:52:32 -0000 1.29 +++ org_lwjgl_input_Mouse.cpp 7 Oct 2003 13:09:59 -0000 1.30 @@ -56,12 +56,10 @@ // Cached fields of Mouse.java static jclass clsMouse; -static jfieldID fidMButtonCount; static jfieldID fidMButtons; static jfieldID fidMDX; static jfieldID fidMDY; static jfieldID fidMDWheel; -static jfieldID fidMHasWheel; static POINT cursorPos; static RECT windowRect; @@ -76,7 +74,6 @@ void InitializeMouseFields(); void CacheMouseFields(); void UpdateMouseFields(); -void SetMouseCapabilities(); static void getScreenClientRect(RECT* clientRect, RECT* windowRect) { @@ -99,6 +96,14 @@ CacheMouseFields(); } +JNIEXPORT jboolean JNICALL Java_org_lwjgl_input_Mouse_nHasWheel(JNIEnv *, jclass) { + return mHasWheel; +} + +JNIEXPORT jint JNICALL Java_org_lwjgl_input_Mouse_nGetButtonCount(JNIEnv *, jclass) { + return mButtonCount +} + /** * Called when the Mouse instance is to be created */ @@ -126,9 +131,6 @@ } /* Do setup of Mouse */ SetupMouse(); - - /* Set capabilities */ - SetMouseCapabilities(); } else { if(mCreate_success) { /* Do setup of Mouse */ @@ -432,22 +434,9 @@ } /** - * Sets the capabilities of the Mouse - */ -void SetMouseCapabilities() { - //set buttoncount - mEnvironment->SetStaticIntField(clsMouse, fidMButtonCount, mButtoncount); - - //set wheel - mEnvironment->SetStaticBooleanField(clsMouse, fidMHasWheel, mHaswheel); -} - -/** * Caches the field ids for quicker access */ void CacheMouseFields() { - fidMButtonCount = mEnvironment->GetStaticFieldID(clsMouse, "buttonCount", "I"); - fidMHasWheel = mEnvironment->GetStaticFieldID(clsMouse, "hasWheel", "Z"); fidMButtons = mEnvironment->GetStaticFieldID(clsMouse, "buttons", "[Z"); fidMDX = mEnvironment->GetStaticFieldID(clsMouse, "dx", "I"); fidMDY = mEnvironment->GetStaticFieldID(clsMouse, "dy", "I"); |
|
From: Elias N. <eli...@us...> - 2003-10-07 13:10:03
|
Update of /cvsroot/java-game-lib/LWJGL/src/native/linux In directory sc8-pr-cvs1:/tmp/cvs-serv24751/linux Modified Files: org_lwjgl_input_Mouse.cpp Log Message: Index: org_lwjgl_input_Mouse.cpp CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/native/linux/org_lwjgl_input_Mouse.cpp =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/linux/org_lwjgl_input_Mouse.cpp,v retrieving revision 1.33 retrieving revision 1.34 diff -u -d -r1.33 -r1.34 --- org_lwjgl_input_Mouse.cpp 30 Sep 2003 11:14:06 -0000 1.33 +++ org_lwjgl_input_Mouse.cpp 7 Oct 2003 13:09:59 -0000 1.34 @@ -61,8 +61,6 @@ static bool should_grab = false; static bool native_cursor = false; -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; @@ -102,10 +100,6 @@ 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) @@ -260,6 +254,14 @@ return width_return > height_return ? height_return : width_return; } +JNIEXPORT jboolean JNICALL Java_org_lwjgl_input_Mouse_nHasWheel(JNIEnv *, jclass) { + return JNI_TRUE; +} + +JNIEXPORT jint JNICALL Java_org_lwjgl_input_Mouse_nGetButtonCount(JNIEnv *, jclass) { + return NUM_BUTTONS; +} + /* * Class: org_lwjgl_input_Mouse * Method: nCreate @@ -269,8 +271,6 @@ (JNIEnv * env, jclass clazz) { int i; - env->SetStaticIntField(clazz, fid_button_count, NUM_BUTTONS); - env->SetStaticBooleanField(clazz, fid_has_wheel, JNI_TRUE); setCursorPos(0, 0); current_z = last_x = last_y = last_z = 0; for (i = 0; i < NUM_BUTTONS; i++) |
Update of /cvsroot/java-game-lib/LWJGL/src/native/macosx In directory sc8-pr-cvs1:/tmp/cvs-serv15119/macosx Modified Files: Makefile.am Window.h org_lwjgl_input_Keyboard.cpp org_lwjgl_input_Mouse.cpp org_lwjgl_opengl_Window.cpp tools.cpp tools.h Log Message: Index: Makefile.am CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/native/macosx/Makefile.am =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/macosx/Makefile.am,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- Makefile.am 6 Oct 2003 14:00:41 -0000 1.8 +++ Makefile.am 7 Oct 2003 12:12:08 -0000 1.9 @@ -10,7 +10,7 @@ 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 Index: Window.h CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/native/macosx/Window.h =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/macosx/Window.h,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- Window.h 6 Oct 2003 14:00:42 -0000 1.2 +++ Window.h 7 Oct 2003 12:12:08 -0000 1.3 @@ -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_ */ Index: org_lwjgl_input_Keyboard.cpp CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/native/macosx/org_lwjgl_input_Keyboard.cpp =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/macosx/org_lwjgl_input_Keyboard.cpp,v retrieving revision 1.11 retrieving revision 1.12 diff -u -d -r1.11 -r1.12 --- org_lwjgl_input_Keyboard.cpp 7 Oct 2003 11:23:12 -0000 1.11 +++ org_lwjgl_input_Keyboard.cpp 7 Oct 2003 12:12:08 -0000 1.12 @@ -76,7 +76,6 @@ 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 @@ 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 @@ 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 @@ num_events++; } unlock(); -if (num_events != 0) - printf("num events: %d\n", num_events); return num_events; } Index: org_lwjgl_input_Mouse.cpp CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/native/macosx/org_lwjgl_input_Mouse.cpp =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/macosx/org_lwjgl_input_Mouse.cpp,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- org_lwjgl_input_Mouse.cpp 10 May 2003 17:20:48 -0000 1.5 +++ org_lwjgl_input_Mouse.cpp 7 Oct 2003 12:12:08 -0000 1.6 @@ -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...@gr...> + * @author elias_naur <eli...@us...> * @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]; +bool registerMouseHandler(JNIEnv* env, WindowRef win_ref) { +} -/* - * 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"); +JNIEXPORT void JNICALL Java_org_lwjgl_input_Mouse_initIDs(JNIEnv * env, jclass clazz) { } +JNIEXPORT jint JNICALL Java_org_lwjgl_input_Mouse_nGetNativeCursorCaps(JNIEnv *env, jclass clazz) { +} -/* - * 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_nSetNativeCursor(JNIEnv *env, jclass clazz, jint cursor_handle) { } -/* - * 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_nGetMinCursorSize(JNIEnv *env, jclass clazz) { } +JNIEXPORT jint JNICALL Java_org_lwjgl_input_Mouse_nGetMaxCursorSize(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) -{ +JNIEXPORT void JNICALL Java_org_lwjgl_input_Mouse_nCreate(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); +JNIEXPORT void JNICALL Java_org_lwjgl_input_Mouse_nDestroy(JNIEnv * env, jclass clazz) { +} - 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_nPoll(JNIEnv * env, jclass clazz) { } Index: org_lwjgl_opengl_Window.cpp CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/native/macosx/org_lwjgl_opengl_Window.cpp =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/macosx/org_lwjgl_opengl_Window.cpp,v retrieving revision 1.14 retrieving revision 1.15 diff -u -d -r1.14 -r1.15 --- org_lwjgl_opengl_Window.cpp 7 Oct 2003 10:04:38 -0000 1.14 +++ org_lwjgl_opengl_Window.cpp 7 Oct 2003 12:12:08 -0000 1.15 @@ -107,32 +107,14 @@ 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) { Index: tools.cpp CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/native/macosx/tools.cpp =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/macosx/tools.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- tools.cpp 7 Oct 2003 10:04:38 -0000 1.3 +++ tools.cpp 7 Oct 2003 12:12:08 -0000 1.4 @@ -8,6 +8,21 @@ 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) { Index: tools.h CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/native/macosx/tools.h =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/macosx/tools.h,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- tools.h 7 Oct 2003 10:04:38 -0000 1.4 +++ tools.h 7 Oct 2003 12:12:08 -0000 1.5 @@ -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); |
|
From: Elias N. <eli...@us...> - 2003-10-07 11:23:22
|
Update of /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/test/input In directory sc8-pr-cvs1:/tmp/cvs-serv7557/src/java/org/lwjgl/test/input Modified Files: KeyboardTest.java Log Message: Index: KeyboardTest.java CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/java/org/lwjgl/test/input/KeyboardTest.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/test/input/KeyboardTest.java,v retrieving revision 1.14 retrieving revision 1.15 diff -u -d -r1.14 -r1.15 --- KeyboardTest.java 30 Sep 2003 10:52:05 -0000 1.14 +++ KeyboardTest.java 7 Oct 2003 11:23:11 -0000 1.15 @@ -130,20 +130,18 @@ } //check keys, buffered + Keyboard.poll(); Keyboard.read(); int count = Keyboard.getNumKeyboardEvents(); while(Keyboard.next()) { System.out.println("Checking key:" + Keyboard.getKeyName(Keyboard.key)); + System.out.println("Key character: " + Keyboard.character); if(Keyboard.key == Keyboard.KEY_ESCAPE) { return; } if (Keyboard.isKeyDown(Keyboard.KEY_RIGHT)) { - position.x += 1; - } - - if (Keyboard.key == Keyboard.KEY_RIGHT) { position.x += 1; } |
|
From: Elias N. <eli...@us...> - 2003-10-07 11:23:22
|
Update of /cvsroot/java-game-lib/LWJGL/src/native/macosx In directory sc8-pr-cvs1:/tmp/cvs-serv7557/src/native/macosx Modified Files: org_lwjgl_input_Keyboard.cpp Log Message: Index: org_lwjgl_input_Keyboard.cpp CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/native/macosx/org_lwjgl_input_Keyboard.cpp =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/macosx/org_lwjgl_input_Keyboard.cpp,v retrieving revision 1.10 retrieving revision 1.11 diff -u -d -r1.10 -r1.11 --- org_lwjgl_input_Keyboard.cpp 7 Oct 2003 10:04:37 -0000 1.10 +++ org_lwjgl_input_Keyboard.cpp 7 Oct 2003 11:23:12 -0000 1.11 @@ -43,56 +43,108 @@ #include "tools.h" #include "org_lwjgl_input_Keyboard.h" -#define KEYBOARD_BUFFER_SIZE 50 +#define EVENT_BUFFER_SIZE 100 #define KEYBOARD_SIZE 256 -#define KEY_EVENT_BACKLOG 40 #define UNICODE_BUFFER_SIZE 10 static unsigned char key_buf[KEYBOARD_SIZE]; static unsigned char key_map[KEYBOARD_SIZE]; -static unsigned char input_event_buffer[KEYBOARD_SIZE*2]; -static unsigned char output_event_buffer[KEYBOARD_SIZE*2]; +static unsigned char input_event_buffer[EVENT_BUFFER_SIZE]; +static unsigned char output_event_buffer[EVENT_BUFFER_SIZE]; -static int list_start; -static int list_end; -static bool buffer_enabled; +static int list_start = 0; +static int list_end = 0; +static bool buffer_enabled = false; +static bool translation_enabled = false; -static void handleMappedKey(unsigned char mapped_code, unsigned char state) { - lock(); +static void putEventElement(unsigned char byte) { + int next_index = (list_end + 1)%EVENT_BUFFER_SIZE; + if (next_index == list_start) { +#ifdef _DEBUG + printf("Keyboard buffer overflow!\n"); +#endif + return; + } + input_event_buffer[list_end] = byte; + list_end = next_index; +} + +static bool hasMoreEvents(void) { + return list_start != list_end; +} + +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++; + } +} + +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); + putEventElement(state); + return true; + } } - unlock(); + return false; } -static void handleKey(UInt32 key_code, unsigned char state) { +static bool handleKey(UInt32 key_code, unsigned char state) { if (key_code >= KEYBOARD_SIZE) { #ifdef _DEBUG - printf("Key code too large %x\n", (unsigned int)key_code); + printf("Key code >= %d %x\n", KEYBOARD_SIZE, (unsigned int)key_code); #endif - return; + return false; } unsigned char mapped_code = key_map[key_code]; if (mapped_code == 0) { #ifdef _DEBUG printf("unknown key code: %x\n", (unsigned int)key_code); #endif - return; + return false; } - handleMappedKey(mapped_code, state); + return handleMappedKey(mapped_code, state); } -static void writeChars(int num_chars, UniChar *buffer) { - +static unsigned char getSecondByte(UniChar ch) { + return (unsigned char)(ch & 0xff); } -static OSStatus handleUnicode(EventRef event) { +static unsigned char getFirstByte(UniChar ch) { + return (unsigned char)((ch & 0xff00) >> 16); +} + +static bool writeChars(int num_chars, UniChar *buffer) { + if (num_chars == 0) + return false; + unsigned char b0 = getFirstByte(buffer[0]); + unsigned char b1 = getSecondByte(buffer[0]); + putEventElement(b0); + putEventElement(b1); + for (int i = 1; i < num_chars; i++) { + putEventElement(0); + putEventElement(0); + b0 = getFirstByte(buffer[i]); + b1 = getSecondByte(buffer[i]); + putEventElement(b0); + putEventElement(b1); + } + return true; +} + +static bool handleUnicode(EventRef event) { UniChar unicode_buffer[UNICODE_BUFFER_SIZE]; UInt32 data_size; int num_chars; @@ -101,25 +153,23 @@ #ifdef _DEBUG printf("Could not get unicode char count\n"); #endif - return eventNotHandledErr; + return false; } num_chars = data_size/sizeof(UniChar); if (num_chars >= UNICODE_BUFFER_SIZE) { #ifdef _DEBUG printf("Unicode chars could not fit in buffer\n"); #endif - return eventNotHandledErr; + return false; } err = GetEventParameter(event, kEventParamKeyUnicodes, typeUnicodeText, NULL, data_size, NULL, unicode_buffer); if (err != noErr) { #ifdef _DEBUG printf("Could not get unicode chars\n"); #endif - return eventNotHandledErr; + return false; } - if (buffer_enabled) - writeChars(num_chars, unicode_buffer); - return noErr; + return writeChars(num_chars, unicode_buffer); } static pascal OSStatus doKeyDown(EventHandlerCallRef next_handler, EventRef event, void *user_data) { @@ -131,8 +181,20 @@ #endif return eventNotHandledErr; } - handleKey(key_code, 1); - return handleUnicode(event); + lock(); + if (handleKey(key_code, 1)) { + if (translation_enabled) { + if (!handleUnicode(event)) { + putEventElement(0); + putEventElement(0); + } + } else { + putEventElement(0); + putEventElement(0); + } + } + unlock(); + return noErr; } static pascal OSStatus doKeyUp(EventHandlerCallRef next_handler, EventRef event, void *user_data) { @@ -144,14 +206,22 @@ #endif return eventNotHandledErr; } - handleKey(key_code, 0); + lock(); + if (handleKey(key_code, 0)) { + putEventElement(0); + putEventElement(0); + } + unlock(); return noErr; } static void handleModifier(UInt32 modifier_bit_mask, UInt32 modifier_bit, unsigned char key_code) { bool key_down = (modifier_bit_mask & modifier_bit) == modifier_bit; unsigned char key_state = key_down ? 1 : 0; - handleMappedKey(key_code, key_state); + if (handleMappedKey(key_code, key_state)) { + putEventElement(0); + putEventElement(0); + } } static pascal OSStatus doKeyModifier(EventHandlerCallRef next_handler, EventRef event, void *user_data) { @@ -293,9 +363,14 @@ } JNIEXPORT void JNICALL Java_org_lwjgl_input_Keyboard_nCreate(JNIEnv * env, jclass clazz) { + lock(); buffer_enabled = false; + translation_enabled = false; + list_end = 0; + list_start = 0; memset(key_buf, 0, KEYBOARD_SIZE*sizeof(unsigned char)); setupMappings(); + unlock(); } JNIEXPORT void JNICALL Java_org_lwjgl_input_Keyboard_nDestroy(JNIEnv * env, jclass clazz) { @@ -309,17 +384,33 @@ } JNIEXPORT jint JNICALL Java_org_lwjgl_input_Keyboard_nRead(JNIEnv * env, jclass clazz) { + int num_events = 0; + lock(); + int event_size; + if (translation_enabled) + event_size = 4; + else + event_size = 2; + while (hasMoreEvents()) { + copyEvent(event_size, num_events); + num_events++; + } + unlock(); +if (num_events != 0) + printf("num events: %d\n", num_events); + return num_events; } JNIEXPORT void JNICALL Java_org_lwjgl_input_Keyboard_nEnableTranslation(JNIEnv *env, jclass clazz) { + translation_enabled = true; } JNIEXPORT jint JNICALL Java_org_lwjgl_input_Keyboard_nEnableBuffer(JNIEnv * env, jclass clazz) { jfieldID fid_readBuffer = env->GetStaticFieldID(clazz, "readBuffer", "Ljava/nio/ByteBuffer;"); - jobject new_buffer = env->NewDirectByteBuffer(&output_event_buffer, KEYBOARD_BUFFER_SIZE * 2); + jobject new_buffer = env->NewDirectByteBuffer(&output_event_buffer, EVENT_BUFFER_SIZE); env->SetStaticObjectField(clazz, fid_readBuffer, new_buffer); buffer_enabled = true; - return KEYBOARD_BUFFER_SIZE; + return EVENT_BUFFER_SIZE/2; } JNIEXPORT jint JNICALL Java_org_lwjgl_input_Keyboard_nisStateKeySet(JNIEnv *env, jclass clazz, jint key) { |
|
From: Elias N. <eli...@us...> - 2003-10-07 10:04:45
|
Update of /cvsroot/java-game-lib/LWJGL/src/native/macosx In directory sc8-pr-cvs1:/tmp/cvs-serv28326/src/native/macosx Modified Files: org_lwjgl_input_Keyboard.cpp org_lwjgl_opengl_Window.cpp tools.cpp tools.h Log Message: Index: org_lwjgl_input_Keyboard.cpp CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/native/macosx/org_lwjgl_input_Keyboard.cpp =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/macosx/org_lwjgl_input_Keyboard.cpp,v retrieving revision 1.9 retrieving revision 1.10 diff -u -d -r1.9 -r1.10 --- org_lwjgl_input_Keyboard.cpp 6 Oct 2003 15:28:12 -0000 1.9 +++ org_lwjgl_input_Keyboard.cpp 7 Oct 2003 10:04:37 -0000 1.10 @@ -46,9 +46,30 @@ #define KEYBOARD_BUFFER_SIZE 50 #define KEYBOARD_SIZE 256 #define KEY_EVENT_BACKLOG 40 +#define UNICODE_BUFFER_SIZE 10 static unsigned char key_buf[KEYBOARD_SIZE]; static unsigned char key_map[KEYBOARD_SIZE]; +static unsigned char input_event_buffer[KEYBOARD_SIZE*2]; +static unsigned char output_event_buffer[KEYBOARD_SIZE*2]; + +static int list_start; +static int list_end; +static bool buffer_enabled; + +static void handleMappedKey(unsigned char mapped_code, unsigned char state) { + lock(); + 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; + + } + unlock(); +} static void handleKey(UInt32 key_code, unsigned char state) { if (key_code >= KEYBOARD_SIZE) { @@ -57,17 +78,48 @@ #endif return; } - lock(); unsigned char mapped_code = key_map[key_code]; - unsigned char old_state = key_buf[mapped_code]; - if (old_state != state) { -if (state == 1) - printf("key down, key %x\n", key_code); -else - printf("key up, key %x\n", key_code); - key_buf[mapped_code] = state; + if (mapped_code == 0) { +#ifdef _DEBUG + printf("unknown key code: %x\n", (unsigned int)key_code); +#endif + return; } - unlock(); + handleMappedKey(mapped_code, state); +} + +static void writeChars(int num_chars, UniChar *buffer) { + +} + +static OSStatus handleUnicode(EventRef event) { + UniChar unicode_buffer[UNICODE_BUFFER_SIZE]; + UInt32 data_size; + int num_chars; + OSStatus err = GetEventParameter(event, kEventParamKeyUnicodes, typeUnicodeText, NULL, 0, &data_size, NULL); + if (err != noErr) { +#ifdef _DEBUG + printf("Could not get unicode char count\n"); +#endif + return eventNotHandledErr; + } + num_chars = data_size/sizeof(UniChar); + if (num_chars >= UNICODE_BUFFER_SIZE) { +#ifdef _DEBUG + printf("Unicode chars could not fit in buffer\n"); +#endif + return eventNotHandledErr; + } + err = GetEventParameter(event, kEventParamKeyUnicodes, typeUnicodeText, NULL, data_size, NULL, unicode_buffer); + if (err != noErr) { +#ifdef _DEBUG + printf("Could not get unicode chars\n"); +#endif + return eventNotHandledErr; + } + if (buffer_enabled) + writeChars(num_chars, unicode_buffer); + return noErr; } static pascal OSStatus doKeyDown(EventHandlerCallRef next_handler, EventRef event, void *user_data) { @@ -80,7 +132,7 @@ return eventNotHandledErr; } handleKey(key_code, 1); - return noErr; + return handleUnicode(event); } static pascal OSStatus doKeyUp(EventHandlerCallRef next_handler, EventRef event, void *user_data) { @@ -99,7 +151,7 @@ static void handleModifier(UInt32 modifier_bit_mask, UInt32 modifier_bit, unsigned char key_code) { bool key_down = (modifier_bit_mask & modifier_bit) == modifier_bit; unsigned char key_state = key_down ? 1 : 0; - handleKey(key_code, key_state); + handleMappedKey(key_code, key_state); } static pascal OSStatus doKeyModifier(EventHandlerCallRef next_handler, EventRef event, void *user_data) { @@ -145,11 +197,105 @@ return !error; } +static void setupMappings(void) { + memset(key_map, 0, KEYBOARD_SIZE*sizeof(unsigned char)); + key_map[0x35] = org_lwjgl_input_Keyboard_KEY_ESCAPE; + key_map[0x12] = org_lwjgl_input_Keyboard_KEY_1; + key_map[0x13] = org_lwjgl_input_Keyboard_KEY_2; + key_map[0x14] = org_lwjgl_input_Keyboard_KEY_3; + key_map[0x15] = org_lwjgl_input_Keyboard_KEY_4; + key_map[0x17] = org_lwjgl_input_Keyboard_KEY_5; + key_map[0x16] = org_lwjgl_input_Keyboard_KEY_6; + key_map[0x1a] = org_lwjgl_input_Keyboard_KEY_7; + key_map[0x1c] = org_lwjgl_input_Keyboard_KEY_8; + key_map[0x19] = org_lwjgl_input_Keyboard_KEY_9; + key_map[0x1d] = org_lwjgl_input_Keyboard_KEY_0; + key_map[0x1b] = org_lwjgl_input_Keyboard_KEY_MINUS; + key_map[0x18] = org_lwjgl_input_Keyboard_KEY_EQUALS; + key_map[0x33] = org_lwjgl_input_Keyboard_KEY_BACK; + key_map[0x30] = org_lwjgl_input_Keyboard_KEY_TAB; + key_map[0x0c] = org_lwjgl_input_Keyboard_KEY_Q; + key_map[0x0d] = org_lwjgl_input_Keyboard_KEY_W; + key_map[0x0e] = org_lwjgl_input_Keyboard_KEY_E; + key_map[0x0f] = org_lwjgl_input_Keyboard_KEY_R; + key_map[0x11] = org_lwjgl_input_Keyboard_KEY_T; + key_map[0x10] = org_lwjgl_input_Keyboard_KEY_Y; + key_map[0x20] = org_lwjgl_input_Keyboard_KEY_U; + key_map[0x22] = org_lwjgl_input_Keyboard_KEY_I; + key_map[0x1f] = org_lwjgl_input_Keyboard_KEY_O; + key_map[0x23] = org_lwjgl_input_Keyboard_KEY_P; + key_map[0x21] = org_lwjgl_input_Keyboard_KEY_LBRACKET; + key_map[0x1e] = org_lwjgl_input_Keyboard_KEY_RBRACKET; + key_map[0x24] = org_lwjgl_input_Keyboard_KEY_RETURN; + key_map[0x00] = org_lwjgl_input_Keyboard_KEY_A; + key_map[0x01] = org_lwjgl_input_Keyboard_KEY_S; + key_map[0x02] = org_lwjgl_input_Keyboard_KEY_D; + key_map[0x03] = org_lwjgl_input_Keyboard_KEY_F; + key_map[0x05] = org_lwjgl_input_Keyboard_KEY_G; + key_map[0x04] = org_lwjgl_input_Keyboard_KEY_H; + key_map[0x26] = org_lwjgl_input_Keyboard_KEY_J; + key_map[0x28] = org_lwjgl_input_Keyboard_KEY_K; + key_map[0x25] = org_lwjgl_input_Keyboard_KEY_L; + key_map[0x29] = org_lwjgl_input_Keyboard_KEY_SEMICOLON; + key_map[0x27] = org_lwjgl_input_Keyboard_KEY_APOSTROPHE; + key_map[0x2a] = org_lwjgl_input_Keyboard_KEY_GRAVE; + key_map[0x32] = org_lwjgl_input_Keyboard_KEY_BACKSLASH; + key_map[0x06] = org_lwjgl_input_Keyboard_KEY_Z; + key_map[0x07] = org_lwjgl_input_Keyboard_KEY_X; + key_map[0x08] = org_lwjgl_input_Keyboard_KEY_C; + key_map[0x09] = org_lwjgl_input_Keyboard_KEY_V; + key_map[0x0b] = org_lwjgl_input_Keyboard_KEY_B; + key_map[0x2d] = org_lwjgl_input_Keyboard_KEY_N; + key_map[0x2e] = org_lwjgl_input_Keyboard_KEY_M; + key_map[0x2b] = org_lwjgl_input_Keyboard_KEY_COMMA; + key_map[0x2f] = org_lwjgl_input_Keyboard_KEY_PERIOD; + key_map[0x2c] = org_lwjgl_input_Keyboard_KEY_SLASH; + key_map[0x43] = org_lwjgl_input_Keyboard_KEY_MULTIPLY; + key_map[0x31] = org_lwjgl_input_Keyboard_KEY_SPACE; + key_map[0x7a] = org_lwjgl_input_Keyboard_KEY_F1; + key_map[0x78] = org_lwjgl_input_Keyboard_KEY_F2; + key_map[0x63] = org_lwjgl_input_Keyboard_KEY_F3; + key_map[0x76] = org_lwjgl_input_Keyboard_KEY_F4; + key_map[0x60] = org_lwjgl_input_Keyboard_KEY_F5; + key_map[0x61] = org_lwjgl_input_Keyboard_KEY_F6; + key_map[0x62] = org_lwjgl_input_Keyboard_KEY_F7; + key_map[0x64] = org_lwjgl_input_Keyboard_KEY_F8; + key_map[0x65] = org_lwjgl_input_Keyboard_KEY_F9; + key_map[0x6d] = org_lwjgl_input_Keyboard_KEY_F10; + key_map[0x59] = org_lwjgl_input_Keyboard_KEY_NUMPAD7; + key_map[0x5b] = org_lwjgl_input_Keyboard_KEY_NUMPAD8; + key_map[0x5c] = org_lwjgl_input_Keyboard_KEY_NUMPAD9; + key_map[0x4e] = org_lwjgl_input_Keyboard_KEY_SUBTRACT; + key_map[0x56] = org_lwjgl_input_Keyboard_KEY_NUMPAD4; + key_map[0x57] = org_lwjgl_input_Keyboard_KEY_NUMPAD5; + key_map[0x58] = org_lwjgl_input_Keyboard_KEY_NUMPAD6; + key_map[0x45] = org_lwjgl_input_Keyboard_KEY_ADD; + key_map[0x53] = org_lwjgl_input_Keyboard_KEY_NUMPAD1; + key_map[0x54] = org_lwjgl_input_Keyboard_KEY_NUMPAD2; + key_map[0x55] = org_lwjgl_input_Keyboard_KEY_NUMPAD3; + key_map[0x52] = org_lwjgl_input_Keyboard_KEY_NUMPAD0; + key_map[0x41] = org_lwjgl_input_Keyboard_KEY_DECIMAL; + key_map[0x67] = org_lwjgl_input_Keyboard_KEY_F11; + key_map[0x6f] = org_lwjgl_input_Keyboard_KEY_F12; + key_map[0x51] = org_lwjgl_input_Keyboard_KEY_NUMPADEQUALS; + key_map[0x4c] = org_lwjgl_input_Keyboard_KEY_NUMPADENTER; + key_map[0x4b] = org_lwjgl_input_Keyboard_KEY_DIVIDE; + key_map[0x73] = org_lwjgl_input_Keyboard_KEY_HOME; + key_map[0x7e] = org_lwjgl_input_Keyboard_KEY_UP; + key_map[0x74] = org_lwjgl_input_Keyboard_KEY_PRIOR; + key_map[0x7b] = org_lwjgl_input_Keyboard_KEY_LEFT; + key_map[0x7c] = org_lwjgl_input_Keyboard_KEY_RIGHT; + key_map[0x7d] = org_lwjgl_input_Keyboard_KEY_DOWN; + key_map[0x79] = org_lwjgl_input_Keyboard_KEY_NEXT; +} + JNIEXPORT void JNICALL Java_org_lwjgl_input_Keyboard_initIDs(JNIEnv * env, jclass clazz) { } JNIEXPORT void JNICALL Java_org_lwjgl_input_Keyboard_nCreate(JNIEnv * env, jclass clazz) { + buffer_enabled = false; memset(key_buf, 0, KEYBOARD_SIZE*sizeof(unsigned char)); + setupMappings(); } JNIEXPORT void JNICALL Java_org_lwjgl_input_Keyboard_nDestroy(JNIEnv * env, jclass clazz) { @@ -169,6 +315,11 @@ } JNIEXPORT jint JNICALL Java_org_lwjgl_input_Keyboard_nEnableBuffer(JNIEnv * env, jclass clazz) { + jfieldID fid_readBuffer = env->GetStaticFieldID(clazz, "readBuffer", "Ljava/nio/ByteBuffer;"); + jobject new_buffer = env->NewDirectByteBuffer(&output_event_buffer, KEYBOARD_BUFFER_SIZE * 2); + env->SetStaticObjectField(clazz, fid_readBuffer, new_buffer); + buffer_enabled = true; + return KEYBOARD_BUFFER_SIZE; } JNIEXPORT jint JNICALL Java_org_lwjgl_input_Keyboard_nisStateKeySet(JNIEnv *env, jclass clazz, jint key) { Index: org_lwjgl_opengl_Window.cpp CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/native/macosx/org_lwjgl_opengl_Window.cpp =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/macosx/org_lwjgl_opengl_Window.cpp,v retrieving revision 1.13 retrieving revision 1.14 diff -u -d -r1.13 -r1.14 --- org_lwjgl_opengl_Window.cpp 6 Oct 2003 15:28:12 -0000 1.13 +++ org_lwjgl_opengl_Window.cpp 7 Oct 2003 10:04:38 -0000 1.14 @@ -188,8 +188,9 @@ } JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_Window_nIsCloseRequested(JNIEnv *, jclass) { + bool saved; lock(); - const bool saved = close_requested; + saved = close_requested; close_requested = false; unlock(); return saved; @@ -273,8 +274,9 @@ } JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_Window_nIsFocused(JNIEnv *env, jclass clazz) { + bool result; lock(); - bool result = activated; + result = activated; unlock(); return result; } @@ -284,8 +286,9 @@ } JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_Window_nIsMinimized(JNIEnv *env, jclass clazz) { + bool result; lock(); - bool result = miniaturized; + result = miniaturized; unlock(); return result; } Index: tools.cpp CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/native/macosx/tools.cpp =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/macosx/tools.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- tools.cpp 6 Oct 2003 14:00:44 -0000 1.2 +++ tools.cpp 7 Oct 2003 10:04:38 -0000 1.3 @@ -26,7 +26,7 @@ } } -void lock(void) { +void lockLWJGL(void) { OSStatus err = MPEnterCriticalRegion(critical_region, kDurationForever); if (err != noErr) { #ifdef _DEBUG @@ -35,7 +35,7 @@ } } -void unlock(void) { +void unlockLWJGL(void) { OSStatus err = MPExitCriticalRegion(critical_region); if (err != noErr) { #ifdef _DEBUG Index: tools.h CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/native/macosx/tools.h =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/macosx/tools.h,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- tools.h 6 Oct 2003 14:00:44 -0000 1.3 +++ tools.h 7 Oct 2003 10:04:38 -0000 1.4 @@ -3,10 +3,13 @@ #include <JavaVM/jni.h> +#define lock() {lockLWJGL(); +#define unlock() unlockLWJGL();} + extern void throwException(JNIEnv* env, const char* msg); extern bool initLock(JNIEnv* env); extern void destroyLock(void); -extern void lock(void); -extern void unlock(void); +extern void lockLWJGL(void); +extern void unlockLWJGL(void); #endif |
|
From: Elias N. <eli...@us...> - 2003-10-07 10:02:55
|
Update of /cvsroot/java-game-lib/LWJGL/src/native/linux In directory sc8-pr-cvs1:/tmp/cvs-serv27961/linux Modified Files: org_lwjgl_input_Keyboard.cpp Log Message: Index: org_lwjgl_input_Keyboard.cpp CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/native/linux/org_lwjgl_input_Keyboard.cpp =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/linux/org_lwjgl_input_Keyboard.cpp,v retrieving revision 1.27 retrieving revision 1.28 diff -u -d -r1.27 -r1.28 --- org_lwjgl_input_Keyboard.cpp 30 Sep 2003 11:14:06 -0000 1.27 +++ org_lwjgl_input_Keyboard.cpp 7 Oct 2003 10:02:40 -0000 1.28 @@ -161,6 +161,8 @@ translation_enabled = false; buffer_enabled = false; should_grab = true; + list_start = 0; + list_end = 0; updateGrab(); } |
|
From: Elias N. <eli...@us...> - 2003-10-06 15:28:17
|
Update of /cvsroot/java-game-lib/LWJGL/src/native/macosx In directory sc8-pr-cvs1:/tmp/cvs-serv23467/src/native/macosx Modified Files: org_lwjgl_input_Keyboard.cpp org_lwjgl_opengl_Window.cpp Log Message: Index: org_lwjgl_input_Keyboard.cpp CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/native/macosx/org_lwjgl_input_Keyboard.cpp =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/macosx/org_lwjgl_input_Keyboard.cpp,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- org_lwjgl_input_Keyboard.cpp 6 Oct 2003 14:00:43 -0000 1.8 +++ org_lwjgl_input_Keyboard.cpp 6 Oct 2003 15:28:12 -0000 1.9 @@ -47,6 +47,29 @@ #define KEYBOARD_SIZE 256 #define KEY_EVENT_BACKLOG 40 +static unsigned char key_buf[KEYBOARD_SIZE]; +static unsigned char key_map[KEYBOARD_SIZE]; + +static void handleKey(UInt32 key_code, unsigned char state) { + if (key_code >= KEYBOARD_SIZE) { +#ifdef _DEBUG + printf("Key code too large %x\n", (unsigned int)key_code); +#endif + return; + } + lock(); + unsigned char mapped_code = key_map[key_code]; + unsigned char old_state = key_buf[mapped_code]; + if (old_state != state) { +if (state == 1) + printf("key down, key %x\n", key_code); +else + printf("key up, key %x\n", key_code); + key_buf[mapped_code] = state; + } + unlock(); +} + static pascal OSStatus doKeyDown(EventHandlerCallRef next_handler, EventRef event, void *user_data) { UInt32 key_code; OSStatus err = GetEventParameter(event, kEventParamKeyCode, typeUInt32, NULL, sizeof(key_code), NULL, &key_code); @@ -56,7 +79,7 @@ #endif return eventNotHandledErr; } -printf("key down, key %d\n", key_code); + handleKey(key_code, 1); return noErr; } @@ -69,109 +92,85 @@ #endif return eventNotHandledErr; } -printf("key up, key %d\n", key_code); + handleKey(key_code, 0); return noErr; } -bool registerKeyboardHandler(JNIEnv* env, WindowRef win_ref) { - EventTypeSpec event_types[1]; - EventHandlerUPP handler_upp = NewEventHandlerUPP(doKeyUp); - event_types[0].eventClass = kEventClassKeyboard; - event_types[0].eventKind = kEventRawKeyUp; - OSStatus err = InstallWindowEventHandler(win_ref, handler_upp, 1, event_types, NULL, NULL); - DisposeEventHandlerUPP(handler_upp); - if (noErr != err) { - throwException(env, "Could not register window event handler"); - return false; +static void handleModifier(UInt32 modifier_bit_mask, UInt32 modifier_bit, unsigned char key_code) { + bool key_down = (modifier_bit_mask & modifier_bit) == modifier_bit; + unsigned char key_state = key_down ? 1 : 0; + handleKey(key_code, key_state); +} + +static pascal OSStatus doKeyModifier(EventHandlerCallRef next_handler, EventRef event, void *user_data) { + UInt32 modifier_bits; + OSStatus err = GetEventParameter(event, kEventParamKeyModifiers, typeUInt32, NULL, sizeof(modifier_bits), NULL, &modifier_bits); + if (err != noErr) { +#ifdef _DEBUG + printf("Could not get event key code\n"); +#endif + return eventNotHandledErr; } - handler_upp = NewEventHandlerUPP(doKeyDown); - event_types[0].eventClass = kEventClassKeyboard; - event_types[0].eventKind = kEventRawKeyDown; - err = InstallWindowEventHandler(win_ref, handler_upp, 1, event_types, NULL, NULL); + handleModifier(modifier_bits, controlKey, 0x1d); + handleModifier(modifier_bits, rightControlKey, 0x9d); + handleModifier(modifier_bits, shiftKey, 0x2a); + handleModifier(modifier_bits, rightShiftKey, 0x36); + handleModifier(modifier_bits, optionKey, 0x38); + handleModifier(modifier_bits, rightOptionKey, 0xb8); + handleModifier(modifier_bits, cmdKey, 0xdb); + handleModifier(modifier_bits, alphaLock, 0x3a); + handleModifier(modifier_bits, kEventKeyModifierNumLockMask, 0x45); + //handleModifier(modifier_bits, rightCmdKey, 0xdc); + 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 false; + return true; } - return true; + return false; } -/* - * Class: org_lwjgl_input_Keyboard - * Method: initIDs - * Signature: ()V - */ -JNIEXPORT void JNICALL Java_org_lwjgl_input_Keyboard_initIDs - (JNIEnv * env, jclass clazz) -{ +bool registerKeyboardHandler(JNIEnv* env, WindowRef win_ref) { + bool error = registerHandler(env, win_ref, doKeyUp, kEventRawKeyUp); + error = error || registerHandler(env, win_ref, doKeyDown, kEventRawKeyDown); + error = error || registerHandler(env, win_ref, doKeyModifier, kEventRawKeyModifiersChanged); + return !error; } -/* - * Class: org_lwjgl_input_Keyboard - * Method: nCreate - * Signature: ()Z - */ -JNIEXPORT void JNICALL Java_org_lwjgl_input_Keyboard_nCreate - (JNIEnv * env, jclass clazz) -{ +JNIEXPORT void JNICALL Java_org_lwjgl_input_Keyboard_initIDs(JNIEnv * env, jclass clazz) { } -/* - * Class: org_lwjgl_input_Keyboard - * Method: nDestroy - * Signature: ()V - */ -JNIEXPORT void JNICALL Java_org_lwjgl_input_Keyboard_nDestroy - (JNIEnv * env, jclass clazz) -{ +JNIEXPORT void JNICALL Java_org_lwjgl_input_Keyboard_nCreate(JNIEnv * env, jclass clazz) { + memset(key_buf, 0, KEYBOARD_SIZE*sizeof(unsigned char)); } -/* - * Class: org_lwjgl_input_Keyboard - * Method: nPoll - * Signature: (I)V - */ -JNIEXPORT void JNICALL Java_org_lwjgl_input_Keyboard_nPoll - (JNIEnv * env, jclass clazz, jobject buffer) -{ +JNIEXPORT void JNICALL Java_org_lwjgl_input_Keyboard_nDestroy(JNIEnv * env, jclass clazz) { } -/* - * Class: org_lwjgl_input_Keyboard - * Method: nRead - * Signature: (I)V - */ -JNIEXPORT jint JNICALL Java_org_lwjgl_input_Keyboard_nRead - (JNIEnv * env, jclass clazz) -{ +JNIEXPORT void JNICALL Java_org_lwjgl_input_Keyboard_nPoll(JNIEnv * env, jclass clazz, jobject buffer) { + unsigned char *new_keyboard_buffer = (unsigned char *)env->GetDirectBufferAddress(buffer); + lock(); + memcpy(new_keyboard_buffer, key_buf, KEYBOARD_SIZE*sizeof(unsigned char)); + unlock(); } -/* - * Class: org_lwjgl_input_Keyboard - * Method: nEnableTranslation - * Signature: ()I - */ -JNIEXPORT void JNICALL Java_org_lwjgl_input_Keyboard_nEnableTranslation - (JNIEnv *env, jclass clazz) -{ +JNIEXPORT jint JNICALL Java_org_lwjgl_input_Keyboard_nRead(JNIEnv * env, jclass clazz) { } -/* - * Class: org_lwjgl_input_Keyboard - * Method: nEnableBuffer - * Signature: ()I - */ -JNIEXPORT jint JNICALL Java_org_lwjgl_input_Keyboard_nEnableBuffer - (JNIEnv * env, jclass clazz) -{ +JNIEXPORT void JNICALL Java_org_lwjgl_input_Keyboard_nEnableTranslation(JNIEnv *env, jclass clazz) { } -/* - * Class: org_lwjgl_input_Keyboard - * Method: nisStateKeySet - * Signature: (I)I - */ -JNIEXPORT jint JNICALL Java_org_lwjgl_input_Keyboard_nisStateKeySet(JNIEnv *env, jclass clazz, jint key) -{ - return org_lwjgl_input_Keyboard_STATE_UNKNOWN; +JNIEXPORT jint JNICALL Java_org_lwjgl_input_Keyboard_nEnableBuffer(JNIEnv * env, jclass clazz) { +} + +JNIEXPORT jint JNICALL Java_org_lwjgl_input_Keyboard_nisStateKeySet(JNIEnv *env, jclass clazz, jint key) { + return org_lwjgl_input_Keyboard_STATE_UNKNOWN; } Index: org_lwjgl_opengl_Window.cpp CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/native/macosx/org_lwjgl_opengl_Window.cpp =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/macosx/org_lwjgl_opengl_Window.cpp,v retrieving revision 1.12 retrieving revision 1.13 diff -u -d -r1.12 -r1.13 --- org_lwjgl_opengl_Window.cpp 6 Oct 2003 14:00:43 -0000 1.12 +++ org_lwjgl_opengl_Window.cpp 6 Oct 2003 15:28:12 -0000 1.13 @@ -107,7 +107,7 @@ return noErr; } -static bool registerWindowHandler(JNIEnv* env, EventHandlerProcPtr func, UInt32 event_kind) { +static bool registerWindowHandler(JNIEnv* env, WindowRef win_ref, EventHandlerProcPtr func, UInt32 event_kind) { EventTypeSpec event_type; OSStatus err; EventHandlerUPP handler_upp = NewEventHandlerUPP(func); @@ -124,11 +124,11 @@ static bool registerEventHandlers(JNIEnv *env) { bool error; - error = registerWindowHandler(env, doQuit, kEventWindowClose); - error = error || registerWindowHandler(env, doActivate, kEventWindowActivated); - error = error || registerWindowHandler(env, doDeactivate, kEventWindowDeactivated); - error = error || registerWindowHandler(env, doMiniaturized, kEventWindowCollapsed); - error = error || registerWindowHandler(env, doMaximize, kEventWindowExpanded); + 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 @@ -143,11 +143,11 @@ } static void destroy(void) { - destroyLock(); aglSetCurrentContext(NULL); aglDestroyContext(context); destroyWindow(); extgl_Close(); + destroyLock(); } static bool createContext(JNIEnv *env, jint bpp, jint alpha, jint depth, jint stencil) { |
|
From: Elias N. <eli...@us...> - 2003-10-06 14:01:17
|
Update of /cvsroot/java-game-lib/LWJGL/src/native In directory sc8-pr-cvs1:/tmp/cvs-serv6813 Modified Files: configure.in Log Message: Index: configure.in CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/native/configure.in =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/configure.in,v retrieving revision 1.44 retrieving revision 1.45 diff -u -d -r1.44 -r1.45 --- configure.in 9 Sep 2003 08:10:38 -0000 1.44 +++ configure.in 6 Oct 2003 14:00:40 -0000 1.45 @@ -30,7 +30,7 @@ case "$host_os" in darwin*) _BUILD_FLAGS="-D_AGL -fpascal-strings" - LDFLAGS="-Xlinker -framework -Xlinker Carbon -Xlinker -framework -Xlinker JavaVM" + LDFLAGS="-Xlinker -framework -Xlinker Carbon -Xlinker -framework -Xlinker QuickTime -Xlinker -framework -Xlinker JavaVM" NATIVE_BUILD_DIR=macosx CXXFLAGS="$CXXFLAGS $DEBUG_FLAGS -Wall $_BUILD_FLAGS" CFLAGS="$CFLAGS $DEBUG_FLAGS -Wall $_BUILD_FLAGS" |
|
From: Elias N. <eli...@us...> - 2003-10-06 14:00:56
|
Update of /cvsroot/java-game-lib/LWJGL/src/native/macosx In directory sc8-pr-cvs1:/tmp/cvs-serv6813/macosx Modified Files: Makefile.am Window.h org_lwjgl_input_Keyboard.cpp org_lwjgl_opengl_Window.cpp tools.cpp tools.h Log Message: Index: Makefile.am CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/native/macosx/Makefile.am =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/macosx/Makefile.am,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- Makefile.am 1 Oct 2003 09:33:22 -0000 1.7 +++ Makefile.am 6 Oct 2003 14:00:41 -0000 1.8 @@ -9,6 +9,7 @@ # org_lwjgl_input_Controller.cpp \ org_lwjgl_input_Keyboard.cpp \ org_lwjgl_opengl_MacOSX.cpp \ + tools.cpp \ # org_lwjgl_input_Mouse.cpp \ # org_lwjgl_input_Cursor.cpp \ org_lwjgl_opengl_Window.cpp Index: Window.h CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/native/macosx/Window.h =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/macosx/Window.h,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- Window.h 1 Oct 2003 09:33:22 -0000 1.1 +++ Window.h 6 Oct 2003 14:00:42 -0000 1.2 @@ -43,6 +43,8 @@ #define _LWJGL_WINDOW_H_INCLUDED_ #include <jni.h> + #include <Carbon/Carbon.h> extern void setQuitRequested(void); + extern bool registerKeyboardHandler(JNIEnv* env, WindowRef win_ref); #endif /* _LWJGL_WINDOW_H_INCLUDED_ */ Index: org_lwjgl_input_Keyboard.cpp CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/native/macosx/org_lwjgl_input_Keyboard.cpp =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/macosx/org_lwjgl_input_Keyboard.cpp,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- org_lwjgl_input_Keyboard.cpp 1 Oct 2003 09:33:22 -0000 1.7 +++ org_lwjgl_input_Keyboard.cpp 6 Oct 2003 14:00:43 -0000 1.8 @@ -39,10 +39,7 @@ * @version $Revision$ */ -#include <IOKit/IOKitLib.h> -#include <IOKit/hid/IOHIDKeys.h> -#include <CoreFoundation/CoreFoundation.h> -#include <stdlib.h> +#include "Window.h" #include "tools.h" #include "org_lwjgl_input_Keyboard.h" @@ -50,6 +47,55 @@ #define KEYBOARD_SIZE 256 #define KEY_EVENT_BACKLOG 40 +static pascal OSStatus doKeyDown(EventHandlerCallRef next_handler, EventRef event, void *user_data) { + UInt32 key_code; + OSStatus err = GetEventParameter(event, kEventParamKeyCode, typeUInt32, NULL, sizeof(key_code), NULL, &key_code); + if (err != noErr) { +#ifdef _DEBUG + printf("Could not get event key code\n"); +#endif + return eventNotHandledErr; + } +printf("key down, key %d\n", key_code); + return noErr; +} + +static pascal OSStatus doKeyUp(EventHandlerCallRef next_handler, EventRef event, void *user_data) { + UInt32 key_code; + OSStatus err = GetEventParameter(event, kEventParamKeyCode, typeUInt32, NULL, sizeof(key_code), NULL, &key_code); + if (err != noErr) { +#ifdef _DEBUG + printf("Could not get event key code\n"); +#endif + return eventNotHandledErr; + } +printf("key up, key %d\n", key_code); + return noErr; +} + +bool registerKeyboardHandler(JNIEnv* env, WindowRef win_ref) { + EventTypeSpec event_types[1]; + EventHandlerUPP handler_upp = NewEventHandlerUPP(doKeyUp); + event_types[0].eventClass = kEventClassKeyboard; + event_types[0].eventKind = kEventRawKeyUp; + OSStatus err = InstallWindowEventHandler(win_ref, handler_upp, 1, event_types, NULL, NULL); + DisposeEventHandlerUPP(handler_upp); + if (noErr != err) { + throwException(env, "Could not register window event handler"); + return false; + } + handler_upp = NewEventHandlerUPP(doKeyDown); + event_types[0].eventClass = kEventClassKeyboard; + event_types[0].eventKind = kEventRawKeyDown; + err = InstallWindowEventHandler(win_ref, handler_upp, 1, event_types, NULL, NULL); + DisposeEventHandlerUPP(handler_upp); + if (noErr != err) { + throwException(env, "Could not register window event handler"); + return false; + } + return true; +} + /* * Class: org_lwjgl_input_Keyboard * Method: initIDs @@ -60,36 +106,6 @@ { } -static void printCFString(CFStringRef str) { - CFIndex buffer_size = CFStringGetLength(str) + 1; - char * buffer = (char *)malloc(buffer_size); - if (buffer != NULL) { - if (CFStringGetCString(str, buffer, buffer_size, CFStringGetSystemEncoding())) - printf("%s", buffer); - free(buffer); - } -} - -static void printCFNumber(CFNumberRef num) { - long number; - - if (CFNumberGetValue(num, kCFNumberLongType, &number)) - printf("0x%lx (%ld)", number, number); -} - -static void printProperty(CFDictionaryRef dict, CFStringRef key) { - CFTypeRef val = CFDictionaryGetValue(dict, key); - if (val != NULL) { - CFTypeID type = CFGetTypeID(val); - if (type == CFArrayGetTypeID()) printf("array\n"); - else if (type == CFBooleanGetTypeID()) printf("boolean\n"); - else if (type == CFDictionaryGetTypeID()) printf("dictionary\n"); - else if (type == CFNumberGetTypeID()) printCFNumber((CFNumberRef)val); - else if (type == CFStringGetTypeID()) printCFString((CFStringRef)val); - else printf("<unknown object type>\n"); - } -} - /* * Class: org_lwjgl_input_Keyboard * Method: nCreate @@ -98,31 +114,6 @@ JNIEXPORT void JNICALL Java_org_lwjgl_input_Keyboard_nCreate (JNIEnv * env, jclass clazz) { - io_iterator_t device_iterator; - io_object_t hid_device; - kern_return_t kern_err; - CFMutableDictionaryRef dev_props; - CFMutableDictionaryRef matching_dic = IOServiceMatching(kIOHIDDeviceKey); - IOReturn err = IOServiceGetMatchingServices(kIOMasterPortDefault, matching_dic, &device_iterator); - if (err != kIOReturnSuccess) { - throwException(env, "Could not find matching devices"); - return; - } - while ((hid_device = IOIteratorNext(device_iterator)) != NULL) { - kern_err = IORegistryEntryCreateCFProperties(hid_device, &dev_props, kCFAllocatorDefault, kNilOptions); - IOObjectRelease(hid_device); - if (kern_err == KERN_SUCCESS && dev_props != NULL) { - printf("Device found: "); - printProperty(dev_props, CFSTR(kIOHIDProductKey)); - printf(" usage "); - printProperty(dev_props, CFSTR(kIOHIDPrimaryUsageKey)); - printf(" usage page "); - printProperty(dev_props, CFSTR(kIOHIDPrimaryUsagePageKey)); - printf("\n"); - CFRelease(dev_props); - } - } - IOObjectRelease(device_iterator); } /* Index: org_lwjgl_opengl_Window.cpp CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/native/macosx/org_lwjgl_opengl_Window.cpp =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/macosx/org_lwjgl_opengl_Window.cpp,v retrieving revision 1.11 retrieving revision 1.12 diff -u -d -r1.11 -r1.12 --- org_lwjgl_opengl_Window.cpp 1 Oct 2003 09:33:22 -0000 1.11 +++ org_lwjgl_opengl_Window.cpp 6 Oct 2003 14:00:43 -0000 1.12 @@ -39,7 +39,8 @@ * @version $Revision$ */ -#include <Carbon/Carbon.h> +#include "Window.h" +#include <QuickTime/Movies.h> #include "org_lwjgl_opengl_Window.h" #include "extgl.h" #include "tools.h" @@ -47,6 +48,10 @@ static WindowRef win_ref; static AGLContext context; static bool close_requested; +static Ptr fullscreen_ptr; +static bool current_fullscreen; +static bool miniaturized; +static bool activated; static void setWindowTitle(JNIEnv *env, jstring title_obj) { const char* title = env->GetStringUTFChars(title_obj, NULL); @@ -63,7 +68,38 @@ } void setQuitRequested(void) { + lock(); close_requested = true; + unlock(); +} + +static pascal OSStatus doMiniaturized(EventHandlerCallRef next_handler, EventRef event, void *user_data) { + lock(); + miniaturized = true; + unlock(); + return noErr; +} + +static pascal OSStatus doMaximize(EventHandlerCallRef next_handler, EventRef event, void *user_data) { + lock(); + miniaturized = false; + unlock(); + return noErr; +} + +static pascal OSStatus doActivate(EventHandlerCallRef next_handler, EventRef event, void *user_data) { + lock(); + miniaturized = false; + activated = true; + unlock(); + return noErr; +} + +static pascal OSStatus doDeactivate(EventHandlerCallRef next_handler, EventRef event, void *user_data) { + lock(); + activated = false; + unlock(); + return noErr; } static pascal OSStatus doQuit(EventHandlerCallRef next_handler, EventRef event, void *user_data) { @@ -71,24 +107,46 @@ return noErr; } -static void registerEventHandlers(JNIEnv *env) { - EventTypeSpec event_types[2]; +static bool registerWindowHandler(JNIEnv* env, EventHandlerProcPtr func, UInt32 event_kind) { + EventTypeSpec event_type; OSStatus err; - EventHandlerUPP handler_upp = NewEventHandlerUPP(doQuit); - event_types[0].eventClass = kEventClassWindow; - event_types[0].eventKind = kEventWindowClose; - err = InstallWindowEventHandler(win_ref, handler_upp, 1, event_types, NULL, NULL); + 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; + return true; } + return false; +} + +static bool registerEventHandlers(JNIEnv *env) { + bool error; + error = registerWindowHandler(env, doQuit, kEventWindowClose); + error = error || registerWindowHandler(env, doActivate, kEventWindowActivated); + error = error || registerWindowHandler(env, doDeactivate, kEventWindowDeactivated); + error = error || registerWindowHandler(env, doMiniaturized, kEventWindowCollapsed); + error = error || registerWindowHandler(env, doMaximize, kEventWindowExpanded); + if (error) + return false; + else + return registerKeyboardHandler(env, win_ref); +} + +static void destroyWindow(void) { + if (current_fullscreen) + EndFullScreen(fullscreen_ptr, 0); + else + DisposeWindow(win_ref); } static void destroy(void) { + destroyLock(); aglSetCurrentContext(NULL); aglDestroyContext(context); - DisposeWindow(win_ref); + destroyWindow(); extgl_Close(); } @@ -98,7 +156,6 @@ GLint attrib[] = {AGL_RGBA, AGL_DOUBLEBUFFER, AGL_ACCELERATED, - //AGL_FULLSCREEN, AGL_NO_RECOVERY, AGL_MINIMUM_POLICY, AGL_PIXEL_SIZE, bpp, @@ -131,8 +188,10 @@ } JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_Window_nIsCloseRequested(JNIEnv *, jclass) { + lock(); const bool saved = close_requested; close_requested = false; + unlock(); return saved; } @@ -143,6 +202,9 @@ kWindowCollapseBoxAttribute| kWindowStandardHandlerAttribute; SetRect(&rect, x, y, x + width, y + height); + current_fullscreen = fullscreen == JNI_TRUE; + miniaturized = false; + activated = true; close_requested = false; if (!extgl_Open()) { throwException(env, "Could not load gl library"); @@ -152,17 +214,31 @@ throwException(env, "Could not load agl symbols"); return; } - status = CreateNewWindow(kDocumentWindowClass, window_attr, &rect, &win_ref); + if (current_fullscreen) + status = BeginFullScreen(&fullscreen_ptr, NULL, 0, 0, &win_ref, NULL, 0); + else + status = CreateNewWindow(kDocumentWindowClass, window_attr, &rect, &win_ref); if (noErr != status) { + extgl_Close(); throwException(env, "Could not create window"); return; } - registerEventHandlers(env); + if (!registerEventHandlers(env)) { + destroyWindow(); + extgl_Close(); + return; + } + if (!initLock(env)) { + destroyWindow(); + extgl_Close(); + return; + } setWindowTitle(env, title); - const RGBColor background_color = { 0, 0, 0 }; + const RGBColor background_color = {0, 0, 0}; SetWindowContentColor(win_ref, &background_color); if (!createContext(env, bpp, alpha, depth, stencil)) { - DisposeWindow(win_ref); + destroyLock(); + destroyWindow(); extgl_Close(); return; } @@ -175,19 +251,41 @@ SelectWindow(win_ref); } -JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Window_update - (JNIEnv *env, jclass clazz) -{ +JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Window_nSetTitle(JNIEnv * env, jclass clazz, jstring title_obj) { + setWindowTitle(env, title_obj); } -JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Window_swapBuffers(JNIEnv * env, jclass clazz) -{ +JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Window_update(JNIEnv *env, jclass clazz) { +} + +JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Window_swapBuffers(JNIEnv * env, jclass clazz) { aglSwapBuffers(context); } +JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Window_minimize(JNIEnv *env, jclass clazz) { +} -JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Window_nDestroy - (JNIEnv *env, jclass clazz) -{ +JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Window_restore(JNIEnv *env, jclass clazz) { +} + +JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Window_nDestroy(JNIEnv *env, jclass clazz) { destroy(); +} + +JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_Window_nIsFocused(JNIEnv *env, jclass clazz) { + lock(); + bool result = activated; + unlock(); + return result; +} + +JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_Window_nIsDirty(JNIEnv *env, jclass clazz) { + return JNI_FALSE; +} + +JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_Window_nIsMinimized(JNIEnv *env, jclass clazz) { + lock(); + bool result = miniaturized; + unlock(); + return result; } Index: tools.cpp CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/native/macosx/tools.cpp =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/macosx/tools.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- tools.cpp 1 Oct 2003 09:02:52 -0000 1.1 +++ tools.cpp 6 Oct 2003 14:00:44 -0000 1.2 @@ -1,7 +1,45 @@ #include "tools.h" +#include <CoreServices/CoreServices.h> + +MPCriticalRegionID critical_region; void throwException(JNIEnv* env, const char* msg) { jclass cls = env->FindClass("java/lang/Exception"); - env->ThrowNew(cls, err); - env->DeleteLocalRef(cls); + env->ThrowNew(cls, msg); +} + +bool initLock(JNIEnv* env) { + OSStatus err = MPCreateCriticalRegion(&critical_region); + if (err != noErr) { + throwException(env, "Could not init lock"); + return false; + } + return true; +} + +void destroyLock(void) { + OSStatus err = MPDeleteCriticalRegion(critical_region); + if (err != noErr) { +#ifdef _DEBUG + printf("Could not delete lock\n"); +#endif + } +} + +void lock(void) { + OSStatus err = MPEnterCriticalRegion(critical_region, kDurationForever); + if (err != noErr) { +#ifdef _DEBUG + printf("Could not lock\n"); +#endif + } +} + +void unlock(void) { + OSStatus err = MPExitCriticalRegion(critical_region); + if (err != noErr) { +#ifdef _DEBUG + printf("Could not unlock\n"); +#endif + } } Index: tools.h CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/native/macosx/tools.h =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/macosx/tools.h,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- tools.h 1 Oct 2003 09:33:22 -0000 1.2 +++ tools.h 6 Oct 2003 14:00:44 -0000 1.3 @@ -4,5 +4,9 @@ #include <JavaVM/jni.h> extern void throwException(JNIEnv* env, const char* msg); +extern bool initLock(JNIEnv* env); +extern void destroyLock(void); +extern void lock(void); +extern void unlock(void); #endif |
|
From: Elias N. <eli...@us...> - 2003-10-06 08:34:10
|
Update of /cvsroot/java-game-lib/LWJGL/src/native/win32 In directory sc8-pr-cvs1:/tmp/cvs-serv21612/win32 Modified Files: org_lwjgl_opengl_Window.cpp Log Message: Index: org_lwjgl_opengl_Window.cpp CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/native/win32/org_lwjgl_opengl_Window.cpp =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/win32/org_lwjgl_opengl_Window.cpp,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- org_lwjgl_opengl_Window.cpp 26 Sep 2003 16:26:10 -0000 1.8 +++ org_lwjgl_opengl_Window.cpp 6 Oct 2003 08:34:03 -0000 1.9 @@ -43,15 +43,13 @@ #include "Window.h" #include "org_lwjgl_opengl_Window.h" -bool oneShotInitialised = false; // Registers the LWJGL window class +static bool oneShotInitialised = false; // Registers the LWJGL window class HWND hwnd = NULL; // Handle to the window HDC hdc = NULL; // Device context HGLRC hglrc = NULL; // OpenGL context LPDIRECTINPUT lpdi = NULL; // DirectInput -bool isFullScreen = false; // Whether we're fullscreen or not -bool isMinimized = false; // Whether we're minimized or not -/*JNIEnv * environment = NULL; // Cached environment -jclass window; // Cached Java Window class*/ +static bool isFullScreen = false; // Whether we're fullscreen or not +static bool isMinimized = false; // Whether we're minimized or not extern HINSTANCE dll_handle; // Handle to the LWJGL dll RECT clientSize; @@ -613,8 +611,10 @@ * Signature: ()Z */ JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_Window_nIsDirty - (JNIEnv *env, jclass clazz) { - return dirty; + (JNIEnv *env, jclass clazz) { + bool result = dirty; + dirty = false; + return result; } /* |
|
From: Elias N. <eli...@us...> - 2003-10-06 08:13:28
|
Update of /cvsroot/java-game-lib/LWJGL/src/native/linux In directory sc8-pr-cvs1:/tmp/cvs-serv18930/linux Modified Files: org_lwjgl_opengl_Window.cpp Log Message: Index: org_lwjgl_opengl_Window.cpp CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/native/linux/org_lwjgl_opengl_Window.cpp =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/linux/org_lwjgl_opengl_Window.cpp,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- org_lwjgl_opengl_Window.cpp 26 Sep 2003 13:59:50 -0000 1.7 +++ org_lwjgl_opengl_Window.cpp 6 Oct 2003 08:13:18 -0000 1.8 @@ -542,7 +542,9 @@ */ JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_Window_nIsDirty (JNIEnv *env, jclass clazz) { - return dirty; + bool result = dirty; + dirty = false; + return result; } /* |
|
From: Elias N. <eli...@us...> - 2003-10-03 14:33:37
|
Update of /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/test/opengl In directory sc8-pr-cvs1:/tmp/cvs-serv28903/src/java/org/lwjgl/test/opengl Modified Files: PbufferTest.java Log Message: Index: PbufferTest.java CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/java/org/lwjgl/test/opengl/PbufferTest.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/test/opengl/PbufferTest.java,v retrieving revision 1.17 retrieving revision 1.18 diff -u -d -r1.17 -r1.18 --- PbufferTest.java 26 Sep 2003 13:59:49 -0000 1.17 +++ PbufferTest.java 3 Oct 2003 14:33:27 -0000 1.18 @@ -202,7 +202,7 @@ GL.glEnd(); } GL.glPopMatrix(); - GL.glCopyTexImage2D(GL.GL_TEXTURE_2D, 0, GL.GL_RGB, 0, 0, 256, 256, 0); + GL.glCopyTexImage2D(GL.GL_TEXTURE_2D, 0, GL.GL_RGB, 0, 0, 512, 512, 0); Pbuffer.releaseContext(); // OpenGL window rendering @@ -231,7 +231,7 @@ private void initPbuffer() { try { - pbuffer = new Pbuffer(256, 256, mode.bpp, 0, 0, 0); + pbuffer = new Pbuffer(512, 512, mode.bpp, 0, 0, 0); pbuffer.makeCurrent(); initGLState(256, 256, 0.5f); GL.glBindTexture(GL.GL_TEXTURE_2D, tex_handle); |
|
From: Elias N. <eli...@us...> - 2003-10-01 09:33:28
|
Update of /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/opengl In directory sc8-pr-cvs1:/tmp/cvs-serv28625/src/java/org/lwjgl/opengl Modified Files: Window.java Added Files: MacOSX.java Log Message: Loading Mac OS X hack through reflection --- NEW FILE: MacOSX.java --- CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/java/org/lwjgl/opengl/MacOSX.java /* * 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. */ package org.lwjgl.opengl; /** * $Id: MacOSX.java,v 1.1 2003/10/01 09:33:22 elias_naur Exp $ * * Mac OS X specific hacks * * @author elias_naur <eli...@us...> * @version $Revision: 1.1 $ */ class MacOSX { public static void initMacOSX() { java.awt.Toolkit.getDefaultToolkit(); new com.apple.eawt.Application().addApplicationListener(new com.apple.eawt.ApplicationAdapter() { public void handleQuit(com.apple.eawt.ApplicationEvent e) { e.setHandled(false); setQuitRequested(); } }); } private static native void setQuitRequested(); } Index: Window.java CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/java/org/lwjgl/opengl/Window.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/opengl/Window.java,v retrieving revision 1.12 retrieving revision 1.13 diff -u -d -r1.12 -r1.13 --- Window.java 29 Sep 2003 09:26:20 -0000 1.12 +++ Window.java 1 Oct 2003 09:33:22 -0000 1.13 @@ -25,6 +25,7 @@ import org.lwjgl.Sys; import java.util.HashSet; +import java.lang.reflect.Method; public final class Window { @@ -53,19 +54,19 @@ * I have posted a bug report to apple regarding the behaviour. * */ - if (Display.getPlatform() == Display.PLATFORM_AGL) { - java.awt.Toolkit.getDefaultToolkit(); - new com.apple.eawt.Application().addApplicationListener(new com.apple.eawt.ApplicationAdapter() { - public void handleQuit(com.apple.eawt.ApplicationEvent e) { - e.setHandled(false); - apple_quit = true; - } - }); - } + if (Display.getPlatform() == Display.PLATFORM_AGL) + initMacOSX(); } - /** Special quit boolean set from the apple version */ - private static boolean apple_quit; + private static void initMacOSX() { + try { + Class mac_class = Class.forName("org.lwjgl.opengl.MacOSX"); + Method init_method = mac_class.getMethod("initMacOSX", null); + init_method.invoke(null, null); + } catch (Exception e) { + e.printStackTrace(); + } + } /** Whether the window is currently created, ie. has a native peer */ private static boolean created; @@ -185,9 +186,7 @@ */ public static boolean isCloseRequested() { assert isCreated() : "Cannot determine state of uncreated window"; - boolean result = nIsCloseRequested() || apple_quit; - apple_quit = false; - return result; + return nIsCloseRequested(); } private static native boolean nIsCloseRequested(); @@ -342,7 +341,6 @@ throws Exception; private static void createWindow() throws Exception { - apple_quit = false; HashSet extensions = new HashSet(); nCreate(title, x, y, width, height, fullscreen, color, alpha, depth, stencil, extensions); GLCaps.determineAvailableExtensions(extensions); |
|
From: Elias N. <eli...@us...> - 2003-10-01 09:33:28
|
Update of /cvsroot/java-game-lib/LWJGL/src/native/macosx In directory sc8-pr-cvs1:/tmp/cvs-serv28625/src/native/macosx Modified Files: Makefile.am org_lwjgl_input_Keyboard.cpp org_lwjgl_opengl_Window.cpp tools.h Added Files: Window.h org_lwjgl_opengl_MacOSX.cpp org_lwjgl_opengl_MacOSX.h Log Message: Loading Mac OS X hack through reflection --- NEW FILE: Window.h --- CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/native/macosx/Window.h /* * 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: Window.h,v 1.1 2003/10/01 09:33:22 elias_naur Exp $ * * Include file to access public window features * * @author elias_naur <eli...@us...> * @version $Revision: 1.1 $ */ #ifndef _LWJGL_WINDOW_H_INCLUDED_ #define _LWJGL_WINDOW_H_INCLUDED_ #include <jni.h> extern void setQuitRequested(void); #endif /* _LWJGL_WINDOW_H_INCLUDED_ */ --- NEW FILE: org_lwjgl_opengl_MacOSX.cpp --- CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/native/macosx/org_lwjgl_opengl_MacOSX.cpp /* * 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: org_lwjgl_opengl_MacOSX.cpp,v 1.1 2003/10/01 09:33:22 elias_naur Exp $ * * @author elias_naur <eli...@us...> * @version $Revision: 1.1 $ */ #include "Window.h" #include "org_lwjgl_opengl_MacOSX.h" JNIEXPORT void JNICALL Java_org_lwjgl_opengl_MacOSX_setQuitRequested(JNIEnv *, jclass) { setQuitRequested(); } --- NEW FILE: org_lwjgl_opengl_MacOSX.h --- CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/native/macosx/org_lwjgl_opengl_MacOSX.h /* DO NOT EDIT THIS FILE - it is machine generated */ #include <jni.h> /* Header for class org_lwjgl_opengl_MacOSX */ #ifndef _Included_org_lwjgl_opengl_MacOSX #define _Included_org_lwjgl_opengl_MacOSX #ifdef __cplusplus extern "C" { #endif /* * Class: org_lwjgl_opengl_MacOSX * Method: setQuitRequested * Signature: ()V */ JNIEXPORT void JNICALL Java_org_lwjgl_opengl_MacOSX_setQuitRequested (JNIEnv *, jclass); #ifdef __cplusplus } #endif #endif Index: Makefile.am CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/native/macosx/Makefile.am =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/macosx/Makefile.am,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- Makefile.am 1 Oct 2003 09:02:52 -0000 1.6 +++ Makefile.am 1 Oct 2003 09:33:22 -0000 1.7 @@ -8,6 +8,7 @@ org_lwjgl_Sys.cpp \ # org_lwjgl_input_Controller.cpp \ org_lwjgl_input_Keyboard.cpp \ + org_lwjgl_opengl_MacOSX.cpp \ # org_lwjgl_input_Mouse.cpp \ # org_lwjgl_input_Cursor.cpp \ org_lwjgl_opengl_Window.cpp Index: org_lwjgl_input_Keyboard.cpp CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/native/macosx/org_lwjgl_input_Keyboard.cpp =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/macosx/org_lwjgl_input_Keyboard.cpp,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- org_lwjgl_input_Keyboard.cpp 1 Oct 2003 09:02:52 -0000 1.6 +++ org_lwjgl_input_Keyboard.cpp 1 Oct 2003 09:33:22 -0000 1.7 @@ -33,7 +33,7 @@ /** * $Id$ * - * Linux keyboard handling. + * Mac OS X keyboard handling. * * @author elias_naur <eli...@us...> * @version $Revision$ Index: org_lwjgl_opengl_Window.cpp CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/native/macosx/org_lwjgl_opengl_Window.cpp =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/macosx/org_lwjgl_opengl_Window.cpp,v retrieving revision 1.10 retrieving revision 1.11 diff -u -d -r1.10 -r1.11 --- org_lwjgl_opengl_Window.cpp 1 Oct 2003 09:02:52 -0000 1.10 +++ org_lwjgl_opengl_Window.cpp 1 Oct 2003 09:33:22 -0000 1.11 @@ -62,8 +62,12 @@ env->ReleaseStringUTFChars(title_obj, title); } -static pascal OSStatus doQuit(EventHandlerCallRef next_handler, EventRef event, void *user_data) { +void setQuitRequested(void) { close_requested = true; +} + +static pascal OSStatus doQuit(EventHandlerCallRef next_handler, EventRef event, void *user_data) { + setQuitRequested(); return noErr; } Index: tools.h CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/native/macosx/tools.h =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/macosx/tools.h,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- tools.h 1 Oct 2003 09:02:52 -0000 1.1 +++ tools.h 1 Oct 2003 09:33:22 -0000 1.2 @@ -3,6 +3,6 @@ #include <JavaVM/jni.h> -void throwException(JNIEnv* env, const char* msg); +extern void throwException(JNIEnv* env, const char* msg); #endif |
Update of /cvsroot/java-game-lib/LWJGL/src/native/macosx In directory sc8-pr-cvs1:/tmp/cvs-serv23786/macosx Modified Files: Makefile.am org_lwjgl_input_Keyboard.cpp org_lwjgl_opengl_Window.cpp Added Files: tools.cpp tools.h Removed Files: org_lwjgl_opengl_BaseGL.cpp Log Message: --- NEW FILE: tools.cpp --- CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/native/macosx/tools.cpp #include "tools.h" void throwException(JNIEnv* env, const char* msg) { jclass cls = env->FindClass("java/lang/Exception"); env->ThrowNew(cls, err); env->DeleteLocalRef(cls); } --- NEW FILE: tools.h --- CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/native/macosx/tools.h #ifndef TOOLS_H #define TOOLS_H #include <JavaVM/jni.h> void throwException(JNIEnv* env, const char* msg); #endif Index: Makefile.am CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/native/macosx/Makefile.am =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/macosx/Makefile.am,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- Makefile.am 26 Sep 2003 13:59:50 -0000 1.5 +++ Makefile.am 1 Oct 2003 09:02:52 -0000 1.6 @@ -7,7 +7,7 @@ org_lwjgl_Display.cpp \ org_lwjgl_Sys.cpp \ # org_lwjgl_input_Controller.cpp \ -# org_lwjgl_input_Keyboard.cpp \ + org_lwjgl_input_Keyboard.cpp \ # org_lwjgl_input_Mouse.cpp \ # org_lwjgl_input_Cursor.cpp \ org_lwjgl_opengl_Window.cpp Index: org_lwjgl_input_Keyboard.cpp CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/native/macosx/org_lwjgl_input_Keyboard.cpp =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/macosx/org_lwjgl_input_Keyboard.cpp,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- org_lwjgl_input_Keyboard.cpp 30 Sep 2003 10:52:05 -0000 1.5 +++ org_lwjgl_input_Keyboard.cpp 1 Oct 2003 09:02:52 -0000 1.6 @@ -39,6 +39,11 @@ * @version $Revision$ */ +#include <IOKit/IOKitLib.h> +#include <IOKit/hid/IOHIDKeys.h> +#include <CoreFoundation/CoreFoundation.h> +#include <stdlib.h> +#include "tools.h" #include "org_lwjgl_input_Keyboard.h" #define KEYBOARD_BUFFER_SIZE 50 @@ -55,6 +60,36 @@ { } +static void printCFString(CFStringRef str) { + CFIndex buffer_size = CFStringGetLength(str) + 1; + char * buffer = (char *)malloc(buffer_size); + if (buffer != NULL) { + if (CFStringGetCString(str, buffer, buffer_size, CFStringGetSystemEncoding())) + printf("%s", buffer); + free(buffer); + } +} + +static void printCFNumber(CFNumberRef num) { + long number; + + if (CFNumberGetValue(num, kCFNumberLongType, &number)) + printf("0x%lx (%ld)", number, number); +} + +static void printProperty(CFDictionaryRef dict, CFStringRef key) { + CFTypeRef val = CFDictionaryGetValue(dict, key); + if (val != NULL) { + CFTypeID type = CFGetTypeID(val); + if (type == CFArrayGetTypeID()) printf("array\n"); + else if (type == CFBooleanGetTypeID()) printf("boolean\n"); + else if (type == CFDictionaryGetTypeID()) printf("dictionary\n"); + else if (type == CFNumberGetTypeID()) printCFNumber((CFNumberRef)val); + else if (type == CFStringGetTypeID()) printCFString((CFStringRef)val); + else printf("<unknown object type>\n"); + } +} + /* * Class: org_lwjgl_input_Keyboard * Method: nCreate @@ -63,6 +98,31 @@ JNIEXPORT void JNICALL Java_org_lwjgl_input_Keyboard_nCreate (JNIEnv * env, jclass clazz) { + io_iterator_t device_iterator; + io_object_t hid_device; + kern_return_t kern_err; + CFMutableDictionaryRef dev_props; + CFMutableDictionaryRef matching_dic = IOServiceMatching(kIOHIDDeviceKey); + IOReturn err = IOServiceGetMatchingServices(kIOMasterPortDefault, matching_dic, &device_iterator); + if (err != kIOReturnSuccess) { + throwException(env, "Could not find matching devices"); + return; + } + while ((hid_device = IOIteratorNext(device_iterator)) != NULL) { + kern_err = IORegistryEntryCreateCFProperties(hid_device, &dev_props, kCFAllocatorDefault, kNilOptions); + IOObjectRelease(hid_device); + if (kern_err == KERN_SUCCESS && dev_props != NULL) { + printf("Device found: "); + printProperty(dev_props, CFSTR(kIOHIDProductKey)); + printf(" usage "); + printProperty(dev_props, CFSTR(kIOHIDPrimaryUsageKey)); + printf(" usage page "); + printProperty(dev_props, CFSTR(kIOHIDPrimaryUsagePageKey)); + printf("\n"); + CFRelease(dev_props); + } + } + IOObjectRelease(device_iterator); } /* @@ -90,16 +150,17 @@ * Method: nRead * Signature: (I)V */ -JNIEXPORT int JNICALL Java_org_lwjgl_input_Keyboard_nRead +JNIEXPORT jint JNICALL Java_org_lwjgl_input_Keyboard_nRead (JNIEnv * env, jclass clazz) { +} /* * Class: org_lwjgl_input_Keyboard * Method: nEnableTranslation * Signature: ()I */ -JNIEXPORT jboolean JNICALL Java_org_lwjgl_input_Keyboard_nEnableTranslation +JNIEXPORT void JNICALL Java_org_lwjgl_input_Keyboard_nEnableTranslation (JNIEnv *env, jclass clazz) { } Index: org_lwjgl_opengl_Window.cpp CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/native/macosx/org_lwjgl_opengl_Window.cpp =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/macosx/org_lwjgl_opengl_Window.cpp,v retrieving revision 1.9 retrieving revision 1.10 diff -u -d -r1.9 -r1.10 --- org_lwjgl_opengl_Window.cpp 30 Sep 2003 10:52:05 -0000 1.9 +++ org_lwjgl_opengl_Window.cpp 1 Oct 2003 09:02:52 -0000 1.10 @@ -40,24 +40,14 @@ */ #include <Carbon/Carbon.h> -#include <JavaVM/jni.h> #include "org_lwjgl_opengl_Window.h" #include "extgl.h" +#include "tools.h" static WindowRef win_ref; static AGLContext context; static bool close_requested; -/* - * Utility function to throw an Exception - */ -static void throwException(JNIEnv * env, const char * err) -{ - jclass cls = env->FindClass("java/lang/Exception"); - env->ThrowNew(cls, err); - env->DeleteLocalRef(cls); -} - static void setWindowTitle(JNIEnv *env, jstring title_obj) { const char* title = env->GetStringUTFChars(title_obj, NULL); CFStringRef cf_title = CFStringCreateWithCString(NULL, title, kCFStringEncodingUTF8); @@ -184,7 +174,6 @@ JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Window_update (JNIEnv *env, jclass clazz) { - RunApplicationEventLoop(); } JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Window_swapBuffers(JNIEnv * env, jclass clazz) --- org_lwjgl_opengl_BaseGL.cpp DELETED --- CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/native/macosx/org_lwjgl_opengl_BaseGL.cpp |