bulk commit, since cvs server was down while fixing :/

fix: formatting got fucked
fix: multiple poll
fix: removed AquireInput method
This commit is contained in:
Brian Matzon 2002-11-18 06:16:12 +00:00
parent 5d596cd7c3
commit e2c8914168
1 changed files with 206 additions and 231 deletions

View File

@ -16,8 +16,7 @@
* * Neither the name of 'Light Weight Java Game Library' nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
@ -38,10 +37,9 @@
* @author Brian Matzon <brian@matzon.com>
* @version $Revision$
*/
#define WIN32_LEAN_AND_MEAN
#include "org_lwjgl_input_Joystick.h"
#include <windows.h>
#undef DIRECTINPUT_VERSION
#define DIRECTINPUT_VERSION 0x0500
@ -157,7 +155,17 @@ JNIEXPORT void JNICALL Java_org_lwjgl_input_Joystick_nDestroy(JNIEnv *env, jobje
* Signature: ()V
*/
JNIEXPORT void JNICALL Java_org_lwjgl_input_Joystick_nPoll(JNIEnv * env, jobject obj) {
lpDIDevice->Poll();
HRESULT hRes;
// poll the joystick to read the current state
hRes = lpDIDevice->Poll();
if (FAILED(hRes)) {
#if _DEBUG
printf("Poll fail\n");
#endif
return;
}
UpdateFields();
}
@ -311,30 +319,6 @@ void SetupJoystick() {
create_success = true;
}
/**
* Aquires the Joystick
*/
bool AcquireInput(void) {
HRESULT hRes;
// if we have a device
if (lpDIDevice != NULL) {
// acquire the device
hRes = lpDIDevice->Acquire();
if (SUCCEEDED(hRes)) {
// acquisition successful
return TRUE;
} else {
// acquisition failed
return FALSE;
}
} else {
// we don't have a current device
return FALSE;
}
}
/**
* Sets the fields on the Joystick
*/
@ -350,15 +334,6 @@ void InitializeFields() {
void UpdateFields() {
HRESULT hRes;
// poll the joystick to read the current state
hRes = lpDIDevice->Poll();
if (FAILED(hRes)) {
#if _DEBUG
printf("Poll fail\n");
#endif
return;
}
// get data from the joystick
hRes = lpDIDevice->GetDeviceState(sizeof(DIJOYSTATE2), &js);
@ -366,7 +341,7 @@ void UpdateFields() {
// did the read fail because we lost input for some reason?
// if so, then attempt to reacquire.
if(hRes == DIERR_INPUTLOST) {
AcquireInput();
lpDIDevice->Acquire();
#if _DEBUG
printf("DIERR_INPUTLOST, reaquiring input\n");
#endif