diff options
author | endolf <[email protected]> | 2003-12-02 18:55:13 +0000 |
---|---|---|
committer | endolf <[email protected]> | 2003-12-02 18:55:13 +0000 |
commit | 08739c125094ad6cb42cf466772994576896fa49 (patch) | |
tree | 6e4e08e2077a51235e99fba692b35982a6064845 | |
parent | c6a3dffe69834c25788c7dcef5e61360cb93e3c3 (diff) |
Updated rumblers to be able to get their axis name and axis identifier
git-svn-id: file:///home/sven/projects/JOGL/git-svn/svn-server-sync/jinput/trunk@64 e343933a-64c8-49c5-92b1-88f2ce3e89e8
5 files changed, 45 insertions, 5 deletions
diff --git a/coreAPI/src/java/net/java/games/input/Rumbler.java b/coreAPI/src/java/net/java/games/input/Rumbler.java index 2d4c8b8..9da084b 100644 --- a/coreAPI/src/java/net/java/games/input/Rumbler.java +++ b/coreAPI/src/java/net/java/games/input/Rumbler.java @@ -49,4 +49,19 @@ public interface Rumbler { */ public abstract void rumble(float intensity); + /** + * Get the string name of the axis the rumbler is attached to + * + * @return The axis name + */ + public String getAxisName(); + + /** + * Get the axis identifier the rumbler is attached to + * + * @return The axis identifier + */ + public Axis.Identifier getAxisIdentifier(); + + } // interface Rumbler diff --git a/coreAPI/src/java/net/java/games/input/test/RumbleTest.java b/coreAPI/src/java/net/java/games/input/test/RumbleTest.java index 706485b..64fe204 100644 --- a/coreAPI/src/java/net/java/games/input/test/RumbleTest.java +++ b/coreAPI/src/java/net/java/games/input/test/RumbleTest.java @@ -24,6 +24,7 @@ public class RumbleTest { Rumbler[] rumblers = controllers[i].getRumblers(); System.out.println("Found " + rumblers.length + " rumblers"); for(int j=0;j<rumblers.length;j++) { + System.out.println("Rumbler " + rumblers[j].getAxisName() + " on axis " + rumblers[j].getAxisIdentifier().getName()); System.out.println("Rumbling with intensity: " + 0.5f); rumblers[j].rumble(0.5f); try { @@ -36,6 +37,20 @@ public class RumbleTest { Thread.sleep(1000); } catch (InterruptedException e) { } + System.out.println("Fading rumble to -1"); + for(float k=1.0f;k>-1.0f;) { + long startTime = System.currentTimeMillis(); + rumblers[j].rumble(k); + try { + Thread.sleep(1); + } catch (InterruptedException e) { + } + k-=((float)(System.currentTimeMillis() - startTime))/1000f; + } + try { + Thread.sleep(1000); + } catch (InterruptedException e) { + } System.out.println("Rumbling with intensity: " + 0.0f); rumblers[j].rumble(0f); try { diff --git a/plugins/DX8/src/java/net/java/games/input/DirectInputDevice.java b/plugins/DX8/src/java/net/java/games/input/DirectInputDevice.java index 993ab93..d269961 100644 --- a/plugins/DX8/src/java/net/java/games/input/DirectInputDevice.java +++ b/plugins/DX8/src/java/net/java/games/input/DirectInputDevice.java @@ -159,8 +159,8 @@ class DirectInputDevice extends AbstractController { * @param effect the natie effect id * @param axisID The axis ID */ - private void addRumbler(long effect, Axis.Identifier axisID) { - rumblerList.add(new DirectInputRumbler(this, effect, axisID)); + private void addRumbler(long effect, Axis.Identifier axisID, String axisName) { + rumblerList.add(new DirectInputRumbler(this, effect, axisID, axisName)); } /** Polls axes for data. Returns false if the controller is no longer valid. 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 de04724..f0ae3d0 100644 --- a/plugins/DX8/src/java/net/java/games/input/DirectInputRumbler.java +++ b/plugins/DX8/src/java/net/java/games/input/DirectInputRumbler.java @@ -15,12 +15,22 @@ public class DirectInputRumbler implements net.java.games.input.Rumbler { private DirectInputDevice device; private long effect; private Axis.Identifier axisID; + private String axisName; /** Creates a new instance of DirectInputRumbler */ - public DirectInputRumbler(DirectInputDevice device, long effect, Axis.Identifier axisID) { + public DirectInputRumbler(DirectInputDevice device, long effect, Axis.Identifier axisID, String axisName) { this.device = device; this.effect = effect; this.axisID = axisID; + this.axisName = axisName; + } + + public Axis.Identifier getAxisIdentifier() { + return axisID; + } + + public String getAxisName() { + return axisName; } public void rumble(float intensity) { diff --git a/plugins/DX8/src/native/input.cpp b/plugins/DX8/src/native/input.cpp index 9fe577b..20493f1 100644 --- a/plugins/DX8/src/native/input.cpp +++ b/plugins/DX8/src/native/input.cpp @@ -263,7 +263,7 @@ BOOL InitIDs(JNIEnv* env) { return FALSE; } MID_AddRumbler = env->GetMethodID(CLASS_DirectInputDevice, "addRumbler", - "(JLnet/java/games/input/Axis$Identifier;)V"); + "(JLnet/java/games/input/Axis$Identifier;Ljava/lang/String;)V"); if (MID_AddRumbler == NULL) { return FALSE; } @@ -700,7 +700,7 @@ BOOL CALLBACK EnumObjectsCallback(LPCDIDEVICEOBJECTINSTANCE lpddoi, return res; } - env->CallVoidMethod(obj, MID_AddRumbler, (jlong)(long)g_pEffect, identifier); + env->CallVoidMethod(obj, MID_AddRumbler, (jlong)(long)g_pEffect, identifier, name); } return DIENUM_CONTINUE; } |