aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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;
}