I paste you my patch here :
Index: coreAPI/src/java/net/java/games/input/DefaultControllerEnvironment.java
===================================================================
--- coreAPI/src/java/net/java/games/input/DefaultControllerEnvironment.java (revision 247)
+++ coreAPI/src/java/net/java/games/input/DefaultControllerEnvironment.java (working copy)
@@ -169,6 +169,21 @@
e.printStackTrace();
}
}
+ } else {
+ controllers = new ArrayList();
+ for (Object ceName : loadedPlugins) {
+ try {
+ Class ceClass = Class.forName((String) ceName);
+ ControllerEnvironment ce = (ControllerEnvironment) ceClass.newInstance();
+ if (ce.isSupported()) {
+ addControllers(ce.getControllers());
+ } else {
+ logln(ceClass.getName() + " is not supported");
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
}
Controller[] ret = new Controller[controllers.size()];
Iterator it = controllers.iterator();
Index: plugins/windows/src/java/net/java/games/input/DirectInputEnvironmentPlugin.java
===================================================================
--- plugins/windows/src/java/net/java/games/input/DirectInputEnvironmentPlugin.java (revision 247)
+++ plugins/windows/src/java/net/java/games/input/DirectInputEnvironmentPlugin.java (working copy)
@@ -111,28 +111,20 @@
}
}
- private final Controller[] controllers;
+ private Controller[] controllers = new Controller[0];
private final List active_devices = new ArrayList();
private final DummyWindow window;
/** Creates new DirectInputEnvironment */
public DirectInputEnvironmentPlugin() {
DummyWindow window = null;
- Controller[] controllers = new Controller[]{};
if(isSupported()) {
try {
window = new DummyWindow();
- try {
- controllers = enumControllers(window);
- } catch (IOException e) {
- window.destroy();
- throw e;
- }
} catch (IOException e) {
logln("Failed to enumerate devices: " + e.getMessage());
}
this.window = window;
- this.controllers = controllers;
AccessController.doPrivileged(
new PrivilegedAction() {
public final Object run() {
@@ -144,12 +136,23 @@
// These are final fields, so can't set them, then over ride
// them if we are supported.
this.window = null;
- this.controllers = controllers;
}
}
public final Controller[] getControllers() {
- return controllers;
+ if (this.window != null) {
+ try {
+ try {
+ this.controllers = this.enumControllers(this.window);
+ } catch (IOException e) {
+ this.window.destroy();
+ throw e;
+ }
+ } catch (IOException e) {
+ logln("Failed to enumerate devices: " + e.getMessage());
+ }
+ }
+ return this.controllers;
}
private final Component[] createComponents(IDirectInputDevice device, boolean map_mouse_buttons) {
As you could see, I only upgrade DirectInputEnvironnementPlugin (and DefaultControllerEnvironnement ::))
May be you will need to change the implicit for-each for Java 1.4.
The patch works well for me. I suppose it could be applied to other platforms.