Ok, I have a deployable jinput webstart, but to do this I've had to introduce a bit of code and a property. There are no updates to JInput however.
I implemented a new Controller environment:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
| import net.java.games.input.ControllerEnvironment; import net.java.games.input.Controller;
import java.util.StringTokenizer; import java.util.ArrayList;
public class DirectControllerEnv extends ControllerEnvironment { public static final String PLUGINS_PROPERTY = "jinput.plugins"; private ControllerEnvironment defaultEnv = ControllerEnvironment.getDefaultEnvironment(); private Controller[] controllers; public DirectControllerEnv() { String plugins = System.getProperty(PLUGINS_PROPERTY); if ((plugins == null) || ("".equals(plugins))) { controllers = defaultEnv.getControllers(); } else { ArrayList trolls = new ArrayList(); addAll(defaultEnv.getControllers(),trolls); StringTokenizer classes = new StringTokenizer(plugins,","); while (classes.hasMoreTokens()) { String className = classes.nextToken(); ControllerEnvironment env; try { env = (ControllerEnvironment) Class.forName(className).newInstance(); } catch (Exception e) { System.err.println("Failed to instance environment"); continue; } addAll(env.getControllers(),trolls); } controllers = new Controller[trolls.size()]; for (int i=0;i<trolls.size();i++) { controllers[i] = (Controller) trolls.get(i); } } } private void addAll(Controller[] controls,ArrayList list) { for (int i=0;i<controls.length;i++) { System.out.println("Detected Controller: "+controls[i]); list.add(controls[i]); } } public Controller[] getControllers() { return controllers; } } |
This environment allows the developer of the application to specify plugins that he/she knows are going to be distributed with the app in a comma seperated class list property ("jinput.plugins").
These classes are instanced using the "context" class loader. The libraries likewise are loaded with the "context" class loader.
The DirectControllerEnv does also include any controllers found by the DefaultControllerEnvironment. This way, when running at the command line the controllers directory can be used as normal.
However, when distributing via webstart no user is going to have access to the "controller" directory (since it'll be hidden away in the webstart cache) so the only plugins that are going to be available will be the ones the developer distributes.
In the JNLP the property can be specified to point at the distributed plugins and the jars and native libraries for the plugins can be packaged just the same as any other webstart jars/libraries. So the JNLP looks a bit like this:
1 2 3 4 5 6 7
| <resources os="Windows"> <j2se href="http://java.sun.com/products/autodl/j2se" version="1.4+"/> <property name="jinput.plugins" value="net.java.games.input.DirectInputEnvironmentPlugin" /> <jar href="lib/jogl-win32.jar"/> <jar href="controller/dxinput.jar"/> <nativelib href="lib/dxinput-native.jar"/> </resources> |
For a full JNLP file that seems to be working check out
http://www.newdawnsoftware.com/martian/jnlp/martian.jnlp.example.txtKev
PS. For details on how to package stuff for web start I wrote this tutorial that I'm trying to get checked:
http://www.cokeandcode.com/info/webstart-howto.html