How to implement a joystick?

Hi
I wanna programm a helicopter-simulator controlled by joystick. For the joystick, I use te JXInput package (www.hardcode.de) which returns me a value between -1 and 1 for each axis, depending on where the stick is.

Now, I’m not sure what to use: Behavior or Listener. And how can I implement translations/rotations using the Alpha/Interpolator-Classes together with this -1 to 1 -value ?

Really thanks for help !
Flavio

Excellent choice! ;D

What I do is having a Behavior that forms kind of a gameloop with a WakeUpOnElapsedFrames.

During the processStimulus I update the controller and use the values to control the motion. This in turn directly influences a TransformGroup where the helicopter is.
Of course this is encapsulated in dozens of classes, so I cannot post them here. Maybe the classes you need are

  • HeliController (update(), getPitch(), getTailRotor(), getLeftRight(), getForwardBackward())

  • HeliMotion (setHeliController(), update())

No Alpha/Interpolator stuff.

I have a PlaneController in place that additionally lets you use keyboard or mouse, depending on whats used latest. If you like to see it…

Hi,
first of all, thanks for responding. I’m now a little bit further … but still have problems:

I get the value from JXInput (-1 to 1) which I wanna use for the translation/rotation.
How can I transform this value in a value which is compatible with the Transform3D-class (a Matrix4d object), which I us for doing the translation/rotation?

Would it be possible to take a look in your code, especially the Behavior-Class and the Class where you handle the value from JXInput?

Thanks
Flavio