Hi Shawn,
There are a couple of ways to grab joystick data and use it in a Java
program, of which I am aware. The first way is to use javax.comm,
which allows one to get data directly from either the serial or
parallel ports, and it does so in a platform independent manner. Some
of the newer joysticks use the USB standard, like Wingman Force from
Logitech, and so it is possible to write your own serial port driver.
Using javax.comm has the advantage of running on Solaris, Linux, and
Windows (and hopefully a number of other platforms in the future).
The other way to grab joystick data is to directly use JNI. You can
use JNI calls which call down to the API calls exported by the
joystick. For instance, I think this is what you would have to do to
get game port data, since I do not believe that javax.comm gives you
access to the Game Port. This will limit your platform possibilities.
So that is how to get the data from your joystick. Now, how do you use
the data in a Java program?
If you are using Java 3D, there is a standard Java interface called
InputDevice (javax.media.j3d.InputDevice). You implement each of the
methods in the interface. You hand the implementation of the
InputDevice interface to Java 3D, along with a transform which you
associate with the InputDevice using a simple sensor-based behavior.
There is a detailed source code example of this in the Java 3D example
called VirtualInputDevice. The example uses a GUI-joystick (i.e.,
there is a window with joystick controls in it), instead of a real
joystick for its input.
Note that the concept of devices is built right into Java 3D. The
implementation handles the scheduling of the input device reads for
you. Once you hand the API the InputDevice and the associated
transform that you want the device to modify inside your scene graph,
you can just forget about it. It will just work automatically. Also,
the interface is high level, so there are as few JNI calls as possible
(if JNI is the route you choose). There are also various scheduling
semantics supported. In the same directory as the Java 3D
VirtualInputDevice example, there is a detailed README.
We have shown numerous Virtual Reality demos using various Logitech and
Fakespace Virtual Reality equipment using these methods.
I should also mention that Java 3D has bundled doom-style keyboard
navigation libraries with the Java 3D release in the
com.sun.j3d.utils.behaviors.keyboard package.
Hope this helps.
Travis Bryson
Sun Microsystems
> Date: Mon, 15 Mar 1999 16:38:40 -0500
> From: Shawn Kendall <[EMAIL PROTECTED]>
> X-Accept-Language: en
> MIME-Version: 1.0
> To: "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>, "[EMAIL PROTECTED]"
<[EMAIL PROTECTED]>
> Subject: [java3d] Joystick data
> Content-Transfer-Encoding: 7bit
>
> Does anyone here know how I can get joystick data from Java?
> What API do I use?
> Has anyone out there done this?
> I know I can use the CommAPI to get serial data but what about game port
> data?
> Thanks for any help.
>
>
>
> --
> TTFN
>
> __________________________________________________________
>
> Shawn Kendall Full Sail Real World Education
> Course Instructor 3300 University BLVD
> Virtual Reality Winter Park FL 32792
> [EMAIL PROTECTED] http://www.fullsail.com
> __________________________________________________________
>
>
>
> =====================================================================
> To subscribe/unsubscribe, send mail to [EMAIL PROTECTED]
> Java 3D Home Page: http://java.sun.com/products/java-media/3D/
=====================================================================
To subscribe/unsubscribe, send mail to [EMAIL PROTECTED]
Java 3D Home Page: http://java.sun.com/products/java-media/3D/