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.Object
The
GamepadEvents
class is the engine's implementation for receiving gamepad input events.Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
GamepadEvents.GamepadPollListener
This listener interface receives poll events for a gamepad.static interface
GamepadEvents.GamepadPressedListener
This listener interface receives pressed events for a gamepad.static interface
GamepadEvents.GamepadReleasedListener
This 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>>
componentPollListeners
protected java.util.Map<java.lang.String,java.util.Collection<GamepadEvents.GamepadPressedListener>>
componentPressedListeners
protected java.util.Map<java.lang.String,java.util.Collection<GamepadEvents.GamepadReleasedListener>>
componentReleasedListeners
protected java.util.Collection<GamepadEvents.GamepadPollListener>
pollListeners
protected java.util.Collection<GamepadEvents.GamepadPressedListener>
pressedListeners
protected java.util.Collection<GamepadEvents.GamepadReleasedListener>
releasedListeners
Constructor Summary
Constructors Modifier Constructor Description protected
GamepadEvents()
Method Summary
Modifier and Type Method Description void
clearEventListeners()
Removes all registered event listeners from the Gamepad instance.abstract boolean
isPressed(java.lang.String gamepadComponent)
Determines whether the specified Gamepad component is currently pressed.void
onPoll(GamepadEvents.GamepadPollListener listener)
Adds the specified gamepad poll listener to receive events when any component has been polled.void
onPoll(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.void
onPressed(GamepadEvents.GamepadPressedListener listener)
Adds the specified gamepad pressed listener to receive events when any component has been pressed.void
onPressed(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.void
onReleased(GamepadEvents.GamepadReleasedListener listener)
Adds the specified gamepad released listener to receive events when any component has been released.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.void
removePollListener(GamepadEvents.GamepadPollListener listener)
Unregister the specified poll listener from gamepad events.void
removePollListener(java.lang.String identifier, GamepadEvents.GamepadPollListener listener)
Unregister the specified poll listener from gamepad events.void
removePressedListener(GamepadEvents.GamepadPressedListener listener)
Unregister the specified pressed listener from gamepad events.void
removePressedListener(java.lang.String identifier, GamepadEvents.GamepadPressedListener listener)
Unregister the specified pressed listener from gamepad events.void
removeReleasedListener(GamepadEvents.GamepadReleasedListener listener)
Unregister the specified released listener from gamepad events.void
removeReleasedListener(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