Class GamepadManager

java.lang.Object
de.gurkenlabs.litiengine.input.GamepadEvents
de.gurkenlabs.litiengine.input.GamepadManager

public final class GamepadManager extends GamepadEvents

The GamepadManager provides access to all gamepad input devices.

Gamepads don't need to be added explicitly, the manager supports hot-plugging at runtime and will auto-detect any added/removed gamepads.

See Also:
  • Method Details

    • onAdded

      public void onAdded(GamepadManager.GamepadAddedListener listener)
      Adds the specified gamepad added listener to receive events when gamepads are added.
      Parameters:
      listener - The listener to add.
    • removeAddedListener

      public void removeAddedListener(GamepadManager.GamepadAddedListener listener)
      Unregister the specified added listener from this instance.
      Parameters:
      listener - The listener to remove.
    • onRemoved

      public void onRemoved(GamepadManager.GamepadRemovedListener listener)
      Adds the specified gamepad removed listener to receive events when gamepads are removed.
      Parameters:
      listener - The listener to add.
    • removeRemovedListener

      public void removeRemovedListener(GamepadManager.GamepadRemovedListener listener)
      Unregister the specified removed listener from this instance.
      Parameters:
      listener - The listener to remove.
    • getAll

      public List<Gamepad> getAll()
      Gets all gamepads that are currently available.
      Returns:
      All available gamepads.
      See Also:
    • current

      public Gamepad current()
      Gets the first gamepad that is currently available.
      Returns:
      The first available Gamepad instance
      See Also:
    • get

      public Gamepad get(int index)
      Gets the gamepad by the index within the gamepad list.
      Parameters:
      index - The index of the Gamepad.
      Returns:
      The Gamepad with the specified index.
      See Also:
    • getById

      public Gamepad getById(String id)
      Gets the gamepad with the specified id if it is still plugged in. After re-plugging a controller while the game is running, its id might change.
      Parameters:
      id - The id of the Gamepad.
      Returns:
      The Gamepad with the specified index.
      See Also:
    • onValueChanged

      public void onValueChanged(GamepadEvents.GamepadValueChangedListener listener)
      Description copied from class: GamepadEvents
      Adds the specified gamepad poll listener to receive events when any component has been polled.
      Overrides:
      onValueChanged in class GamepadEvents
      Parameters:
      listener - The listener to add.
    • onButtonPressed

      public void onButtonPressed(GamepadEvents.GamepadButtonPressedListener listener)
      Description copied from class: GamepadEvents
      Adds the specified gamepad pressed listener to receive events when any component has been pressed.
      Overrides:
      onButtonPressed in class GamepadEvents
      Parameters:
      listener - The listener to add.
    • onButtonReleased

      public void onButtonReleased(GamepadEvents.GamepadButtonReleasedListener listener)
      Description copied from class: GamepadEvents
      Adds the specified gamepad released listener to receive events when any component has been released.
      Overrides:
      onButtonReleased in class GamepadEvents
      Parameters:
      listener - The listener to add.
    • onValueChanged

      public void onValueChanged(de.gurkenlabs.input4j.InputComponent.ID identifier, GamepadEvents.GamepadValueChangedListener listener)
      Description copied from class: GamepadEvents
      Adds the specified gamepad poll listener to receive events when the component with the defined identifier has been polled.
      Overrides:
      onValueChanged in class GamepadEvents
      Parameters:
      identifier - The component identifier for which to add the listener.
      listener - The listener to add.
    • onButtonPressed

      public void onButtonPressed(de.gurkenlabs.input4j.InputComponent.ID identifier, GamepadEvents.GamepadButtonPressedListener listener)
      Description copied from class: GamepadEvents
      Adds the specified gamepad pressed listener to receive events when the component with the defined identifier has been pressed.
      Overrides:
      onButtonPressed in class GamepadEvents
      Parameters:
      identifier - The component identifier for which to add the listener.
      listener - The listener to add.
    • onButtonReleased

      public void onButtonReleased(de.gurkenlabs.input4j.InputComponent.ID identifier, GamepadEvents.GamepadButtonReleasedListener listener)
      Description copied from class: GamepadEvents
      Adds the specified gamepad released listener to receive events when the component with the defined identifier has been released.
      Overrides:
      onButtonReleased in class GamepadEvents
      Parameters:
      identifier - The component identifier for which to add the listener.
      listener - The listener to add.
    • clearEventListeners

      public void clearEventListeners()
      Description copied from class: GamepadEvents
      Removes all registered event listeners from the Gamepad instance.
      Overrides:
      clearEventListeners in class GamepadEvents
    • isButtonPressed

      public boolean isButtonPressed(de.gurkenlabs.input4j.InputComponent.ID buttonId)
      Description copied from class: GamepadEvents
      Determines whether the specified Gamepad component is currently pressed. This is useful for button type components.
      Specified by:
      isButtonPressed in class GamepadEvents
      Parameters:
      buttonId - The component to check against.
      Returns:
      True if the component is pressed, otherwise false.
    • isButtonPressed

      public boolean isButtonPressed(int buttonId)
      Specified by:
      isButtonPressed in class GamepadEvents
    • removePollListener

      public void removePollListener(de.gurkenlabs.input4j.InputComponent.ID identifier, GamepadEvents.GamepadValueChangedListener listener)
      Description copied from class: GamepadEvents
      Unregister the specified poll listener from gamepad events.
      Overrides:
      removePollListener in class GamepadEvents
      Parameters:
      identifier - The component identifier for which to remove the listener.
      listener - The listener to remove.
    • removeButtonPressedListener

      public void removeButtonPressedListener(de.gurkenlabs.input4j.InputComponent.ID identifier, GamepadEvents.GamepadButtonPressedListener listener)
      Description copied from class: GamepadEvents
      Unregister the specified pressed listener from gamepad events.
      Overrides:
      removeButtonPressedListener in class GamepadEvents
      Parameters:
      identifier - The component identifier for which to remove the listener.
      listener - The listener to remove.
    • removeButtonReleasedListener

      public void removeButtonReleasedListener(de.gurkenlabs.input4j.InputComponent.ID identifier, GamepadEvents.GamepadButtonReleasedListener listener)
      Description copied from class: GamepadEvents
      Unregister the specified released listener from gamepad events.
      Overrides:
      removeButtonReleasedListener in class GamepadEvents
      Parameters:
      identifier - The component identifier for which to remove the listener.
      listener - The listener to remove.
    • removePollListener

      public void removePollListener(GamepadEvents.GamepadValueChangedListener listener)
      Description copied from class: GamepadEvents
      Unregister the specified poll listener from gamepad events.
      Overrides:
      removePollListener in class GamepadEvents
      Parameters:
      listener - The listener to remove.
    • removeButtonPressedListener

      public void removeButtonPressedListener(GamepadEvents.GamepadButtonPressedListener listener)
      Description copied from class: GamepadEvents
      Unregister the specified pressed listener from gamepad events.
      Overrides:
      removeButtonPressedListener in class GamepadEvents
      Parameters:
      listener - The listener to remove.
    • removeButtonReleasedListener

      public void removeButtonReleasedListener(GamepadEvents.GamepadButtonReleasedListener listener)
      Description copied from class: GamepadEvents
      Unregister the specified released listener from gamepad events.
      Overrides:
      removeButtonReleasedListener in class GamepadEvents
      Parameters:
      listener - The listener to remove.