*** 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$
*/
#include <jni.h>
#include <Window.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
*/
JNIEXPORT jboolean JNICALL Java_org_lwjgl_input_Controller_nCreate(JNIEnv *env, jclass clazz) {
return JNI_FALSE;
JNIEXPORT void JNICALL Java_org_lwjgl_input_Controller_nCreate(JNIEnv *env, jclass clazz) {
throwException(env, "Controller not implemented");
}
/*

View File

@ -131,7 +131,7 @@ void releaseKeyboard(void) {
* 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)
{
for (int i = 0; i < KEYBOARD_SIZE; i++)
@ -162,7 +162,6 @@ JNIEXPORT jboolean JNICALL Java_org_lwjgl_input_Keyboard_nCreate
buffer_enabled = false;
should_grab = true;
updateGrab();
return JNI_TRUE;
}
/*
@ -300,11 +299,10 @@ JNIEXPORT int JNICALL Java_org_lwjgl_input_Keyboard_nRead
* 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)
{
translation_enabled = true;
return JNI_TRUE;
}
/*

View File

@ -265,7 +265,7 @@ JNIEXPORT jint JNICALL Java_org_lwjgl_input_Mouse_nGetMaxCursorSize
* Method: nCreate
* Signature: ()Z
*/
JNIEXPORT jboolean JNICALL Java_org_lwjgl_input_Mouse_nCreate
JNIEXPORT void JNICALL Java_org_lwjgl_input_Mouse_nCreate
(JNIEnv * env, jclass clazz)
{
int i;
@ -276,10 +276,8 @@ JNIEXPORT jboolean JNICALL Java_org_lwjgl_input_Mouse_nCreate
for (i = 0; i < NUM_BUTTONS; i++)
buttons[i] = JNI_FALSE;
if (!blankCursor()) {
#ifdef _DEBUG
printf("Could not create blank cursor\n");
#endif
return JNI_FALSE;
throwException(env, "Could not create blank cursor");
return;
}
current_cursor = blank_cursor;
native_cursor = false;
@ -288,7 +286,6 @@ JNIEXPORT jboolean JNICALL Java_org_lwjgl_input_Mouse_nCreate
pointer_grabbed = false;
updateGrab();
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
*/
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 @@ JNIEXPORT jboolean JNICALL Java_org_lwjgl_input_Controller_nCreate(JNIEnv *env,
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 @@ JNIEXPORT jboolean JNICALL Java_org_lwjgl_input_Controller_nCreate(JNIEnv *env,
/* 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 @@ JNIEXPORT jboolean JNICALL Java_org_lwjgl_input_Controller_nCreate(JNIEnv *env,
/* 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 @@ JNIEXPORT void JNICALL Java_org_lwjgl_input_Controller_nPoll(JNIEnv * env, jclas
/**
* Shutdown DI
*/
void ShutdownController() {
static void ShutdownController() {
// release device
if (cDIDevice != NULL) {
cDIDevice->Unacquire();
@ -246,7 +238,7 @@ void ShutdownController() {
/**
* 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 @@ void EnumerateControllerCapabilities() {
/**
* 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 @@ BOOL CALLBACK EnumControllerObjectsCallback(LPCDIDEVICEOBJECTINSTANCE lpddoi, LP
/**
* 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 @@ void CreateController(LPCDIDEVICEINSTANCE lpddi) {
/**
* 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 @@ void SetupController() {
/**
* Sets the fields on the Controller
*/
void InitializeControllerFields() {
static void InitializeControllerFields() {
//create buttons array
jbooleanArray cButtonsArray = cEnvironment->NewBooleanArray(cButtoncount);
@ -471,7 +463,7 @@ void InitializeControllerFields() {
/**
* Updates the fields on the Controller
*/
void UpdateControllerFields() {
static void UpdateControllerFields() {
HRESULT hRes;
// get data from the Controller
@ -543,7 +535,7 @@ void UpdateControllerFields() {
/**
* Sets the capabilities of the Controller
*/
void SetControllerCapabilities() {
static void SetControllerCapabilities() {
//set buttoncount
cEnvironment->SetStaticIntField(clsController, fidCButtonCount, cButtoncount);
@ -567,7 +559,7 @@ void SetControllerCapabilities() {
/**
* 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 @@ void CacheControllerFields() {
fidCRZ = cEnvironment->GetStaticFieldID(clsController, "rz", "I");
fidCPOV = cEnvironment->GetStaticFieldID(clsController, "pov", "I");
fidCSlider = cEnvironment->GetStaticFieldID(clsController, "slider", "I");
}
}

View File

@ -80,38 +80,30 @@ JNIEXPORT void JNICALL Java_org_lwjgl_input_Keyboard_initIDs
* 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 @@ JNIEXPORT jboolean JNICALL Java_org_lwjgl_input_Keyboard_nCreate
printf("Failed to acquire keyboard\n");
#endif
}
return JNI_TRUE;
}
/*
@ -308,7 +297,7 @@ JNIEXPORT jint JNICALL Java_org_lwjgl_input_Keyboard_nRead
* 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
@ -324,7 +313,6 @@ JNIEXPORT jboolean JNICALL Java_org_lwjgl_input_Keyboard_nEnableTranslation
useUnicode = false;
}
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
*/
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 @@ JNIEXPORT jboolean JNICALL Java_org_lwjgl_input_Mouse_nCreate(JNIEnv *env, jclas
/* 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 @@ JNIEXPORT void JNICALL Java_org_lwjgl_input_Mouse_nSetNativeCursor
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 @@ JNIEXPORT void JNICALL Java_org_lwjgl_input_Mouse_nSetNativeCursor
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;
}