|
From: <kev...@us...> - 2006-08-21 17:26:34
|
Revision: 2561 Author: kevglass Date: 2006-08-21 10:26:28 -0700 (Mon, 21 Aug 2006) ViewCVS: http://svn.sourceforge.net/java-game-lib/?rev=2561&view=rev Log Message: ----------- Added sanity checks on reported controllers to prune out one with no Axis or no Buttons. Modified Paths: -------------- trunk/LWJGL/src/java/org/lwjgl/input/Controllers.java Modified: trunk/LWJGL/src/java/org/lwjgl/input/Controllers.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/input/Controllers.java 2006-08-21 17:25:49 UTC (rev 2560) +++ trunk/LWJGL/src/java/org/lwjgl/input/Controllers.java 2006-08-21 17:26:28 UTC (rev 2561) @@ -71,6 +71,19 @@ 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 { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |