The usual samples show a code fragment like this:
1 2 3 4 5 6 7 8
| Controller[] controllers = driver.getKnownControllers(); while(true) { for (Controller ctl : controllers) { ctl.poll(); EventQueue queue = ctl.getEventQueue(); } } |
Which works great in my testing.
But by placing the getKnownControllers() outside of the infinite loop, you will not detect any changes. The user could plug in a new controller, or even swap one for another, and the sample code will not detect it.
Is this a reasonable restriction? Is it acceptable to use this design? or should the main loop also check occasionally for new controllers?