Class AbstractJoystick

java.lang.Object
com.jme3.input.AbstractJoystick
All Implemented Interfaces:
Joystick
Direct Known Subclasses:
AndroidJoystickJoyInput14.AndroidJoystick, AndroidSensorJoyInput.AndroidSensorJoystick, GlfwJoystickInput.GlfwJoystick, JInputJoyInput.JInputJoystick

public abstract class AbstractJoystick extends Object implements Joystick
A joystick represents a single joystick that is installed in the system.
  • Constructor Details

    • AbstractJoystick

      protected AbstractJoystick(InputManager inputManager, JoyInput joyInput, int joyId, String name)
      Creates a new joystick instance. Only used internally.
      Parameters:
      inputManager - (alias created)
      joyInput - (alias created)
      joyId - ID to assign to the instance
      name - name to assign to the instance
  • Method Details

    • getInputManager

      protected InputManager getInputManager()
    • getJoyInput

      protected JoyInput getJoyInput()
    • addAxis

      protected void addAxis(JoystickAxis axis)
    • addButton

      protected void addButton(JoystickButton button)
    • rumble

      public void rumble(float amount)
      Rumbles the joystick for the given amount/magnitude.
      Specified by:
      rumble in interface Joystick
      Parameters:
      amount - The amount to rumble. Should be between 0 and 1.
    • assignButton

      @Deprecated public void assignButton(String mappingName, int buttonId)
      Deprecated.
      Use JoystickButton.assignButton() instead.
      Assign the mapping name to receive events from the given button index on the joystick.
      Specified by:
      assignButton in interface Joystick
      Parameters:
      mappingName - The mapping to receive joystick button events.
      buttonId - The button index.
      See Also:
    • assignAxis

      @Deprecated public void assignAxis(String positiveMapping, String negativeMapping, int axisId)
      Deprecated.
      Use JoystickAxis.assignAxis() instead.
      Assign the mappings to receive events from the given joystick axis.
      Specified by:
      assignAxis in interface Joystick
      Parameters:
      positiveMapping - The mapping to receive events when the axis is negative
      negativeMapping - The mapping to receive events when the axis is positive
      axisId - The axis index.
      See Also:
    • getAxis

      public JoystickAxis getAxis(String logicalId)
      Description copied from interface: Joystick
      Returns the JoystickAxis with the specified logical ID.
      Specified by:
      getAxis in interface Joystick
      Parameters:
      logicalId - The id of the axis to search for as returned by JoystickAxis.getLogicalId().
      Returns:
      the pre-existing instance, or null if not found
    • getAxes

      public List<JoystickAxis> getAxes()
      Returns a read-only list of all joystick axes for this Joystick.
      Specified by:
      getAxes in interface Joystick
      Returns:
      an unmodifiable list of pre-existing instances
    • getAxisCount

      public int getAxisCount()
      Returns the number of axes on this joystick.
      Specified by:
      getAxisCount in interface Joystick
      Returns:
      the number of axes on this joystick.
    • getButton

      public JoystickButton getButton(String logicalId)
      Description copied from interface: Joystick
      Returns the JoystickButton with the specified logical ID.
      Specified by:
      getButton in interface Joystick
      Parameters:
      logicalId - The id of the axis to search for as returned by JoystickButton.getLogicalId().
      Returns:
      the pre-existing instance, or null if not found
    • getButtons

      public List<JoystickButton> getButtons()
      Returns a read-only list of all joystick buttons for this Joystick.
      Specified by:
      getButtons in interface Joystick
      Returns:
      an unmodifiable list of pre-existing instances
    • getButtonCount

      public int getButtonCount()
      Returns the number of buttons on this joystick.
      Specified by:
      getButtonCount in interface Joystick
      Returns:
      the number of buttons on this joystick.
    • getName

      public String getName()
      Returns the name of this joystick.
      Specified by:
      getName in interface Joystick
      Returns:
      the name of this joystick.
    • getJoyId

      public int getJoyId()
      Returns the joyId of this joystick.
      Specified by:
      getJoyId in interface Joystick
      Returns:
      the joyId of this joystick.
    • getXAxisIndex

      public int getXAxisIndex()
      Gets the index number for the X axis on the joystick.

      E.g. for most gamepads, the left control stick X axis will be returned.

      Specified by:
      getXAxisIndex in interface Joystick
      Returns:
      The axis index for the X axis for this joystick.
      See Also:
    • getYAxisIndex

      public int getYAxisIndex()
      Gets the index number for the Y axis on the joystick.

      E.g. for most gamepads, the left control stick Y axis will be returned.

      Specified by:
      getYAxisIndex in interface Joystick
      Returns:
      The axis index for the Y axis for this joystick.
      See Also:
    • toString

      public String toString()
      Overrides:
      toString in class Object