Package de.gurkenlabs.litiengine.input
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.
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
GamepadManager.GamepadAddedListener
This listener interface receives events when gamepads gets added.static interface
GamepadManager.GamepadRemovedListener
This listener interface receives events when gamepads gets removed.Nested classes/interfaces inherited from class de.gurkenlabs.litiengine.input.GamepadEvents
GamepadEvents.GamepadPollListener, GamepadEvents.GamepadPressedListener, GamepadEvents.GamepadReleasedListener
Field Summary
Fields inherited from class de.gurkenlabs.litiengine.input.GamepadEvents
componentPollListeners, componentPressedListeners, componentReleasedListeners, pollListeners, pressedListeners, releasedListeners
Method Summary
Modifier and Type Method Description Gamepad
current()
Gets the first gamepad that is currently available.Gamepad
get(int index)
Gets the gamepad by the index within the gamepad list.java.util.List<Gamepad>
getAll()
Gets all gamepads that are currently available.Gamepad
getById(int id)
Gets the gamepad with the specified id if it is still plugged in.boolean
isPressed(java.lang.String gamepadComponent)
Determines whether the specified Gamepad component is currently pressed.void
onAdded(GamepadManager.GamepadAddedListener listener)
Adds the specified gamepad added listener to receive events when gamepads are added.void
onRemoved(GamepadManager.GamepadRemovedListener listener)
Adds the specified gamepad removed listener to receive events when gamepads are removed.void
removeAddedListener(GamepadManager.GamepadAddedListener listener)
Unregister the specified added listener from this instance.void
removeRemovedListener(GamepadManager.GamepadRemovedListener listener)
Unregister the specified removed listener from this instance.void
start()
DON'T CALL THIS EXPLICITLY! THE LITIENGINE WILL MANAGE THE LIFECYCLE OF THIS INSTANCE.void
terminate()
DON'T CALL THIS EXPLICITLY! THE LITIENGINE WILL MANAGE THE LIFECYCLE OF THIS INSTANCE.Methods inherited from class de.gurkenlabs.litiengine.input.GamepadEvents
clearEventListeners, onPoll, onPoll, onPressed, onPressed, onReleased, onReleased, removePollListener, removePollListener, removePressedListener, removePressedListener, removeReleasedListener, removeReleasedListener
Method Details
onAdded
Adds the specified gamepad added listener to receive events when gamepads are added.- Parameters:
listener
- The listener to add.
removeAddedListener
Unregister the specified added listener from this instance.- Parameters:
listener
- The listener to remove.
onRemoved
Adds the specified gamepad removed listener to receive events when gamepads are removed.- Parameters:
listener
- The listener to add.
removeRemovedListener
Unregister the specified removed listener from this instance.- Parameters:
listener
- The listener to remove.
getAll
Gets all gamepads that are currently available.current
Gets the first gamepad that is currently available.get
Gets the gamepad by the index within the gamepad list.getById
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.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 classGamepadEvents
- 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 interfaceILaunchable
terminate
public void terminate()DON'T CALL THIS EXPLICITLY! THE LITIENGINE WILL MANAGE THE LIFECYCLE OF THIS INSTANCE.- Specified by:
terminate
in interfaceILaunchable