Class GamepadManager

java.lang.Object
de.gurkenlabs.litiengine.input.GamepadEvents
de.gurkenlabs.litiengine.input.GamepadManager
All Implemented Interfaces:
ILaunchable

public final class GamepadManager extends GamepadEvents implements ILaunchable
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(int 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:
    • isPressed

      public boolean isPressed(String gamepadComponent)
      Description copied from class: GamepadEvents
      Determines whether the specified Gamepad component is currently pressed. This is useful for button type components.
      Specified by:
      isPressed in class GamepadEvents
      Parameters:
      gamepadComponent - The component to check against.
      Returns:
      True if the component is pressed, otherwise false.
      See Also:
    • onPoll

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

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

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

      public void onPoll(String identifier, GamepadEvents.GamepadPollListener 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:
      onPoll in class GamepadEvents
      Parameters:
      identifier - The component identifier for which to add the listener.
      listener - The listener to add.
    • onPressed

      public void onPressed(String identifier, GamepadEvents.GamepadPressedListener 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:
      onPressed in class GamepadEvents
      Parameters:
      identifier - The component identifier for which to add the listener.
      listener - The listener to add.
    • onReleased

      public void onReleased(String identifier, GamepadEvents.GamepadReleasedListener 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:
      onReleased 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
    • removePollListener

      public void removePollListener(String identifier, GamepadEvents.GamepadPollListener 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.
    • removePressedListener

      public void removePressedListener(String identifier, GamepadEvents.GamepadPressedListener listener)
      Description copied from class: GamepadEvents
      Unregister the specified pressed listener from gamepad events.
      Overrides:
      removePressedListener in class GamepadEvents
      Parameters:
      identifier - The component identifier for which to remove the listener.
      listener - The listener to remove.
    • removeReleasedListener

      public void removeReleasedListener(String identifier, GamepadEvents.GamepadReleasedListener listener)
      Description copied from class: GamepadEvents
      Unregister the specified released listener from gamepad events.
      Overrides:
      removeReleasedListener in class GamepadEvents
      Parameters:
      identifier - The component identifier for which to remove the listener.
      listener - The listener to remove.
    • removePollListener

      public void removePollListener(GamepadEvents.GamepadPollListener 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.
    • removePressedListener

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

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

      public void start()
      DON'T CALL THIS EXPLICITLY! THE LITIENGINE WILL MANAGE THE LIFECYCLE OF THIS INSTANCE.
      Specified by:
      start in interface ILaunchable
    • terminate

      public void terminate()
      DON'T CALL THIS EXPLICITLY! THE LITIENGINE WILL MANAGE THE LIFECYCLE OF THIS INSTANCE.
      Specified by:
      terminate in interface ILaunchable