From b1a493521256ba48dbe15635bd3e44e2c1d2a534 Mon Sep 17 00:00:00 2001 From: Kevin Glass Date: Mon, 21 Aug 2006 17:26:28 +0000 Subject: [PATCH] Added sanity checks on reported controllers to prune out one with no Axis or no Buttons. --- src/java/org/lwjgl/input/Controllers.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/java/org/lwjgl/input/Controllers.java b/src/java/org/lwjgl/input/Controllers.java index 9ab81cd2..49beb9e5 100644 --- a/src/java/org/lwjgl/input/Controllers.java +++ b/src/java/org/lwjgl/input/Controllers.java @@ -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 {