I’m having much trouble running JInput with a gamepad. When I call getControllers() it returns an empty array
following is my code:
[quote]/*
- Bestuuring.java
- Created on 12 mei 2005, 10:14
*/
package idp1;
import net.java.games.input.;
import net.java.games.util.plugins.;
/**
*
-
@author Groep15
*/
public class Bestuuring extends Thread {
private net.java.games.input.Controller gp;public Bestuuring() {
System.out.println(“bestuuring online”);
ControllerEnvironment ce = DirectInputEnvironmentPlugin.getDefaultEnvironment();
// retrieve the available controllers
net.java.games.input.Controller[] controllers = ce.getControllers(); //this gives an empty array
if (controllers.length == 0) {
System.out.println(“controllers == null”);
} else {
System.out.println(“controllers found”);
}
net.java.games.input.Controller c;
gp = null;
for (int i = 0; i < controllers.length; i++) {
c = controllers[i];
if(c.getType() == net.java.games.input.Controller.Type.GAMEPAD) { // c is a gamepad
gp = controllers[i];
}
}
}public void run() {
//not yet coded, no need because the constructor doesn’t work
}private void errorHandler(String message) {
Main.stuur.append(“e” + message); //works fine
}
}
[/quote]
I’m running on Windows XP with NetBeans 4 and J2sdk1.4.2
Could someone please give me some advice?
Grtz, Foppie