Added sanity checks on reported controllers to prune out one with no Axis or no Buttons.

This commit is contained in:
Kevin Glass 2006-08-21 17:26:28 +00:00
parent 8ac762037f
commit b1a4935212
1 changed files with 13 additions and 0 deletions

View File

@ -71,6 +71,19 @@ public class Controllers {
net.java.games.input.Controller[] sub = c.getControllers();
if (sub.length == 0) {
JInputController controller = new JInputController(controllerCount,c);
// sanity checks to ensure we're actually getting game controllers rather than
// any old detected device
// if we've got no buttons at all we're not a game controller
if (controller.getButtonCount() == 0) {
return;
}
// if we've got no axis at all we're not a game controller
if (controller.getAxisCount() == 0) {
return;
}
controllers.add(controller);
controllerCount++;
} else {