Package de.gurkenlabs.litiengine.input
Class GamepadEvents
java.lang.Object
de.gurkenlabs.litiengine.input.GamepadEvents
- Direct Known Subclasses:
Gamepad,GamepadManager
public abstract class GamepadEvents
extends java.lang.ObjectThe
GamepadEvents class is the engine's implementation for receiving gamepad input events.Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceGamepadEvents.GamepadPollListenerThis listener interface receives poll events for a gamepad.static interfaceGamepadEvents.GamepadPressedListenerThis listener interface receives pressed events for a gamepad.static interfaceGamepadEvents.GamepadReleasedListenerThis listener interface receives released events for a gamepad.Field Summary
Fields Modifier and Type Field Description protected java.util.Map<java.lang.String,java.util.Collection<GamepadEvents.GamepadPollListener>>componentPollListenersprotected java.util.Map<java.lang.String,java.util.Collection<GamepadEvents.GamepadPressedListener>>componentPressedListenersprotected java.util.Map<java.lang.String,java.util.Collection<GamepadEvents.GamepadReleasedListener>>componentReleasedListenersprotected java.util.Collection<GamepadEvents.GamepadPollListener>pollListenersprotected java.util.Collection<GamepadEvents.GamepadPressedListener>pressedListenersprotected java.util.Collection<GamepadEvents.GamepadReleasedListener>releasedListenersConstructor Summary
Constructors Modifier Constructor Description protectedGamepadEvents()Method Summary
Modifier and Type Method Description voidclearEventListeners()Removes all registered event listeners from the Gamepad instance.abstract booleanisPressed(java.lang.String gamepadComponent)Determines whether the specified Gamepad component is currently pressed.voidonPoll(GamepadEvents.GamepadPollListener listener)Adds the specified gamepad poll listener to receive events when any component has been polled.voidonPoll(java.lang.String identifier, GamepadEvents.GamepadPollListener listener)Adds the specified gamepad poll listener to receive events when the component with the defined identifier has been polled.voidonPressed(GamepadEvents.GamepadPressedListener listener)Adds the specified gamepad pressed listener to receive events when any component has been pressed.voidonPressed(java.lang.String identifier, GamepadEvents.GamepadPressedListener listener)Adds the specified gamepad pressed listener to receive events when the component with the defined identifier has been pressed.voidonReleased(GamepadEvents.GamepadReleasedListener listener)Adds the specified gamepad released listener to receive events when any component has been released.voidonReleased(java.lang.String identifier, GamepadEvents.GamepadReleasedListener listener)Adds the specified gamepad released listener to receive events when the component with the defined identifier has been released.voidremovePollListener(GamepadEvents.GamepadPollListener listener)Unregister the specified poll listener from gamepad events.voidremovePollListener(java.lang.String identifier, GamepadEvents.GamepadPollListener listener)Unregister the specified poll listener from gamepad events.voidremovePressedListener(GamepadEvents.GamepadPressedListener listener)Unregister the specified pressed listener from gamepad events.voidremovePressedListener(java.lang.String identifier, GamepadEvents.GamepadPressedListener listener)Unregister the specified pressed listener from gamepad events.voidremoveReleasedListener(GamepadEvents.GamepadReleasedListener listener)Unregister the specified released listener from gamepad events.voidremoveReleasedListener(java.lang.String identifier, GamepadEvents.GamepadReleasedListener listener)Unregister the specified released listener from gamepad events.
Field Details
componentPollListeners
protected final java.util.Map<java.lang.String,java.util.Collection<GamepadEvents.GamepadPollListener>> componentPollListenerscomponentPressedListeners
protected final java.util.Map<java.lang.String,java.util.Collection<GamepadEvents.GamepadPressedListener>> componentPressedListenerscomponentReleasedListeners
protected final java.util.Map<java.lang.String,java.util.Collection<GamepadEvents.GamepadReleasedListener>> componentReleasedListenerspollListeners
pressedListeners
releasedListeners
Constructor Details
GamepadEvents
protected GamepadEvents()
Method Details
onPoll
Adds the specified gamepad poll listener to receive events when the component with the defined identifier has been polled.- Parameters:
identifier- The component identifier for which to add the listener.listener- The listener to add.
removePollListener
public void removePollListener(java.lang.String identifier, GamepadEvents.GamepadPollListener listener)Unregister the specified poll listener from gamepad events.- Parameters:
identifier- The component identifier for which to remove the listener.listener- The listener to remove.
onPressed
Adds the specified gamepad pressed listener to receive events when the component with the defined identifier has been pressed.- Parameters:
identifier- The component identifier for which to add the listener.listener- The listener to add.
removePressedListener
public void removePressedListener(java.lang.String identifier, GamepadEvents.GamepadPressedListener listener)Unregister the specified pressed listener from gamepad events.- Parameters:
identifier- The component identifier for which to remove the listener.listener- The listener to remove.
onReleased
public void onReleased(java.lang.String identifier, GamepadEvents.GamepadReleasedListener listener)Adds the specified gamepad released listener to receive events when the component with the defined identifier has been released.- Parameters:
identifier- The component identifier for which to add the listener.listener- The listener to add.
removeReleasedListener
public void removeReleasedListener(java.lang.String identifier, GamepadEvents.GamepadReleasedListener listener)Unregister the specified released listener from gamepad events.- Parameters:
identifier- The component identifier for which to remove the listener.listener- The listener to remove.
onPoll
Adds the specified gamepad poll listener to receive events when any component has been polled.- Parameters:
listener- The listener to add.
removePollListener
Unregister the specified poll listener from gamepad events.- Parameters:
listener- The listener to remove.
onPressed
Adds the specified gamepad pressed listener to receive events when any component has been pressed.- Parameters:
listener- The listener to add.
removePressedListener
Unregister the specified pressed listener from gamepad events.- Parameters:
listener- The listener to remove.
onReleased
Adds the specified gamepad released listener to receive events when any component has been released.- Parameters:
listener- The listener to add.
removeReleasedListener
Unregister the specified released listener from gamepad events.- Parameters:
listener- The listener to remove.
clearEventListeners
public void clearEventListeners()Removes all registered event listeners from the Gamepad instance.isPressed
public abstract boolean isPressed(java.lang.String gamepadComponent)Determines whether the specified Gamepad component is currently pressed. This is useful for button type components.- Parameters:
gamepadComponent- The component to check against.- Returns:
- True if the component is pressed, otherwise false.
- See Also:
Gamepad.Buttons,Gamepad.Xbox
