Windows: Cleanup of native input code
This commit is contained in:
parent
9e811f332a
commit
e99b357a1b
|
@ -69,12 +69,6 @@ JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Win32Display_createKeyboard
|
|||
return;
|
||||
}
|
||||
|
||||
// Check to see if we're already initialized
|
||||
if (lpdiKeyboard != NULL) {
|
||||
throwException(env, "Keyboard already created.");
|
||||
return;
|
||||
}
|
||||
|
||||
// Create a keyboard device
|
||||
if (IDirectInput_CreateDevice(lpdi, &GUID_SysKeyboard, &lpdiKeyboard, NULL) != DI_OK) {
|
||||
throwException(env, "Failed to create keyboard.");
|
||||
|
@ -140,31 +134,13 @@ JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Win32Display_destroyKeyboard
|
|||
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Win32Display_nPollKeyboard
|
||||
(JNIEnv * env, jobject self, jobject buffer)
|
||||
{
|
||||
HRESULT ret;
|
||||
void *keyboardBuffer;
|
||||
jlong buffer_size;
|
||||
do {
|
||||
ret = IDirectInputDevice_Acquire(lpdiKeyboard);
|
||||
if (ret == DIERR_INPUTLOST) {
|
||||
printf("Input lost\n");
|
||||
return;
|
||||
} else if (ret == DIERR_NOTACQUIRED) {
|
||||
printf("not acquired\n");
|
||||
return;
|
||||
} else if (ret == DIERR_INVALIDPARAM) {
|
||||
printf("invalid parameter\n");
|
||||
return;
|
||||
} else if (ret == DIERR_NOTBUFFERED) {
|
||||
printf("not buffered\n");
|
||||
return;
|
||||
} else if (ret == DIERR_NOTINITIALIZED) {
|
||||
printf("not inited\n");
|
||||
return;
|
||||
} else if (ret != DI_OK && ret != S_FALSE) {
|
||||
//printf("unknown keyboard error\n");
|
||||
HRESULT ret = IDirectInputDevice_Acquire(lpdiKeyboard);
|
||||
if (ret != DI_OK && ret != S_FALSE) {
|
||||
// printfDebugJava(env, "Failed to acquire keyboard (%x)\n", ret);
|
||||
return;
|
||||
}
|
||||
} while (ret != DI_OK && ret != S_FALSE);
|
||||
|
||||
keyboardBuffer = (void *)(*env)->GetDirectBufferAddress(env, buffer);
|
||||
buffer_size = (*env)->GetDirectBufferCapacity(env, buffer);
|
||||
|
|
|
@ -447,15 +447,6 @@ static BOOL CALLBACK EnumMouseObjectsCallback(LPCDIDEVICEOBJECTINSTANCE lpddoi,
|
|||
return DIENUM_CONTINUE;
|
||||
}
|
||||
|
||||
static int cap(int val, int min, int max) {
|
||||
if (val < min)
|
||||
return min;
|
||||
else if (val > max)
|
||||
return max;
|
||||
else
|
||||
return val;
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the fields on the Mouse
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue