*** empty log message ***

This commit is contained in:
Elias Naur 2003-09-30 11:14:06 +00:00
parent dd72b04c90
commit 6d8991f7dd
6 changed files with 41 additions and 73 deletions

View File

@ -38,6 +38,7 @@
* @version $Revision$ * @version $Revision$
*/ */
#include <jni.h> #include <jni.h>
#include <Window.h>
#include "org_lwjgl_input_Controller.h" #include "org_lwjgl_input_Controller.h"
/** /**
@ -49,8 +50,8 @@ JNIEXPORT void JNICALL Java_org_lwjgl_input_Controller_initIDs(JNIEnv * env, jcl
/** /**
* Called when the Controller instance is to be created * 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) {
return JNI_FALSE; throwException(env, "Controller not implemented");
} }
/* /*

View File

@ -131,7 +131,7 @@ void releaseKeyboard(void) {
* Method: nCreate * Method: nCreate
* Signature: ()Z * Signature: ()Z
*/ */
JNIEXPORT jboolean JNICALL Java_org_lwjgl_input_Keyboard_nCreate JNIEXPORT void JNICALL Java_org_lwjgl_input_Keyboard_nCreate
(JNIEnv * env, jclass clazz) (JNIEnv * env, jclass clazz)
{ {
for (int i = 0; i < KEYBOARD_SIZE; i++) for (int i = 0; i < KEYBOARD_SIZE; i++)
@ -162,7 +162,6 @@ JNIEXPORT jboolean JNICALL Java_org_lwjgl_input_Keyboard_nCreate
buffer_enabled = false; buffer_enabled = false;
should_grab = true; should_grab = true;
updateGrab(); updateGrab();
return JNI_TRUE;
} }
/* /*
@ -300,11 +299,10 @@ JNIEXPORT int JNICALL Java_org_lwjgl_input_Keyboard_nRead
* Method: nEnableTranslation * Method: nEnableTranslation
* Signature: ()I * Signature: ()I
*/ */
JNIEXPORT jboolean JNICALL Java_org_lwjgl_input_Keyboard_nEnableTranslation JNIEXPORT void JNICALL Java_org_lwjgl_input_Keyboard_nEnableTranslation
(JNIEnv *env, jclass clazz) (JNIEnv *env, jclass clazz)
{ {
translation_enabled = true; translation_enabled = true;
return JNI_TRUE;
} }
/* /*

View File

@ -265,7 +265,7 @@ JNIEXPORT jint JNICALL Java_org_lwjgl_input_Mouse_nGetMaxCursorSize
* Method: nCreate * Method: nCreate
* Signature: ()Z * Signature: ()Z
*/ */
JNIEXPORT jboolean JNICALL Java_org_lwjgl_input_Mouse_nCreate JNIEXPORT void JNICALL Java_org_lwjgl_input_Mouse_nCreate
(JNIEnv * env, jclass clazz) (JNIEnv * env, jclass clazz)
{ {
int i; int i;
@ -276,10 +276,8 @@ JNIEXPORT jboolean JNICALL Java_org_lwjgl_input_Mouse_nCreate
for (i = 0; i < NUM_BUTTONS; i++) for (i = 0; i < NUM_BUTTONS; i++)
buttons[i] = JNI_FALSE; buttons[i] = JNI_FALSE;
if (!blankCursor()) { if (!blankCursor()) {
#ifdef _DEBUG throwException(env, "Could not create blank cursor");
printf("Could not create blank cursor\n"); return;
#endif
return JNI_FALSE;
} }
current_cursor = blank_cursor; current_cursor = blank_cursor;
native_cursor = false; native_cursor = false;
@ -288,7 +286,6 @@ JNIEXPORT jboolean JNICALL Java_org_lwjgl_input_Mouse_nCreate
pointer_grabbed = false; pointer_grabbed = false;
updateGrab(); updateGrab();
loadXcursor(); loadXcursor();
return JNI_TRUE;
} }
/* /*

View File

@ -118,7 +118,7 @@ JNIEXPORT void JNICALL Java_org_lwjgl_input_Controller_initIDs(JNIEnv * env, jcl
/** /**
* Called when the Controller instance is to be created * 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. // Create the DirectInput object.
HRESULT hr; HRESULT hr;
hr = DirectInputCreate(dll_handle, DIRECTINPUT_VERSION, &cDI, NULL); hr = DirectInputCreate(dll_handle, DIRECTINPUT_VERSION, &cDI, NULL);
@ -127,26 +127,22 @@ JNIEXPORT jboolean JNICALL Java_org_lwjgl_input_Controller_nCreate(JNIEnv *env,
printf("DirectInputCreate failed\n"); printf("DirectInputCreate failed\n");
#endif #endif
ShutdownController(); ShutdownController();
return JNI_FALSE; return;
} }
/* Find all Controllers */ /* Find all Controllers */
EnumerateControllers(); EnumerateControllers();
if (!cCreate_success) { if (!cCreate_success) {
#if _DEBUG throwException(env, "Failed to enumerate.");
printf("EnumerateControllers failed\n");
#endif
ShutdownController(); ShutdownController();
return JNI_FALSE; return;
} }
/* check that we got at least 1 controller */ /* check that we got at least 1 controller */
if (cDIDevice == NULL) { if (cDIDevice == NULL) {
#if _DEBUG throwException(env, "No devices found.");
printf("No devices found during enumeration\n");
#endif
ShutdownController(); ShutdownController();
return JNI_FALSE; return;
} }
//check for first time initialization - need to detect capabilities //check for first time initialization - need to detect capabilities
@ -157,11 +153,9 @@ JNIEXPORT jboolean JNICALL Java_org_lwjgl_input_Controller_nCreate(JNIEnv *env,
/* Enumerate capabilities of Controller */ /* Enumerate capabilities of Controller */
EnumerateControllerCapabilities(); EnumerateControllerCapabilities();
if (!cCreate_success) { if (!cCreate_success) {
#if _DEBUG throwException(env, "Falied to enumerate capabilities.");
printf("EnumerateControllerCapabilities failed\n");
#endif
ShutdownController(); ShutdownController();
return JNI_FALSE; return;
} }
/* Do setup of Controller */ /* Do setup of Controller */
@ -185,11 +179,9 @@ JNIEXPORT jboolean JNICALL Java_org_lwjgl_input_Controller_nCreate(JNIEnv *env,
/* Aquire the Controller */ /* Aquire the Controller */
hr = cDIDevice->Acquire(); hr = cDIDevice->Acquire();
if(FAILED(hr)) { if(FAILED(hr)) {
#if _DEBUG throwException(env, "Acquire failed");
printf("Acquire failed\n");
#endif
ShutdownController(); ShutdownController();
return JNI_FALSE; return;
} }
return cCreate_success ? JNI_TRUE : JNI_FALSE; return cCreate_success ? JNI_TRUE : JNI_FALSE;
} }
@ -234,7 +226,7 @@ JNIEXPORT void JNICALL Java_org_lwjgl_input_Controller_nPoll(JNIEnv * env, jclas
/** /**
* Shutdown DI * Shutdown DI
*/ */
void ShutdownController() { static void ShutdownController() {
// release device // release device
if (cDIDevice != NULL) { if (cDIDevice != NULL) {
cDIDevice->Unacquire(); cDIDevice->Unacquire();
@ -246,7 +238,7 @@ void ShutdownController() {
/** /**
* Enumerates the capabilities of the Controller attached to the system * Enumerates the capabilities of the Controller attached to the system
*/ */
void EnumerateControllerCapabilities() { static void EnumerateControllerCapabilities() {
HRESULT hr; HRESULT hr;
hr = cDIDevice->EnumObjects(EnumControllerObjectsCallback, NULL, DIDFT_ALL); hr = cDIDevice->EnumObjects(EnumControllerObjectsCallback, NULL, DIDFT_ALL);
if FAILED(hr) { if FAILED(hr) {
@ -262,7 +254,7 @@ void EnumerateControllerCapabilities() {
/** /**
* Enumerates the Controllers attached to the system * Enumerates the Controllers attached to the system
*/ */
void EnumerateControllers() { static void EnumerateControllers() {
HRESULT hr; HRESULT hr;
hr = cDI->EnumDevices(DIDEVTYPE_JOYSTICK, EnumControllerCallback, 0, DIEDFL_ATTACHEDONLY); hr = cDI->EnumDevices(DIDEVTYPE_JOYSTICK, EnumControllerCallback, 0, DIEDFL_ATTACHEDONLY);
if FAILED(hr) { if FAILED(hr) {
@ -322,7 +314,7 @@ BOOL CALLBACK EnumControllerObjectsCallback(LPCDIDEVICEOBJECTINSTANCE lpddoi, LP
/** /**
* Creates the specified device as a Controller * Creates the specified device as a Controller
*/ */
void CreateController(LPCDIDEVICEINSTANCE lpddi) { static void CreateController(LPCDIDEVICEINSTANCE lpddi) {
HRESULT hr; HRESULT hr;
hr = cDI->CreateDevice(lpddi->guidInstance, (LPDIRECTINPUTDEVICE*) &cDIDevice, NULL); hr = cDI->CreateDevice(lpddi->guidInstance, (LPDIRECTINPUTDEVICE*) &cDIDevice, NULL);
if FAILED(hr) { if FAILED(hr) {
@ -338,7 +330,7 @@ void CreateController(LPCDIDEVICEINSTANCE lpddi) {
/** /**
* Sets up the Controller properties * Sets up the Controller properties
*/ */
void SetupController() { static void SetupController() {
// set Controller data format // set Controller data format
if(cDIDevice->SetDataFormat(&c_dfDIJoystick2) != DI_OK) { if(cDIDevice->SetDataFormat(&c_dfDIJoystick2) != DI_OK) {
#if _DEBUG #if _DEBUG
@ -460,7 +452,7 @@ void SetupController() {
/** /**
* Sets the fields on the Controller * Sets the fields on the Controller
*/ */
void InitializeControllerFields() { static void InitializeControllerFields() {
//create buttons array //create buttons array
jbooleanArray cButtonsArray = cEnvironment->NewBooleanArray(cButtoncount); jbooleanArray cButtonsArray = cEnvironment->NewBooleanArray(cButtoncount);
@ -471,7 +463,7 @@ void InitializeControllerFields() {
/** /**
* Updates the fields on the Controller * Updates the fields on the Controller
*/ */
void UpdateControllerFields() { static void UpdateControllerFields() {
HRESULT hRes; HRESULT hRes;
// get data from the Controller // get data from the Controller
@ -543,7 +535,7 @@ void UpdateControllerFields() {
/** /**
* Sets the capabilities of the Controller * Sets the capabilities of the Controller
*/ */
void SetControllerCapabilities() { static void SetControllerCapabilities() {
//set buttoncount //set buttoncount
cEnvironment->SetStaticIntField(clsController, fidCButtonCount, cButtoncount); cEnvironment->SetStaticIntField(clsController, fidCButtonCount, cButtoncount);
@ -567,7 +559,7 @@ void SetControllerCapabilities() {
/** /**
* Caches the field ids for quicker access * Caches the field ids for quicker access
*/ */
void CacheControllerFields() { static void CacheControllerFields() {
fidCButtonCount = cEnvironment->GetStaticFieldID(clsController, "buttonCount", "I"); fidCButtonCount = cEnvironment->GetStaticFieldID(clsController, "buttonCount", "I");
fidCHasXAxis = cEnvironment->GetStaticFieldID(clsController, "hasXAxis", "Z"); fidCHasXAxis = cEnvironment->GetStaticFieldID(clsController, "hasXAxis", "Z");
fidCHasRXAxis = cEnvironment->GetStaticFieldID(clsController, "hasRXAxis", "Z"); fidCHasRXAxis = cEnvironment->GetStaticFieldID(clsController, "hasRXAxis", "Z");
@ -586,4 +578,4 @@ void CacheControllerFields() {
fidCRZ = cEnvironment->GetStaticFieldID(clsController, "rz", "I"); fidCRZ = cEnvironment->GetStaticFieldID(clsController, "rz", "I");
fidCPOV = cEnvironment->GetStaticFieldID(clsController, "pov", "I"); fidCPOV = cEnvironment->GetStaticFieldID(clsController, "pov", "I");
fidCSlider = cEnvironment->GetStaticFieldID(clsController, "slider", "I"); fidCSlider = cEnvironment->GetStaticFieldID(clsController, "slider", "I");
} }

View File

@ -80,38 +80,30 @@ JNIEXPORT void JNICALL Java_org_lwjgl_input_Keyboard_initIDs
* Method: nCreate * Method: nCreate
* Signature: ()Z * Signature: ()Z
*/ */
JNIEXPORT jboolean JNICALL Java_org_lwjgl_input_Keyboard_nCreate JNIEXPORT void JNICALL Java_org_lwjgl_input_Keyboard_nCreate
(JNIEnv * env, jclass clazz) (JNIEnv * env, jclass clazz)
{ {
translationEnabled = false; translationEnabled = false;
// Check to see if we're already initialized // Check to see if we're already initialized
if (lpdiKeyboard != NULL) { if (lpdiKeyboard != NULL) {
#ifdef _DEBUG throwException(env, "Keyboard already created.");
printf("Keyboard already created.\n"); return;
#endif
return JNI_FALSE;
} }
if (hwnd == NULL) { if (hwnd == NULL) {
#ifdef _DEBUG throwException(env, "No window.");
printf("No window\n"); return;
#endif
return JNI_FALSE;
} }
// Create a keyboard device // Create a keyboard device
if (lpdi->CreateDevice(GUID_SysKeyboard, &lpdiKeyboard, NULL) != DI_OK) { if (lpdi->CreateDevice(GUID_SysKeyboard, &lpdiKeyboard, NULL) != DI_OK) {
#ifdef _DEBUG throwException(env, "Failed to create keyboard.");
printf("Failed to create keyboard\n"); return;
#endif
return JNI_FALSE;
} }
if (lpdiKeyboard->SetCooperativeLevel(hwnd, DISCL_NONEXCLUSIVE | DISCL_FOREGROUND) != DI_OK) { if (lpdiKeyboard->SetCooperativeLevel(hwnd, DISCL_NONEXCLUSIVE | DISCL_FOREGROUND) != DI_OK) {
#ifdef _DEBUG throwException(env, "Failed to set keyboard cooperation mode.");
printf("Failed to set keyboard cooperation mode\n"); return;
#endif
return JNI_FALSE;
} }
// Tell 'em wot format to be in (the default "you are a mouse and keyboard" format) // Tell 'em wot format to be in (the default "you are a mouse and keyboard" format)
@ -131,9 +123,6 @@ JNIEXPORT jboolean JNICALL Java_org_lwjgl_input_Keyboard_nCreate
printf("Failed to acquire keyboard\n"); printf("Failed to acquire keyboard\n");
#endif #endif
} }
return JNI_TRUE;
} }
/* /*
@ -308,7 +297,7 @@ JNIEXPORT jint JNICALL Java_org_lwjgl_input_Keyboard_nRead
* Method: nEnableTranslation * Method: nEnableTranslation
* Signature: ()V * Signature: ()V
*/ */
JNIEXPORT jboolean JNICALL Java_org_lwjgl_input_Keyboard_nEnableTranslation JNIEXPORT void JNICALL Java_org_lwjgl_input_Keyboard_nEnableTranslation
(JNIEnv *, jclass) (JNIEnv *, jclass)
{ {
// We can't do translation on DOS boxes it seems so we'll have to throw a wobbler // We can't do translation on DOS boxes it seems so we'll have to throw a wobbler
@ -324,7 +313,6 @@ JNIEXPORT jboolean JNICALL Java_org_lwjgl_input_Keyboard_nEnableTranslation
useUnicode = false; useUnicode = false;
} }
translationEnabled = true; translationEnabled = true;
return JNI_TRUE;
} }
/* /*

View File

@ -102,7 +102,7 @@ JNIEXPORT void JNICALL Java_org_lwjgl_input_Mouse_initIDs(JNIEnv * env, jclass c
/** /**
* Called when the Mouse instance is to be created * 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; HRESULT hr;
mEnvironment = env; mEnvironment = env;
@ -120,11 +120,9 @@ JNIEXPORT jboolean JNICALL Java_org_lwjgl_input_Mouse_nCreate(JNIEnv *env, jclas
/* Enumerate capabilities of Mouse */ /* Enumerate capabilities of Mouse */
EnumerateMouseCapabilities(); EnumerateMouseCapabilities();
if (!mCreate_success) { if (!mCreate_success) {
#if _DEBUG throwException(env, "Failed to enumerate.");
printf("EnumerateMouseCapabilities failed\n");
#endif
ShutdownMouse(); ShutdownMouse();
return JNI_FALSE; return;
} }
/* Do setup of Mouse */ /* Do setup of Mouse */
SetupMouse(); SetupMouse();
@ -171,9 +169,6 @@ JNIEXPORT void JNICALL Java_org_lwjgl_input_Mouse_nSetNativeCursor
throwException(env, "null device!"); throwException(env, "null device!");
mDIDevice->Unacquire(); mDIDevice->Unacquire();
if(mDIDevice->SetCooperativeLevel(hwnd, DISCL_NONEXCLUSIVE | DISCL_FOREGROUND) != DI_OK) { if(mDIDevice->SetCooperativeLevel(hwnd, DISCL_NONEXCLUSIVE | DISCL_FOREGROUND) != DI_OK) {
#if _DEBUG
printf("SetCooperativeLevel failed\n");
#endif
throwException(env, "Could not set the CooperativeLevel."); throwException(env, "Could not set the CooperativeLevel.");
return; return;
} }
@ -197,9 +192,6 @@ JNIEXPORT void JNICALL Java_org_lwjgl_input_Mouse_nSetNativeCursor
SetCursor(NULL); SetCursor(NULL);
mDIDevice->Unacquire(); mDIDevice->Unacquire();
if(mDIDevice->SetCooperativeLevel(hwnd, DISCL_EXCLUSIVE | DISCL_FOREGROUND) != DI_OK) { if(mDIDevice->SetCooperativeLevel(hwnd, DISCL_EXCLUSIVE | DISCL_FOREGROUND) != DI_OK) {
#if _DEBUG
printf("SetCooperativeLevel failed\n");
#endif
throwException(env, "Could not set the CooperativeLevel."); throwException(env, "Could not set the CooperativeLevel.");
return; return;
} }