Hi,
I'm trying to use JInput2 (
jinput_combined_dist_20060514) in an emulator project on Windows XP, but I'm currently experiencing some problems related to ControllerListeners : For some unknown reason, it seems that the ControllerListener I registered never get notified about added/removed controllers.
Moreover, the array returned by the getControllers() method is never updated (when I unplug a controller, it's still returned in this array, although the controller cannot be polled anymore - even if I plug it back )
For instance, when I run the following test case with, say, 2 controllers connected, then unplug one (or plug a new one), I get
"Available controllers count : 2" print once, and nothing else...
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
| import net.java.games.input.*;
public class TestListener { static public void main( String[] args ) { ControllerEnvironment env = ControllerEnvironment.getDefaultEnvironment();
env.addControllerListener( new ControllerListener() { public void controllerRemoved( ControllerEvent e ) { System.out.println("REMOVED"); } public void controllerAdded ( ControllerEvent e ) { System.out.println("ADDED" ); } });
int count = -1;
for(;;) { int update = env.getControllers().length; if (count != update) { count = update; System.out.println( "Available controllers count : " + count ); } try { Thread.sleep(200); } catch( InterruptedException e ) { } } } } |
Did I do something wrong?
Thanks!