diff options
author | endolf <[email protected]> | 2005-06-15 12:26:14 +0000 |
---|---|---|
committer | endolf <[email protected]> | 2005-06-15 12:26:14 +0000 |
commit | e874dcb39a62655c7db2f852a714b48e5dea1a48 (patch) | |
tree | 4d592b538918dd6f775889285af71a9edd9af9e6 | |
parent | eca14000fc8f385ad8d02b9e55c54df0d12edaa1 (diff) |
Unless otherwise specified (using the property), the plugin loader will
now automatically try and load the plugin specific to that platform. The
plugins path will be scanned first, and if found, the plugin will not be
reloaded.
git-svn-id: file:///home/sven/projects/JOGL/git-svn/svn-server-sync/jinput/trunk@97 e343933a-64c8-49c5-92b1-88f2ce3e89e8
-rw-r--r-- | coreAPI/src/java/net/java/games/input/DefaultControllerEnvironment.java | 29 |
1 files changed, 24 insertions, 5 deletions
diff --git a/coreAPI/src/java/net/java/games/input/DefaultControllerEnvironment.java b/coreAPI/src/java/net/java/games/input/DefaultControllerEnvironment.java index 5e8e358..92b9673 100644 --- a/coreAPI/src/java/net/java/games/input/DefaultControllerEnvironment.java +++ b/coreAPI/src/java/net/java/games/input/DefaultControllerEnvironment.java @@ -44,6 +44,7 @@ import java.io.IOException; import java.security.AccessController; import java.security.PrivilegedAction; import java.util.ArrayList; +import java.util.Collection; import java.util.Iterator; import java.util.Properties; import java.util.StringTokenizer; @@ -89,6 +90,8 @@ class DefaultControllerEnvironment extends ControllerEnvironment { * Plug-in class loader. */ private PluginClassLoader pluginLoader = new PluginClassLoader(); + + private Collection loadedPlugins = new ArrayList(); /** * Public no-arg constructor. @@ -111,15 +114,30 @@ class DefaultControllerEnvironment extends ControllerEnvironment { } }); //Check the properties for specified controller classes - String pluginClasses = System.getProperty("jinput.plugins", "") + System.getProperty("net.java.games.input.plugins", ""); + String pluginClasses = System.getProperty("jinput.plugins", "") + " " + System.getProperty("net.java.games.input.plugins", ""); + if(!System.getProperty("jinput.useDefaultPlugin", "true").toLowerCase().trim().equals("false") && !System.getProperty("net.java.games.input.useDefaultPlugin", "true").toLowerCase().trim().equals("false")) { + String osName = System.getProperty("os.name", "").trim(); + if(osName.equals("Linux")) { + pluginClasses = pluginClasses + "net.java.games.input.LinuxEnvironmentPlugin"; + } else if(osName.equals("Mac OS X")) { + pluginClasses = pluginClasses + "net.java.games.input.OSXEnvironmentPlugin"; + } else if(osName.equals("Windows 98") || osName.equals("Windows 2000") || osName.equals("Windows XP")) { + pluginClasses = pluginClasses + "net.java.games.input.DirectInputEnvironmentPlugin"; + } else { + System.out.println("Trying to use default plugin, OS name " + osName +" not recognised"); + } + } if(!pluginClasses.equals("")) { ArrayList pluginClassList = new ArrayList(); StringTokenizer pluginClassTok = new StringTokenizer(pluginClasses, " \t\n\r\f,;:"); while(pluginClassTok.hasMoreTokens()) { - String className = pluginClassTok.nextToken(); + String className = pluginClassTok.nextToken(); try { - ControllerEnvironment ce = (ControllerEnvironment) Class.forName(className).newInstance(); - addControllers(ce.getControllers()); + Class ceClass = Class.forName(className); + if(!loadedPlugins.contains(ceClass)) { + ControllerEnvironment ce = (ControllerEnvironment) ceClass.newInstance(); + addControllers(ce.getControllers()); + } } catch (InstantiationException e) { e.printStackTrace(); } catch (IllegalAccessException e) { @@ -206,8 +224,9 @@ class DefaultControllerEnvironment extends ControllerEnvironment { +" loaded by "+envClasses[i].getClassLoader()); } ControllerEnvironment ce = (ControllerEnvironment) - envClasses[i].newInstance(); + envClasses[i].newInstance(); addControllers(ce.getControllers()); + loadedPlugins.add(ce.getClass()); } catch (Exception e) { e.printStackTrace(); } |