Don't poll if we are shutting down

This commit is contained in:
endolf 2005-11-11 20:05:06 +00:00
parent db744e1d41
commit 819e59f33c
3 changed files with 18 additions and 2 deletions

View file

@ -142,6 +142,22 @@ public class JInputLibrary {
}
}
/** Call to poll the device at the native library
* @param deviceID The native device ID
* @param buttonData Array to populate with button values
* @param relAxesData Array to populate with relative axes values
* @param absAxesData Array to populate with absolute axes values
* @return the number of events read
*/
public static int safePoll(int deviceID, int buttonData[], int relAxesData[], int absAxesData[]) {
if(!shutdown) {
return poll(deviceID, buttonData, relAxesData, absAxesData);
}
return 0;
}
/** Get the name of a device from the native library
* @param deviceID The device id
* @return The devices name

View file

@ -493,7 +493,7 @@ public class LinuxDevice extends AbstractController {
* @return false if the controller is no longer valid.
*/
public boolean poll() {
int retval = JInputLibrary.poll(nativeID, buttonData, relAxesData, absAxesData);
int retval = JInputLibrary.safePoll(nativeID, buttonData, relAxesData, absAxesData);
if(retval>=0) return true;
return false;
}

View file

@ -115,7 +115,7 @@ public class LinuxKeyboard extends StandardKeyboard {
* @return False if this device is invalid.
*/
public boolean poll() {
int retval = JInputLibrary.poll(nativeID, keyData, dummyRelAxesData, dummyAbsAxesData);
int retval = JInputLibrary.safePoll(nativeID, keyData, dummyRelAxesData, dummyAbsAxesData);
if(retval>=0) return true;
return false;
}