This posts gets longer and longer. Here is a short summary what it includes:
[]an introduction on how to setup and program with JInput
[]a link to another tutorial with code examples and such
[]links to my jinput plugin for linux
[]link to my JInputTester application (JNLP!)
By popular request and since I have been using JInput for some time now I decided to give the API a better reputation by providing some introductory information.
A couple of times I read that people were unable to get JInput running. They often missed the point of the so called plugins and wondered that there are no devices. My first post will handle these basics:
General:
JInput consists of two parts. One part is JInput itself. It is a jar named jinput.jar containing all the public classes and interfaces needed to write an application. JInput depends on JUtils (jutils.jar) which can be found on java.net too. These 2 jars have to be in your application’s classpath. there are several ways to accomplish this and I hope you know at least one. If you feel unfamiliar with that read the tutorial at java.sun.com.
The other part is called the plugin. A plugin is automatically recognized by jinput when invoking a special method - the only thing you should care about a plugin is to put the files in the right folder. And here is how that goes …
Installation of the plugin(s):
Nearly all plugins consist of two files. One of them is the native library (e.g. dxinput.dll, libjinput.so) and the other one is the java part of the plugin (any official name for that?). There are multiple ways for installing a plugin:
-
the easiest but most (system) polluting way:
create a folder named ‘controller’ inside your ${jre.home}/lib/ext folder and copy the two files in. -
the application specific way:
assume we have an application using jinput. the application’s jar is named foo.jar and is in a folder named foo-dir. for installing the plugin for this application only, create a folder named ‘controller’ inside foo-dir and copy the 2 files in. afterwards start the application from a console with ‘java -jar foo.jar’. be sure that you are inside foo-dir when doing this.
applicable to 1) and 2): it is better to put two 2 files making up a plugin in a subdirectory of its own. this particular topic was discussed here: http://www.java-gaming.org/cgi-bin/JGNetForums/YaBB.cgi?board=jinput;action=display;num=1084179275
- the system property - way of the JNLP app or the developer
Since JNLP (popular as Java Webstart) has some restrictions on how native libaries are handled, JInput provides a simple way to access the plugin (and yes: only one plugin) through the classpath.
at first make sure the plugin’s jar is in the classpath.
second: make sure the native library is in ${java.library.path} (depending on platform and if you’re using JNLP - refer to java.sun.com they explain everything in detail there).
After that set the system property jinput.plugins to the name of the main plugin class. You can find out that name using your favorite zip tool, opening the plugin jar file and look for a file like XYZEnvironmentPlugin(.class). on the command-line you can set the system property using the -D parameter.
For convenience here is a list of known classes:
[tr]
[td]Windows and DirectInput based plugin[/td]
[td]net.java.games.input.DirectInputEnvironmentPlugin[/td]
[/tr]
[tr]
[td]Linux and Kernel Event Interface based plugin by endolf[/td]
[td]net.java.games.input.LinuxEnvironmentPlugin[/td]
[/tr]
[tr]
[td]Mac OS X and HID based Plugin[/td]
[td]net.java.games.input.OSXEnvironmentPlugin[/td]
[/tr]
[tr]
[td]Linux and Kernel Event Interface based plugin by theBohemian[/td]
[td]de.bitecode.input.linux.LinuxInputEnvironmentPlugin[/td]
[/tr]
Considerations:
-
do not program ‘by hand’. download a modern ide like netbeans or eclipse. they handle the classpath conveniently and you can set system properties through dialogs instead of the command-line (although way 2 may be difficult with an IDE).
-
I have not written JInput or JUtils. That means there may be mistakes in the stuff above.
I have to go to bed now but if people find my explanations above useful I will write another long post - containing more programming stuff.
Please comment on wrong points or stuff that was explained bad or such.
Another tutorial by me which includes some programming examples can be found here: [url]https://freefodder.dev.java.net/tutorial/jinputTutorialOne.html[/url]
My very own implementation of the linux based JInput plugin:
binary:
http://www.inf.fu-berlin.de/~rschuste/java/linux-eventinterface-jinput-plugin-0.1-bin.zip
source:
http://www.inf.fu-berlin.de/~rschuste/java/linux-eventinterface-jinput-plugin-0.1-src.zip
A long time ago (last year?) I have writen a Swing-based test application for JInput. It is now available via JNLP (eg. Java Webstart) again and should work on Windows and Linux for now. I am going to add MacOS support for it soon.
JNLP: http://www.inf.fu-berlin.de/~rschuste/java/jinputtester/jinputtester.jnlp
source code:
http://www.inf.fu-berlin.de/~rschuste/java/jinputtester/jinputtester-1.0.0-src.zip
The application is Free software and licensed under the GPL.
– EDIT: highlighted the part which kaffiene mentioned
– EDIT: added link to the next tutorial
– EDIT: added link to my own plugin
– EDIT - 09.16.04: added content summary and links to JInputTester