Class Joystick

  • All Implemented Interfaces:
    com.centralnexus.input.JoystickListener, java.lang.Cloneable, Actor, Executable, FiringsRecordable, Initializable, TypedActor, Changeable, Debuggable, DebugListener, Derivable, Instantiable, ModelErrorHandler, MoMLExportable, Moveable, Nameable

    public class Joystick
    extends TypedAtomicActor
    implements com.centralnexus.input.JoystickListener
    This actor reads data from a Joystick using the Joystick interface from http://sourceforge.net/projects/javajoystick/ and generates output ranging between -1.0 and 1.0 on the x and x ports.

    Currently, this actor will only work under Windows, though the Joystick interface also supports Linux.

    Under Windows, jjstick.dll must be in your path and joystick.jar must be in the classpath.

    By default, $PTII/configure looks for the Joystick interface in $PTII/vendors/misc/joystick/lib, so you could either add that directory to your path, or copy jjstick.dll to $PTII/bin:

     cp $PTII/vendors/misc/joystick/lib/jjstick.dll $PTII/bin
     
    By default, if configure finds joystick.jar, then vergil will include joystick.jar in the classpath.
    Since:
    Ptolemy II 3.0
    Version:
    $Id$
    Author:
    Christopher Hylands, David Lee, Paul Yang
    See Also:
    SerialComm
    Pt.AcceptedRating:
    red (cxh)
    Pt.ProposedRating:
    red (cxh)
    • Field Detail

      • deadZone

        public Parameter deadZone
        The deadzone of the Joystick: Under this absolute value, the joystick coordinate is 0.0. The default value is a DoubleToken of value 0.01
      • isPolling

        public Parameter isPolling
        Set to true if polling is used to access the Joystick, false if we use a JoystickListener. The initial value is a BooleanToken with value true.
      • pollingInterval

        public Parameter pollingInterval
        The polling interval in milliseconds of how often the JoystickListeners get notified of joystick events. The default value is an IntToken with a value of 50.
      • x

        public TypedIOPort x
        The output port for the x coordinate, which has type DoubleToken.
      • y

        public TypedIOPort y
        The output port for the y coordinate, which has type DoubleToken.
    • Method Detail

      • attributeChanged

        public void attributeChanged​(Attribute attribute)
                              throws IllegalActionException
        If the attribute is deadZone and the joystick has already been initialized by calling initialize() then update the appropriate value in the joystick interface. If the attribute is deadZone and initialized() has not yet been called, then do nothing.
        Overrides:
        attributeChanged in class NamedObj
        Parameters:
        attribute - The attribute that changed.
        Throws:
        IllegalActionException - Not thrown in this base class.
      • joystickAxisChanged

        public void joystickAxisChanged​(com.centralnexus.input.Joystick j)
        Specified by:
        joystickAxisChanged in interface com.centralnexus.input.JoystickListener
      • joystickButtonChanged

        public void joystickButtonChanged​(com.centralnexus.input.Joystick j)
        This method gets called periodically when a joystick button changes its value.
        Specified by:
        joystickButtonChanged in interface com.centralnexus.input.JoystickListener