|
From: Elias N. <eli...@us...> - 2003-09-30 11:14:43
|
Update of /cvsroot/java-game-lib/LWJGL/src/native/win32 In directory sc8-pr-cvs1:/tmp/cvs-serv30485/win32 Modified Files: org_lwjgl_input_Controller.cpp org_lwjgl_input_Keyboard.cpp org_lwjgl_input_Mouse.cpp Log Message: Index: org_lwjgl_input_Controller.cpp CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/native/win32/org_lwjgl_input_Controller.cpp =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/win32/org_lwjgl_input_Controller.cpp,v retrieving revision 1.12 retrieving revision 1.13 diff -u -d -r1.12 -r1.13 --- org_lwjgl_input_Controller.cpp 16 May 2003 18:39:46 -0000 1.12 +++ org_lwjgl_input_Controller.cpp 30 Sep 2003 11:14:06 -0000 1.13 @@ -118,7 +118,7 @@ /** * Called when the Controller instance is to be created */ -JNIEXPORT jboolean JNICALL Java_org_lwjgl_input_Controller_nCreate(JNIEnv *env, jclass clazz) { +JNIEXPORT void JNICALL Java_org_lwjgl_input_Controller_nCreate(JNIEnv *env, jclass clazz) { // Create the DirectInput object. HRESULT hr; hr = DirectInputCreate(dll_handle, DIRECTINPUT_VERSION, &cDI, NULL); @@ -127,26 +127,22 @@ printf("DirectInputCreate failed\n"); #endif ShutdownController(); - return JNI_FALSE; + return; } /* Find all Controllers */ EnumerateControllers(); if (!cCreate_success) { -#if _DEBUG - printf("EnumerateControllers failed\n"); -#endif + throwException(env, "Failed to enumerate."); ShutdownController(); - return JNI_FALSE; + return; } /* check that we got at least 1 controller */ if (cDIDevice == NULL) { -#if _DEBUG - printf("No devices found during enumeration\n"); -#endif + throwException(env, "No devices found."); ShutdownController(); - return JNI_FALSE; + return; } //check for first time initialization - need to detect capabilities @@ -157,11 +153,9 @@ /* Enumerate capabilities of Controller */ EnumerateControllerCapabilities(); if (!cCreate_success) { -#if _DEBUG - printf("EnumerateControllerCapabilities failed\n"); -#endif + throwException(env, "Falied to enumerate capabilities."); ShutdownController(); - return JNI_FALSE; + return; } /* Do setup of Controller */ @@ -185,11 +179,9 @@ /* Aquire the Controller */ hr = cDIDevice->Acquire(); if(FAILED(hr)) { -#if _DEBUG - printf("Acquire failed\n"); -#endif + throwException(env, "Acquire failed"); ShutdownController(); - return JNI_FALSE; + return; } return cCreate_success ? JNI_TRUE : JNI_FALSE; } @@ -234,7 +226,7 @@ /** * Shutdown DI */ -void ShutdownController() { +static void ShutdownController() { // release device if (cDIDevice != NULL) { cDIDevice->Unacquire(); @@ -246,7 +238,7 @@ /** * Enumerates the capabilities of the Controller attached to the system */ -void EnumerateControllerCapabilities() { +static void EnumerateControllerCapabilities() { HRESULT hr; hr = cDIDevice->EnumObjects(EnumControllerObjectsCallback, NULL, DIDFT_ALL); if FAILED(hr) { @@ -262,7 +254,7 @@ /** * Enumerates the Controllers attached to the system */ -void EnumerateControllers() { +static void EnumerateControllers() { HRESULT hr; hr = cDI->EnumDevices(DIDEVTYPE_JOYSTICK, EnumControllerCallback, 0, DIEDFL_ATTACHEDONLY); if FAILED(hr) { @@ -322,7 +314,7 @@ /** * Creates the specified device as a Controller */ -void CreateController(LPCDIDEVICEINSTANCE lpddi) { +static void CreateController(LPCDIDEVICEINSTANCE lpddi) { HRESULT hr; hr = cDI->CreateDevice(lpddi->guidInstance, (LPDIRECTINPUTDEVICE*) &cDIDevice, NULL); if FAILED(hr) { @@ -338,7 +330,7 @@ /** * Sets up the Controller properties */ -void SetupController() { +static void SetupController() { // set Controller data format if(cDIDevice->SetDataFormat(&c_dfDIJoystick2) != DI_OK) { #if _DEBUG @@ -460,7 +452,7 @@ /** * Sets the fields on the Controller */ -void InitializeControllerFields() { +static void InitializeControllerFields() { //create buttons array jbooleanArray cButtonsArray = cEnvironment->NewBooleanArray(cButtoncount); @@ -471,7 +463,7 @@ /** * Updates the fields on the Controller */ -void UpdateControllerFields() { +static void UpdateControllerFields() { HRESULT hRes; // get data from the Controller @@ -543,7 +535,7 @@ /** * Sets the capabilities of the Controller */ -void SetControllerCapabilities() { +static void SetControllerCapabilities() { //set buttoncount cEnvironment->SetStaticIntField(clsController, fidCButtonCount, cButtoncount); @@ -567,7 +559,7 @@ /** * Caches the field ids for quicker access */ -void CacheControllerFields() { +static void CacheControllerFields() { fidCButtonCount = cEnvironment->GetStaticFieldID(clsController, "buttonCount", "I"); fidCHasXAxis = cEnvironment->GetStaticFieldID(clsController, "hasXAxis", "Z"); fidCHasRXAxis = cEnvironment->GetStaticFieldID(clsController, "hasRXAxis", "Z"); @@ -586,4 +578,4 @@ fidCRZ = cEnvironment->GetStaticFieldID(clsController, "rz", "I"); fidCPOV = cEnvironment->GetStaticFieldID(clsController, "pov", "I"); fidCSlider = cEnvironment->GetStaticFieldID(clsController, "slider", "I"); -} \ No newline at end of file +} Index: org_lwjgl_input_Keyboard.cpp CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/native/win32/org_lwjgl_input_Keyboard.cpp =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/win32/org_lwjgl_input_Keyboard.cpp,v retrieving revision 1.23 retrieving revision 1.24 diff -u -d -r1.23 -r1.24 --- org_lwjgl_input_Keyboard.cpp 11 Sep 2003 08:00:28 -0000 1.23 +++ org_lwjgl_input_Keyboard.cpp 30 Sep 2003 11:14:06 -0000 1.24 @@ -80,38 +80,30 @@ * Method: nCreate * Signature: ()Z */ -JNIEXPORT jboolean JNICALL Java_org_lwjgl_input_Keyboard_nCreate +JNIEXPORT void JNICALL Java_org_lwjgl_input_Keyboard_nCreate (JNIEnv * env, jclass clazz) { translationEnabled = false; // Check to see if we're already initialized if (lpdiKeyboard != NULL) { -#ifdef _DEBUG - printf("Keyboard already created.\n"); -#endif - return JNI_FALSE; + throwException(env, "Keyboard already created."); + return; } if (hwnd == NULL) { -#ifdef _DEBUG - printf("No window\n"); -#endif - return JNI_FALSE; + throwException(env, "No window."); + return; } // Create a keyboard device if (lpdi->CreateDevice(GUID_SysKeyboard, &lpdiKeyboard, NULL) != DI_OK) { -#ifdef _DEBUG - printf("Failed to create keyboard\n"); -#endif - return JNI_FALSE; + throwException(env, "Failed to create keyboard."); + return; } if (lpdiKeyboard->SetCooperativeLevel(hwnd, DISCL_NONEXCLUSIVE | DISCL_FOREGROUND) != DI_OK) { -#ifdef _DEBUG - printf("Failed to set keyboard cooperation mode\n"); -#endif - return JNI_FALSE; + throwException(env, "Failed to set keyboard cooperation mode."); + return; } // Tell 'em wot format to be in (the default "you are a mouse and keyboard" format) @@ -131,9 +123,6 @@ printf("Failed to acquire keyboard\n"); #endif } - - return JNI_TRUE; - } /* @@ -308,7 +297,7 @@ * Method: nEnableTranslation * Signature: ()V */ -JNIEXPORT jboolean JNICALL Java_org_lwjgl_input_Keyboard_nEnableTranslation +JNIEXPORT void JNICALL Java_org_lwjgl_input_Keyboard_nEnableTranslation (JNIEnv *, jclass) { // We can't do translation on DOS boxes it seems so we'll have to throw a wobbler @@ -318,13 +307,12 @@ osvi.dwOSVersionInfoSize = sizeof(osvi); GetVersionEx(&osvi); - if (osvi.dwPlatformId == VER_PLATFORM_WIN32_NT) { + if (osvi.dwPlatformId == VER_PLATFORM_WIN32_NT) { useUnicode = true; } else { useUnicode = false; } - translationEnabled = true; - return JNI_TRUE; + translationEnabled = true; } /* 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.27 retrieving revision 1.28 diff -u -d -r1.27 -r1.28 --- org_lwjgl_input_Mouse.cpp 29 Aug 2003 08:00:44 -0000 1.27 +++ org_lwjgl_input_Mouse.cpp 30 Sep 2003 11:14:06 -0000 1.28 @@ -102,7 +102,7 @@ /** * Called when the Mouse instance is to be created */ -JNIEXPORT jboolean JNICALL Java_org_lwjgl_input_Mouse_nCreate(JNIEnv *env, jclass clazz) { +JNIEXPORT void JNICALL Java_org_lwjgl_input_Mouse_nCreate(JNIEnv *env, jclass clazz) { HRESULT hr; mEnvironment = env; @@ -120,11 +120,9 @@ /* Enumerate capabilities of Mouse */ EnumerateMouseCapabilities(); if (!mCreate_success) { -#if _DEBUG - printf("EnumerateMouseCapabilities failed\n"); -#endif + throwException(env, "Failed to enumerate."); ShutdownMouse(); - return JNI_FALSE; + return; } /* Do setup of Mouse */ SetupMouse(); @@ -171,9 +169,6 @@ throwException(env, "null device!"); mDIDevice->Unacquire(); if(mDIDevice->SetCooperativeLevel(hwnd, DISCL_NONEXCLUSIVE | DISCL_FOREGROUND) != DI_OK) { -#if _DEBUG - printf("SetCooperativeLevel failed\n"); -#endif throwException(env, "Could not set the CooperativeLevel."); return; } @@ -197,9 +192,6 @@ SetCursor(NULL); mDIDevice->Unacquire(); if(mDIDevice->SetCooperativeLevel(hwnd, DISCL_EXCLUSIVE | DISCL_FOREGROUND) != DI_OK) { -#if _DEBUG - printf("SetCooperativeLevel failed\n"); -#endif throwException(env, "Could not set the CooperativeLevel."); return; } |