fix: removed GlobalRef
fix: now sets fields to JNI_TRUE/JNI_FALSE respectively
This commit is contained in:
parent
c6747e0a8e
commit
e78cdd5029
|
@ -70,7 +70,6 @@ JNIEnv* cEnvironment; // JNIEnvironment copy
|
||||||
|
|
||||||
bool cCreate_success; // bool used to determine successfull creation
|
bool cCreate_success; // bool used to determine successfull creation
|
||||||
bool cFirstTimeInitialization = true; // boolean to determine first time initialization
|
bool cFirstTimeInitialization = true; // boolean to determine first time initialization
|
||||||
jobject cButtonsReference = NULL; // reference to buttons array so it won't get GC'ed
|
|
||||||
|
|
||||||
// Cached fields of Controller.java
|
// Cached fields of Controller.java
|
||||||
jclass clsController;
|
jclass clsController;
|
||||||
|
@ -166,10 +165,8 @@ JNIEXPORT jboolean JNICALL Java_org_lwjgl_input_Controller_nCreate(JNIEnv *env,
|
||||||
return JNI_FALSE;
|
return JNI_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(cCreate_success) {
|
/* Do setup of Controller */
|
||||||
/* Do setup of Controller */
|
SetupController();
|
||||||
SetupController();
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Initialize any fields on the Controller */
|
/* Initialize any fields on the Controller */
|
||||||
InitializeControllerFields();
|
InitializeControllerFields();
|
||||||
|
@ -195,7 +192,7 @@ JNIEXPORT jboolean JNICALL Java_org_lwjgl_input_Controller_nCreate(JNIEnv *env,
|
||||||
ShutdownController();
|
ShutdownController();
|
||||||
return JNI_FALSE;
|
return JNI_FALSE;
|
||||||
}
|
}
|
||||||
return cCreate_success;
|
return cCreate_success ? JNI_TRUE : JNI_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -245,9 +242,6 @@ void ShutdownController() {
|
||||||
cDIDevice->Release();
|
cDIDevice->Release();
|
||||||
cDIDevice = NULL;
|
cDIDevice = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
//delete global reference, since we're done
|
|
||||||
cEnvironment->DeleteGlobalRef(cButtonsReference);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -471,11 +465,8 @@ void InitializeControllerFields() {
|
||||||
//create buttons array
|
//create buttons array
|
||||||
jbooleanArray cButtonsArray = cEnvironment->NewBooleanArray(cButtoncount);
|
jbooleanArray cButtonsArray = cEnvironment->NewBooleanArray(cButtoncount);
|
||||||
|
|
||||||
//create reference so it won't get GC'ed
|
|
||||||
cButtonsReference = cEnvironment->NewGlobalRef(cButtonsArray);
|
|
||||||
|
|
||||||
//set buttons array
|
//set buttons array
|
||||||
cEnvironment->SetStaticObjectField(clsController, fidCButtons, (jbooleanArray) cButtonsReference);
|
cEnvironment->SetStaticObjectField(clsController, fidCButtons, cButtonsArray);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -529,10 +520,15 @@ void UpdateControllerFields() {
|
||||||
}
|
}
|
||||||
|
|
||||||
//buttons
|
//buttons
|
||||||
|
for (int i = 0; i < cButtoncount; i++) {
|
||||||
|
if (cJS.rgbButtons[i] != 0) {
|
||||||
|
cJS.rgbButtons[i] = JNI_TRUE;
|
||||||
|
} else {
|
||||||
|
cJS.rgbButtons[i] = JNI_FALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
jbooleanArray buttonsArray = (jbooleanArray) cEnvironment->GetStaticObjectField(clsController, fidCButtons);
|
jbooleanArray buttonsArray = (jbooleanArray) cEnvironment->GetStaticObjectField(clsController, fidCButtons);
|
||||||
BYTE * buttons = (BYTE *) cEnvironment->GetPrimitiveArrayCritical(buttonsArray, NULL);
|
cEnvironment->SetBooleanArrayRegion(buttonsArray, 0, cButtoncount, cJS.rgbButtons);
|
||||||
memcpy(buttons, cJS.rgbButtons, cButtoncount);
|
|
||||||
cEnvironment->ReleasePrimitiveArrayCritical(buttonsArray, buttons, 0);
|
|
||||||
|
|
||||||
//pov
|
//pov
|
||||||
if(cHaspov) {
|
if(cHaspov) {
|
||||||
|
|
Loading…
Reference in New Issue