aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/DX8
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/DX8')
-rw-r--r--plugins/DX8/build.xml2
-rw-r--r--plugins/DX8/src/java/net/java/games/input/DirectInputAxis.java48
-rw-r--r--plugins/DX8/src/java/net/java/games/input/DirectInputDevice.java15
-rw-r--r--plugins/DX8/src/java/net/java/games/input/DirectInputEnvironmentPlugin.java23
-rw-r--r--plugins/DX8/src/java/net/java/games/input/DirectInputKeyboard.java10
-rw-r--r--plugins/DX8/src/java/net/java/games/input/DirectInputMouse.java58
-rw-r--r--plugins/DX8/src/java/net/java/games/input/DirectInputRumbler.java6
-rw-r--r--plugins/DX8/src/native/input.cpp18
8 files changed, 97 insertions, 83 deletions
diff --git a/plugins/DX8/build.xml b/plugins/DX8/build.xml
index 0a4759b..ef20e6f 100644
--- a/plugins/DX8/build.xml
+++ b/plugins/DX8/build.xml
@@ -96,7 +96,7 @@
<delete file="bin/dxinput.jar" failonerror="no"/>
<delete file="bin/dxinput.dll" failonerror="no"/>
<delete file="../../coreAPI/src/tests/controller/dxinput.jar" failonerror="no" />
- <delete file="../../coreAPI/src/test/controller/dxinput.dll" failonerror="no"/>
+ <delete file="../../coreAPI/src/tests/controller/dxinput.dll" failonerror="no"/>
<delete dir="../../docs/input/win32/apidoc" failonerror="no"/>
</target>
diff --git a/plugins/DX8/src/java/net/java/games/input/DirectInputAxis.java b/plugins/DX8/src/java/net/java/games/input/DirectInputAxis.java
index e9cfc6e..a09267d 100644
--- a/plugins/DX8/src/java/net/java/games/input/DirectInputAxis.java
+++ b/plugins/DX8/src/java/net/java/games/input/DirectInputAxis.java
@@ -38,15 +38,15 @@
*****************************************************************************/
package net.java.games.input;
-import net.java.games.input.AbstractAxis;
-import net.java.games.input.Axis;
+import net.java.games.input.AbstractComponent;
+import net.java.games.input.Component;
/**
*
* @author martak
* @version
*/
-class DirectInputAxis extends AbstractAxis {
+class DirectInputAxis extends AbstractComponent {
/**
* DIDFT_ constants and macros defined in dinput.h
@@ -106,31 +106,31 @@ class DirectInputAxis extends AbstractAxis {
private int bitmask = 0xffffffff;
private int bitshift = 0;
- private DirectInputAxis(DirectInputDevice device, Axis.Identifier id,
+ private DirectInputAxis(DirectInputDevice device, Component.Identifier id,
int didft, String name) {
super(name, id);
this.device = device;
this.type = DIDFT_GETTYPE(didft);
this.instance = DIDFT_GETINSTANCE(didft);
- if (id == Axis.Identifier.X) {
+ if (id == Component.Identifier.Axis.X) {
offset = 0;
- } else if (id == Axis.Identifier.Y) {
+ } else if (id == Component.Identifier.Axis.Y) {
offset = 1;
- } else if (id == Axis.Identifier.Z) {
+ } else if (id == Component.Identifier.Axis.Z) {
offset = 2;
- } else if (id == Axis.Identifier.RX) {
+ } else if (id == Component.Identifier.Axis.RX) {
offset = 3;
- } else if (id == Axis.Identifier.RY) {
+ } else if (id == Component.Identifier.Axis.RY) {
offset = 4;
- } else if (id == Axis.Identifier.RZ) {
+ } else if (id == Component.Identifier.Axis.RZ) {
offset = 5;
- } else if (id == Axis.Identifier.SLIDER) {
+ } else if (id == Component.Identifier.Axis.SLIDER) {
//System.out.println("Slider on "+name+" instance = "+instance);
offset = 6 + (instance>>2);
- } else if (id == Axis.Identifier.POV) {
+ } else if (id == Component.Identifier.Axis.POV) {
//System.out.println("POV on "+name+" instance = "+instance);
offset = 8 + instance;
- } else if (id == Axis.Identifier.BUTTON) {
+ } else if (id instanceof Component.Identifier.Button) {
//System.out.println("Button on "+name+" instance = "+instance);
offset = 12 + (instance/4);
bitshift = (instance%4)*8;
@@ -152,26 +152,26 @@ class DirectInputAxis extends AbstractAxis {
return ((float)data)/32768;
} else if ((type&DIDFT_POV)!=0) {
if (data == -1) {
- return Axis.POV.OFF;
+ return Component.POV.OFF;
} else if (data == 0.0) {
- return Axis.POV.UP;
+ return Component.POV.UP;
} else if (data == 4500) {
- return Axis.POV.UP_RIGHT;
+ return Component.POV.UP_RIGHT;
} else if (data == 9000) {
- return Axis.POV.RIGHT;
+ return Component.POV.RIGHT;
} else if (data == 13500) {
- return Axis.POV.DOWN_RIGHT;
+ return Component.POV.DOWN_RIGHT;
} else if (data == 18000) {
- return Axis.POV.DOWN;
+ return Component.POV.DOWN;
} else if (data == 22500) {
- return Axis.POV.DOWN_LEFT;
+ return Component.POV.DOWN_LEFT;
} else if (data == 27000) {
- return Axis.POV.LEFT;
+ return Component.POV.LEFT;
} else if (data == 31500) {
- return Axis.POV.UP_LEFT;
+ return Component.POV.UP_LEFT;
} else {
System.err.print("Unexpected value for DX8 HAT: "+data);
- return Axis.POV.OFF;
+ return Component.POV.OFF;
}
} else { // return raw value
return (float)data;
@@ -213,7 +213,7 @@ class DirectInputAxis extends AbstractAxis {
* @param id The identifier for the device
*/
public static DirectInputAxis createAxis(DirectInputDevice device,
- Axis.Identifier id, int didft, String name) {
+ Component.Identifier id, int didft, String name) {
return new DirectInputAxis(device, id, didft, name);
}
}
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 d269961..849a5f1 100644
--- a/plugins/DX8/src/java/net/java/games/input/DirectInputDevice.java
+++ b/plugins/DX8/src/java/net/java/games/input/DirectInputDevice.java
@@ -39,8 +39,7 @@
package net.java.games.input;
import net.java.games.input.AbstractController;
-import net.java.games.input.Axis;
-import net.java.games.input.Controller;
+import net.java.games.input.Component;
import java.util.ArrayList;
import java.util.Iterator;
@@ -120,21 +119,21 @@ class DirectInputDevice extends AbstractController {
default:
type = Type.STICK; break;
}
- axes = initDirectInputAxes();
+ components = initDirectInputAxes();
}
/**
* Used instead of overriding initAxes because it needs the
* pointer to the IDirectInputDevice
*/
- private Axis[] initDirectInputAxes() {
+ private Component[] initDirectInputAxes() {
ArrayList list = new ArrayList();
enumObjects(lpDevice, list);
- Axis[] ret = new Axis[list.size()];
+ Component[] ret = new Component[list.size()];
Iterator it = list.iterator();
int i = 0;
while (it.hasNext()) {
- ret[i] = (Axis)it.next();
+ ret[i] = (Component)it.next();
i++;
}
return ret;
@@ -148,7 +147,7 @@ class DirectInputDevice extends AbstractController {
* instance number of the axis.
* @param name The name to call the axis.
*/
- private void addAxis(ArrayList list, Axis.Identifier id, int didft,
+ private void addAxis(ArrayList list, Component.Identifier id, int didft,
String name) {
list.add(DirectInputAxis.createAxis(this, id, didft, name));
}
@@ -159,7 +158,7 @@ class DirectInputDevice extends AbstractController {
* @param effect the natie effect id
* @param axisID The axis ID
*/
- private void addRumbler(long effect, Axis.Identifier axisID, String axisName) {
+ private void addRumbler(long effect, Component.Identifier axisID, String axisName) {
rumblerList.add(new DirectInputRumbler(this, effect, axisID, axisName));
}
diff --git a/plugins/DX8/src/java/net/java/games/input/DirectInputEnvironmentPlugin.java b/plugins/DX8/src/java/net/java/games/input/DirectInputEnvironmentPlugin.java
index fcaa278..4b3c95d 100644
--- a/plugins/DX8/src/java/net/java/games/input/DirectInputEnvironmentPlugin.java
+++ b/plugins/DX8/src/java/net/java/games/input/DirectInputEnvironmentPlugin.java
@@ -38,7 +38,6 @@
*****************************************************************************/
package net.java.games.input;
-import java.security.AccessController;
import java.util.ArrayList;
import java.util.Iterator;
import net.java.games.input.Controller;
@@ -59,7 +58,9 @@ public class DirectInputEnvironmentPlugin extends ControllerEnvironment
java.security.AccessController.doPrivileged(
new LoadLibraryAction("jinput"));
*/
- System.loadLibrary("dxinput");
+ if(isSupported()) {
+ System.loadLibrary("dxinput");
+ }
}
/**
@@ -109,8 +110,22 @@ public class DirectInputEnvironmentPlugin extends ControllerEnvironment
/** Creates new DirectInputEnvironment */
public DirectInputEnvironmentPlugin() {
- lpDirectInput = directInputCreate();
- enumControllers();
+ if(isSupported()) {
+ lpDirectInput = directInputCreate();
+ enumControllers();
+ } else {
+ controllers = new Controller[0];
+ }
+ }
+
+ public static boolean isSupported() {
+ System.out.println("OS name is: " + System.getProperty("os.name"));
+ if(System.getProperty("os.name").indexOf("Windows")!=-1) {
+ System.out.println("DX8 plugin is supported");
+ return true;
+ }
+ System.out.println("DX8 plugin is not supported");
+ return false;
}
/** Returns a list of all controllers available to this environment,
diff --git a/plugins/DX8/src/java/net/java/games/input/DirectInputKeyboard.java b/plugins/DX8/src/java/net/java/games/input/DirectInputKeyboard.java
index 6faf163..9b5833c 100644
--- a/plugins/DX8/src/java/net/java/games/input/DirectInputKeyboard.java
+++ b/plugins/DX8/src/java/net/java/games/input/DirectInputKeyboard.java
@@ -38,8 +38,8 @@
*****************************************************************************/
package net.java.games.input;
-import net.java.games.input.AbstractAxis;
-import net.java.games.input.Axis;
+import net.java.games.input.AbstractComponent;
+import net.java.games.input.Component;
import net.java.games.input.StandardKeyboard;
/**
@@ -143,8 +143,8 @@ class DirectInputKeyboard extends StandardKeyboard {
for (; CROSSTABLE[keyIndex] > index; keyIndex--)
;
if (CROSSTABLE[keyIndex] == index) {
- Axis[] axes = getAxes();
- AbstractAxis key = (AbstractAxis)axes[index];
+ Component[] components = getComponents();
+ AbstractComponent key = (AbstractComponent)components[index];
if (name != null && name.length() > 0) {
//System.out.println("Renaming key " + key.getName() +
// " to " + name + " index=" +
@@ -173,7 +173,7 @@ class DirectInputKeyboard extends StandardKeyboard {
* @return true if this key has changed state since last read of its state, false otherwise.
*/
protected boolean isKeyPressed(Key key) {
- KeyID id = (KeyID)key.getIdentifier();
+ Component.Identifier.Key id = (Component.Identifier.Key)key.getIdentifier();
int keyIndex = id.getKeyIndex();
int crossIndex = CROSSTABLE[keyIndex];
return ((keyData[crossIndex] & 0x80) != 0);
diff --git a/plugins/DX8/src/java/net/java/games/input/DirectInputMouse.java b/plugins/DX8/src/java/net/java/games/input/DirectInputMouse.java
index 7241414..4d9e257 100644
--- a/plugins/DX8/src/java/net/java/games/input/DirectInputMouse.java
+++ b/plugins/DX8/src/java/net/java/games/input/DirectInputMouse.java
@@ -38,8 +38,8 @@
*****************************************************************************/
package net.java.games.input;
-import net.java.games.input.AbstractAxis;
-import net.java.games.input.Axis;
+import net.java.games.input.AbstractComponent;
+import net.java.games.input.Component;
import net.java.games.input.Mouse;
/**
@@ -105,12 +105,12 @@ class DirectInputMouse extends Mouse {
/**
* Callback to rename a given axis by type, name
*/
- private void renameAxis(Axis.Identifier id, String name) {
- AbstractAxis axis;
- if (id instanceof ButtonID) {
- axis = (AbstractAxis)getButtons().getAxis(id);
+ private void renameAxis(Component.Identifier id, String name) {
+ AbstractComponent axis;
+ if (id instanceof Component.Identifier.Button) {
+ axis = (AbstractComponent)getButtons().getComponent(id);
} else {
- axis = (AbstractAxis)getBall().getAxis(id);
+ axis = (AbstractComponent)getBall().getComponent(id);
}
axis.setName(name);
//System.out.println("Renaming " + name);
@@ -160,10 +160,10 @@ class DirectInputMouse extends Mouse {
public BallImpl() {
super(DirectInputMouse.this.getName() + " ball");
numAxes = getNumAxes(lpDevice);
- x = new BallAxis(Axis.Identifier.X);
- y = new BallAxis(Axis.Identifier.Y);
+ x = new BallAxis(Component.Identifier.Axis.X);
+ y = new BallAxis(Component.Identifier.Axis.Y);
if(numAxes > 2) {
- wheel = new BallAxis(Axis.Identifier.SLIDER);
+ wheel = new BallAxis(Component.Identifier.Axis.SLIDER);
}
}
} // class DirectInputMouse.BallImpl
@@ -181,22 +181,22 @@ class DirectInputMouse extends Mouse {
public ButtonsImpl() {
super(DirectInputMouse.this.getName() + " buttons");
numButtons = getNumButtons(lpDevice);
- left = new ButtonImpl(ButtonID.LEFT);
- right = new ButtonImpl(ButtonID.RIGHT);
+ left = new ButtonImpl(Component.Identifier.Button.LEFT);
+ right = new ButtonImpl(Component.Identifier.Button.RIGHT);
if(numButtons>2) {
- middle = new ButtonImpl(ButtonID.MIDDLE);
+ middle = new ButtonImpl(Component.Identifier.Button.MIDDLE);
}
if(numButtons>3) {
- side = new ButtonImpl(ButtonID.SIDE);
+ side = new ButtonImpl(Component.Identifier.Button.SIDE);
}
if(numButtons>4) {
- extra = new ButtonImpl(ButtonID.EXTRA);
+ extra = new ButtonImpl(Component.Identifier.Button.EXTRA);
}
if(numButtons>5) {
- forward = new ButtonImpl(ButtonID.FORWARD);
+ forward = new ButtonImpl(Component.Identifier.Button.FORWARD);
}
if(numButtons>6) {
- back = new ButtonImpl(ButtonID.BACK);
+ back = new ButtonImpl(Component.Identifier.Button.BACK);
}
}
} // class DirectInputMouse.ButtonsImpl
@@ -235,21 +235,21 @@ class DirectInputMouse extends Mouse {
* @param id An ID of a button to create an obejct to represent.
*
*/
- public ButtonImpl(ButtonID id) {
+ public ButtonImpl(Component.Identifier.Button id) {
super(id.getName(), id);
- if (id == ButtonID.LEFT) {
+ if (id == Component.Identifier.Button.LEFT) {
index = 12;
- } else if (id == ButtonID.RIGHT) {
+ } else if (id == Component.Identifier.Button.RIGHT) {
index = 13;
- } else if (id == ButtonID.MIDDLE) {
+ } else if (id == Component.Identifier.Button.MIDDLE) {
index = 14;
- } else if (id == ButtonID.SIDE) {
+ } else if (id == Component.Identifier.Button.SIDE) {
index = 15;
- } else if (id == ButtonID.EXTRA) {
+ } else if (id == Component.Identifier.Button.EXTRA) {
index = 16;
- } else if (id == ButtonID.FORWARD) {
+ } else if (id == Component.Identifier.Button.FORWARD) {
index = 17;
- } else if (id == ButtonID.BACK) {
+ } else if (id == Component.Identifier.Button.BACK) {
index = 18;
} else {
throw new RuntimeException("Unknown button");
@@ -287,7 +287,7 @@ class DirectInputMouse extends Mouse {
/**
* Mouse ball axis implementation
*/
- class BallAxis extends AbstractAxis {
+ class BallAxis extends AbstractComponent {
/**
* Starting index into the mouseData array
@@ -299,11 +299,11 @@ class DirectInputMouse extends Mouse {
*/
public BallAxis(Identifier id) {
super(id.getName(), id);
- if (id == Identifier.X) {
+ if (id == Identifier.Axis.X) {
index = 0;
- } else if (id == Identifier.Y) {
+ } else if (id == Identifier.Axis.Y) {
index = 4;
- } else if (id == Identifier.SLIDER) {
+ } else if (id == Identifier.Axis.SLIDER) {
index = 8;
} else {
throw new RuntimeException("Unknown mouse axis");
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 444bf02..5c02b24 100644
--- a/plugins/DX8/src/java/net/java/games/input/DirectInputRumbler.java
+++ b/plugins/DX8/src/java/net/java/games/input/DirectInputRumbler.java
@@ -37,7 +37,7 @@ public class DirectInputRumbler implements Rumbler {
/** The native effect */
private long effect;
/** The identifier of the axis we are attached too */
- private Axis.Identifier axisID;
+ private Component.Identifier axisID;
/** The name of the axis this rumbler is attached too */
private String axisName;
@@ -49,7 +49,7 @@ public class DirectInputRumbler implements Rumbler {
* @param axisID The id of the axis this rumbler is attached too
* @param axisName The name of the axis this rumbler is attached too
*/
- public DirectInputRumbler(DirectInputDevice device, long effect, Axis.Identifier axisID, String axisName) {
+ public DirectInputRumbler(DirectInputDevice device, long effect, Component.Identifier axisID, String axisName) {
this.device = device;
this.effect = effect;
this.axisID = axisID;
@@ -61,7 +61,7 @@ public class DirectInputRumbler implements Rumbler {
*
* @return The axis id
*/
- public Axis.Identifier getAxisIdentifier() {
+ public Component.Identifier getAxisIdentifier() {
return axisID;
}
diff --git a/plugins/DX8/src/native/input.cpp b/plugins/DX8/src/native/input.cpp
index c4eb7af..188c439 100644
--- a/plugins/DX8/src/native/input.cpp
+++ b/plugins/DX8/src/native/input.cpp
@@ -49,8 +49,8 @@ jfieldID FID_Side = NULL;
jfieldID FID_Forward = NULL;
jfieldID FID_Back = NULL;
-const char* FD_AxisIdentifier = "Lnet/java/games/input/Axis$Identifier;";
-const char* FD_ButtonIdentifier = "Lnet/java/games/input/Mouse$ButtonID;";
+const char* FD_AxisIdentifier = "Lnet/java/games/input/Component$Identifier$Axis;";
+const char* FD_ButtonIdentifier = "Lnet/java/games/input/Component$Identifier$Button;";
// Dummy input window. This is needed because DirectX evidently needs a window
// to do anything, such as setting the cooperative level for a device.
const TCHAR* DUMMY_WINDOW_NAME = "InputControllerWindow";
@@ -151,7 +151,7 @@ break;
*/
BOOL InitIDs(JNIEnv* env) {
CLASS_AxisIdentifier =
- env->FindClass("net/java/games/input/Axis$Identifier");
+ env->FindClass("net/java/games/input/Component$Identifier$Axis");
if (CLASS_AxisIdentifier == NULL) {
return FALSE;
}
@@ -190,18 +190,18 @@ BOOL InitIDs(JNIEnv* env) {
if (FID_Slider == NULL) {
return FALSE;
}
- FID_Button = env->GetStaticFieldID(CLASS_AxisIdentifier, "BUTTON",
+/* FID_Button = env->GetStaticFieldID(CLASS_AxisIdentifier, "BUTTON",
FD_AxisIdentifier);
if (FID_Button == NULL) {
return FALSE;
- }
+ }*/
FID_POV = env->GetStaticFieldID(CLASS_AxisIdentifier, "POV",
FD_AxisIdentifier);
if (FID_POV == NULL) {
return FALSE;
}
CLASS_ButtonIdentifier =
- env->FindClass("net/java/games/input/Mouse$ButtonID");
+ env->FindClass("net/java/games/input/Component$Identifier$Button");
if (CLASS_ButtonIdentifier == NULL) {
return FALSE;
}
@@ -258,12 +258,12 @@ BOOL InitIDs(JNIEnv* env) {
return FALSE;
}
MID_AddAxis = env->GetMethodID(CLASS_DirectInputDevice, "addAxis",
- "(Ljava/util/ArrayList;Lnet/java/games/input/Axis$Identifier;ILjava/lang/String;)V");
+ "(Ljava/util/ArrayList;Lnet/java/games/input/Component$Identifier;ILjava/lang/String;)V");
if (MID_AddAxis == NULL) {
return FALSE;
}
MID_AddRumbler = env->GetMethodID(CLASS_DirectInputDevice, "addRumbler",
- "(JLnet/java/games/input/Axis$Identifier;Ljava/lang/String;)V");
+ "(JLnet/java/games/input/Component$Identifier;Ljava/lang/String;)V");
if (MID_AddRumbler == NULL) {
return FALSE;
}
@@ -283,7 +283,7 @@ BOOL InitIDs(JNIEnv* env) {
return FALSE;
}
MID_RenameAxis = env->GetMethodID(CLASS_DirectInputMouse, "renameAxis",
- "(Lnet/java/games/input/Axis$Identifier;Ljava/lang/String;)V");
+ "(Lnet/java/games/input/Component$Identifier;Ljava/lang/String;)V");
if (MID_RenameAxis == NULL) {
return FALSE;
}