|
From: Elias N. <eli...@us...> - 2003-10-25 21:33:10
|
Update of /cvsroot/java-game-lib/LWJGL/src/native/macosx In directory sc8-pr-cvs1:/tmp/cvs-serv26531/macosx Modified Files: org_lwjgl_input_Mouse.cpp Log Message: Fixed Mac OS X mouse button mapping 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.19 retrieving revision 1.20 diff -u -d -r1.19 -r1.20 --- org_lwjgl_input_Mouse.cpp 24 Oct 2003 11:46:31 -0000 1.19 +++ org_lwjgl_input_Mouse.cpp 25 Oct 2003 21:27:54 -0000 1.20 @@ -55,7 +55,7 @@ static jfieldID fid_dwheel; static jfieldID fid_buttons; -static unsigned char button_states[NUM_BUTTONS]; +static jbyte button_states[NUM_BUTTONS]; static bool buffer_enabled; /*static int x_axis_index = NUM_BUTTONS; static int y_axis_index = NUM_BUTTONS + 1; @@ -67,7 +67,13 @@ static int last_dy; static int last_dz; -static void handleButton(unsigned char button_index, unsigned char state) { +static void handleButton(unsigned char button_index, jbyte state) { + if (button_index >= NUM_BUTTONS) { +#ifdef _DEBUG + printf("Button index %d out of range [0..%d]\n", button_index, NUM_BUTTONS); +#endif + return; + } button_states[button_index] = state; if (buffer_enabled) { putEventElement(&event_queue, button_index); @@ -122,7 +128,7 @@ #endif return; } - handleButton(button, state); + handleButton(button - 1, state); } static void handleMovedEvent(EventRef event) { @@ -159,6 +165,7 @@ case kEventMouseUp: handleButtonEvent(event, 0); break; + case kEventMouseDragged: case kEventMouseMoved: handleMovedEvent(event); break; @@ -253,8 +260,8 @@ env->SetStaticIntField(clazz, fid_dx, (jint)dx); env->SetStaticIntField(clazz, fid_dy, (jint)dy); env->SetStaticIntField(clazz, fid_dwheel, (jint)dz); - jbooleanArray buttons_array = (jbooleanArray)env->GetStaticObjectField(clazz, fid_buttons); - env->SetBooleanArrayRegion(buttons_array, 0, NUM_BUTTONS, button_states); + jbyteArray buttons_array = (jbyteArray)env->GetStaticObjectField(clazz, fid_buttons); + env->SetByteArrayRegion(buttons_array, 0, NUM_BUTTONS, button_states); resetDeltas(); } |