aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorendolf <[email protected]>2005-08-27 08:21:42 +0000
committerendolf <[email protected]>2005-08-27 08:21:42 +0000
commit5a9dec8a916fc9d5e2d61c512904d24b6af0f307 (patch)
tree1e0214dbb541bb551d600c212098094bb2836894
parent11461384230f3aa88478e67902b65ecb5732e255 (diff)
Added shutdown hooks to stop rumblers before quitting.
git-svn-id: file:///home/sven/projects/JOGL/git-svn/svn-server-sync/jinput/trunk@109 e343933a-64c8-49c5-92b1-88f2ce3e89e8
-rw-r--r--plugins/DX8/src/java/net/java/games/input/DirectInputRumbler.java20
1 files changed, 20 insertions, 0 deletions
diff --git a/plugins/DX8/src/java/net/java/games/input/DirectInputRumbler.java b/plugins/DX8/src/java/net/java/games/input/DirectInputRumbler.java
index 5c02b24..d3fd283 100644
--- a/plugins/DX8/src/java/net/java/games/input/DirectInputRumbler.java
+++ b/plugins/DX8/src/java/net/java/games/input/DirectInputRumbler.java
@@ -54,6 +54,8 @@ public class DirectInputRumbler implements Rumbler {
this.effect = effect;
this.axisID = axisID;
this.axisName = axisName;
+
+ Runtime.getRuntime().addShutdownHook(new Thread(new ShutdownHook(this)));
}
/**
@@ -98,4 +100,22 @@ public class DirectInputRumbler implements Rumbler {
* @param intensity The intensity of the rumble
*/
private native void setRumble(long effect, float intensity);
+
+ private class ShutdownHook implements Runnable {
+ private DirectInputRumbler rumbler;
+ public ShutdownHook(DirectInputRumbler rumbler) {
+ this.rumbler = rumbler;
+ }
+
+ public void run() {
+ if(rumbler!=null) {
+ rumbler.rumble(0f);
+ try {
+ Thread.sleep(1000);
+ } catch (InterruptedException e) {
+ //Ignore, we are quitting anyway
+ }
+ }
+ }
+ }
}