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:
current(), get(int)
  • 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 java.util.List<Gamepad> getAll()
      Gets all gamepads that are currently available.
      Returns:
      All available gamepads.
      See Also:
      get(int), current()
    • current

      public Gamepad current()
      Gets the first gamepad that is currently available.
      Returns:
      The first available Gamepad instance
      See Also:
      get(int), getAll()
    • 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:
      getAll(), current()
    • 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:
      getAll(), current()
    • isPressed

      public boolean isPressed​(java.lang.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:
      Gamepad.Buttons, Gamepad.Xbox
    • 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