Package de.gurkenlabs.litiengine.input
Class GamepadManager
java.lang.Object
de.gurkenlabs.litiengine.input.GamepadEvents
de.gurkenlabs.litiengine.input.GamepadManager
- All Implemented Interfaces:
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:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceThis listener interface receives events when gamepads gets added.static interfaceThis 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 TypeMethodDescriptionvoidRemoves all registered event listeners from the Gamepad instance.current()Gets the first gamepad that is currently available.get(int index) Gets the gamepad by the index within the gamepad list.getAll()Gets all gamepads that are currently available.getById(int id) Gets the gamepad with the specified id if it is still plugged in.booleanDetermines whether the specified Gamepad component is currently pressed.voidonAdded(GamepadManager.GamepadAddedListener listener) Adds the specified gamepad added listener to receive events when gamepads are added.voidonPoll(GamepadEvents.GamepadPollListener listener) Adds the specified gamepad poll listener to receive events when any component has been polled.voidonPoll(String identifier, GamepadEvents.GamepadPollListener listener) Adds the specified gamepad poll listener to receive events when the component with the defined identifier has been polled.voidAdds the specified gamepad pressed listener to receive events when any component has been pressed.voidonPressed(String identifier, GamepadEvents.GamepadPressedListener listener) Adds the specified gamepad pressed listener to receive events when the component with the defined identifier has been pressed.voidAdds the specified gamepad released listener to receive events when any component has been released.voidonReleased(String identifier, GamepadEvents.GamepadReleasedListener listener) Adds the specified gamepad released listener to receive events when the component with the defined identifier has been released.voidAdds the specified gamepad removed listener to receive events when gamepads are removed.voidUnregister the specified added listener from this instance.voidUnregister the specified poll listener from gamepad events.voidremovePollListener(String identifier, GamepadEvents.GamepadPollListener listener) Unregister the specified poll listener from gamepad events.voidUnregister the specified pressed listener from gamepad events.voidremovePressedListener(String identifier, GamepadEvents.GamepadPressedListener listener) Unregister the specified pressed listener from gamepad events.voidUnregister the specified released listener from gamepad events.voidremoveReleasedListener(String identifier, GamepadEvents.GamepadReleasedListener listener) Unregister the specified released listener from gamepad events.voidUnregister the specified removed listener from this instance.voidstart()DON'T CALL THIS EXPLICITLY! THE LITIENGINE WILL MANAGE THE LIFECYCLE OF THIS INSTANCE.voidDON'T CALL THIS EXPLICITLY! THE LITIENGINE WILL MANAGE THE LIFECYCLE OF THIS INSTANCE.
-
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.- Returns:
- All available gamepads.
- See Also:
-
current
Gets the first gamepad that is currently available.- Returns:
- The first available
Gamepadinstance - See Also:
-
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
Description copied from class:GamepadEventsDetermines whether the specified Gamepad component is currently pressed. This is useful for button type components.- Specified by:
isPressedin classGamepadEvents- Parameters:
gamepadComponent- The component to check against.- Returns:
- True if the component is pressed, otherwise false.
- See Also:
-
onPoll
Description copied from class:GamepadEventsAdds the specified gamepad poll listener to receive events when any component has been polled.- Overrides:
onPollin classGamepadEvents- Parameters:
listener- The listener to add.
-
onPressed
Description copied from class:GamepadEventsAdds the specified gamepad pressed listener to receive events when any component has been pressed.- Overrides:
onPressedin classGamepadEvents- Parameters:
listener- The listener to add.
-
onReleased
Description copied from class:GamepadEventsAdds the specified gamepad released listener to receive events when any component has been released.- Overrides:
onReleasedin classGamepadEvents- Parameters:
listener- The listener to add.
-
onPoll
Description copied from class:GamepadEventsAdds the specified gamepad poll listener to receive events when the component with the defined identifier has been polled.- Overrides:
onPollin classGamepadEvents- Parameters:
identifier- The component identifier for which to add the listener.listener- The listener to add.
-
onPressed
Description copied from class:GamepadEventsAdds the specified gamepad pressed listener to receive events when the component with the defined identifier has been pressed.- Overrides:
onPressedin classGamepadEvents- Parameters:
identifier- The component identifier for which to add the listener.listener- The listener to add.
-
onReleased
Description copied from class:GamepadEventsAdds the specified gamepad released listener to receive events when the component with the defined identifier has been released.- Overrides:
onReleasedin classGamepadEvents- Parameters:
identifier- The component identifier for which to add the listener.listener- The listener to add.
-
clearEventListeners
public void clearEventListeners()Description copied from class:GamepadEventsRemoves all registered event listeners from the Gamepad instance.- Overrides:
clearEventListenersin classGamepadEvents
-
removePollListener
Description copied from class:GamepadEventsUnregister the specified poll listener from gamepad events.- Overrides:
removePollListenerin classGamepadEvents- Parameters:
identifier- The component identifier for which to remove the listener.listener- The listener to remove.
-
removePressedListener
Description copied from class:GamepadEventsUnregister the specified pressed listener from gamepad events.- Overrides:
removePressedListenerin classGamepadEvents- 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:GamepadEventsUnregister the specified released listener from gamepad events.- Overrides:
removeReleasedListenerin classGamepadEvents- Parameters:
identifier- The component identifier for which to remove the listener.listener- The listener to remove.
-
removePollListener
Description copied from class:GamepadEventsUnregister the specified poll listener from gamepad events.- Overrides:
removePollListenerin classGamepadEvents- Parameters:
listener- The listener to remove.
-
removePressedListener
Description copied from class:GamepadEventsUnregister the specified pressed listener from gamepad events.- Overrides:
removePressedListenerin classGamepadEvents- Parameters:
listener- The listener to remove.
-
removeReleasedListener
Description copied from class:GamepadEventsUnregister the specified released listener from gamepad events.- Overrides:
removeReleasedListenerin classGamepadEvents- 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:
startin interfaceILaunchable
-
terminate
public void terminate()DON'T CALL THIS EXPLICITLY! THE LITIENGINE WILL MANAGE THE LIFECYCLE OF THIS INSTANCE.- Specified by:
terminatein interfaceILaunchable
-