Added sanity checks on reported controllers to prune out one with no Axis or no Buttons.
This commit is contained in:
parent
8ac762037f
commit
b1a4935212
|
@ -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 {
|
||||
|
|
Loading…
Reference in New Issue