aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorendolf <[email protected]>2005-11-11 20:05:06 +0000
committerendolf <[email protected]>2005-11-11 20:05:06 +0000
commit72073ff6a943d89b477cbfea0949e1e4b36eebc1 (patch)
tree33c3099c8c3cc4dfc657db589d74072f2fc8153a
parent5a1e5dec0a64fb74b7ccfb74992cd6c3293e2410 (diff)
Don't poll if we are shutting down
git-svn-id: file:///home/sven/projects/JOGL/git-svn/svn-server-sync/jinput/trunk@130 e343933a-64c8-49c5-92b1-88f2ce3e89e8
-rw-r--r--plugins/linux/src/java/net/java/games/input/JInputLibrary.java16
-rw-r--r--plugins/linux/src/java/net/java/games/input/LinuxDevice.java2
-rw-r--r--plugins/linux/src/java/net/java/games/input/LinuxKeyboard.java2
3 files changed, 18 insertions, 2 deletions
diff --git a/plugins/linux/src/java/net/java/games/input/JInputLibrary.java b/plugins/linux/src/java/net/java/games/input/JInputLibrary.java
index dbfda64..57dbf07 100644
--- a/plugins/linux/src/java/net/java/games/input/JInputLibrary.java
+++ b/plugins/linux/src/java/net/java/games/input/JInputLibrary.java
@@ -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
diff --git a/plugins/linux/src/java/net/java/games/input/LinuxDevice.java b/plugins/linux/src/java/net/java/games/input/LinuxDevice.java
index a475643..4f7c559 100644
--- a/plugins/linux/src/java/net/java/games/input/LinuxDevice.java
+++ b/plugins/linux/src/java/net/java/games/input/LinuxDevice.java
@@ -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;
}
diff --git a/plugins/linux/src/java/net/java/games/input/LinuxKeyboard.java b/plugins/linux/src/java/net/java/games/input/LinuxKeyboard.java
index 7c16343..4ea1c47 100644
--- a/plugins/linux/src/java/net/java/games/input/LinuxKeyboard.java
+++ b/plugins/linux/src/java/net/java/games/input/LinuxKeyboard.java
@@ -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;
}