Class GamepadEvents
- Direct Known Subclasses:
Gamepad, GamepadManager
public abstract class GamepadEvents
The
GamepadEvents class is the engine's implementation for receiving gamepad input events.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceThis listener interface receives pressed events for a gamepad.static interfaceThis listener interface receives released events for a gamepad.static interfaceThis listener interface receives poll events for a gamepad. -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final Map<de.gurkenlabs.input4j.InputComponent.ID, Collection<GamepadEvents.GamepadValueChangedListener>> protected final Map<de.gurkenlabs.input4j.InputComponent.ID, Collection<GamepadEvents.GamepadButtonPressedListener>> protected final Map<de.gurkenlabs.input4j.InputComponent.ID, Collection<GamepadEvents.GamepadButtonReleasedListener>> protected final Collection<GamepadEvents.GamepadValueChangedListener> protected final Collection<GamepadEvents.GamepadButtonPressedListener> protected final Collection<GamepadEvents.GamepadButtonReleasedListener> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidRemoves all registered event listeners from the Gamepad instance.abstract booleanisButtonPressed(int buttonId) abstract booleanisButtonPressed(de.gurkenlabs.input4j.InputComponent.ID buttonId) Determines whether the specified Gamepad component is currently pressed.voidonButtonPressed(int id, GamepadEvents.GamepadButtonPressedListener listener) Adds the specified gamepad pressed listener to receive events when the component with the defined identifier has been pressed.voidonButtonPressed(de.gurkenlabs.input4j.InputComponent.ID identifier, GamepadEvents.GamepadButtonPressedListener listener) Adds the specified gamepad pressed listener to receive events when the component with the defined identifier has been pressed.voidAdds the specified gamepad pressed listener to receive events when any component has been pressed.voidonButtonReleased(int id, GamepadEvents.GamepadButtonReleasedListener listener) Adds the specified gamepad released listener to receive events when the component with the defined identifier has been released.voidonButtonReleased(de.gurkenlabs.input4j.InputComponent.ID identifier, GamepadEvents.GamepadButtonReleasedListener listener) Adds the specified gamepad released listener to receive events when the component with the defined identifier has been released.voidAdds the specified gamepad released listener to receive events when any component has been released.voidonValueChanged(de.gurkenlabs.input4j.InputComponent.ID id, GamepadEvents.GamepadValueChangedListener listener) Adds the specified gamepad poll listener to receive events when the component with the defined identifier has been polled.voidAdds the specified gamepad poll listener to receive events when any component has been polled.voidremoveButtonPressedListener(int id, GamepadEvents.GamepadButtonPressedListener listener) Unregister the specified released listener from gamepad events.voidremoveButtonPressedListener(de.gurkenlabs.input4j.InputComponent.ID identifier, GamepadEvents.GamepadButtonPressedListener listener) Unregister the specified pressed listener from gamepad events.voidUnregister the specified pressed listener from gamepad events.voidremoveButtonReleasedListener(int id, GamepadEvents.GamepadButtonReleasedListener listener) Unregister the specified released listener from gamepad events.voidremoveButtonReleasedListener(de.gurkenlabs.input4j.InputComponent.ID identifier, GamepadEvents.GamepadButtonReleasedListener listener) Unregister the specified released listener from gamepad events.voidUnregister the specified released listener from gamepad events.voidremovePollListener(de.gurkenlabs.input4j.InputComponent.ID identifier, GamepadEvents.GamepadValueChangedListener listener) Unregister the specified poll listener from gamepad events.voidUnregister the specified poll listener from gamepad events.
-
Field Details
-
componentPollListeners
protected final Map<de.gurkenlabs.input4j.InputComponent.ID, Collection<GamepadEvents.GamepadValueChangedListener>> componentPollListeners -
componentPressedListeners
protected final Map<de.gurkenlabs.input4j.InputComponent.ID, Collection<GamepadEvents.GamepadButtonPressedListener>> componentPressedListeners -
componentReleasedListeners
protected final Map<de.gurkenlabs.input4j.InputComponent.ID, Collection<GamepadEvents.GamepadButtonReleasedListener>> componentReleasedListeners -
pollListeners
-
pressedListeners
-
releasedListeners
-
-
Constructor Details
-
GamepadEvents
protected GamepadEvents()
-
-
Method Details
-
onValueChanged
public void onValueChanged(de.gurkenlabs.input4j.InputComponent.ID id, GamepadEvents.GamepadValueChangedListener listener) Adds the specified gamepad poll listener to receive events when the component with the defined identifier has been polled.- Parameters:
id- The component identifier for which to add the listener.listener- The listener to add.
-
onButtonPressed
public void onButtonPressed(de.gurkenlabs.input4j.InputComponent.ID identifier, GamepadEvents.GamepadButtonPressedListener listener) 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.
-
onButtonPressed
Adds the specified gamepad pressed listener to receive events when the component with the defined identifier has been pressed.- Parameters:
id- The component identifier for which to add the listener.listener- The listener to add.
-
onButtonReleased
public void onButtonReleased(de.gurkenlabs.input4j.InputComponent.ID identifier, GamepadEvents.GamepadButtonReleasedListener 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.
-
onButtonReleased
Adds the specified gamepad released listener to receive events when the component with the defined identifier has been released.- Parameters:
id- The component identifier for which to add the listener.listener- The listener to add.
-
onValueChanged
Adds the specified gamepad poll listener to receive events when any component has been polled.- Parameters:
listener- The listener to add.
-
onButtonPressed
Adds the specified gamepad pressed listener to receive events when any component has been pressed.- Parameters:
listener- The listener to add.
-
onButtonReleased
Adds the specified gamepad released listener to receive events when any component has been released.- Parameters:
listener- The listener to add.
-
removePollListener
public void removePollListener(de.gurkenlabs.input4j.InputComponent.ID identifier, GamepadEvents.GamepadValueChangedListener 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.
-
removeButtonPressedListener
public void removeButtonPressedListener(de.gurkenlabs.input4j.InputComponent.ID identifier, GamepadEvents.GamepadButtonPressedListener 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.
-
removeButtonPressedListener
public void removeButtonPressedListener(int id, GamepadEvents.GamepadButtonPressedListener listener) Unregister the specified released listener from gamepad events.- Parameters:
id- The component identifier for which to remove the listener.listener- The listener to remove.
-
removeButtonReleasedListener
public void removeButtonReleasedListener(de.gurkenlabs.input4j.InputComponent.ID identifier, GamepadEvents.GamepadButtonReleasedListener 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.
-
removeButtonReleasedListener
public void removeButtonReleasedListener(int id, GamepadEvents.GamepadButtonReleasedListener listener) Unregister the specified released listener from gamepad events.- Parameters:
id- The component identifier for which to remove the listener.listener- The listener to remove.
-
removePollListener
Unregister the specified poll listener from gamepad events.- Parameters:
listener- The listener to remove.
-
removeButtonPressedListener
Unregister the specified pressed listener from gamepad events.- Parameters:
listener- The listener to remove.
-
removeButtonReleasedListener
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. -
isButtonPressed
public abstract boolean isButtonPressed(de.gurkenlabs.input4j.InputComponent.ID buttonId) Determines whether the specified Gamepad component is currently pressed. This is useful for button type components.- Parameters:
buttonId- The component to check against.- Returns:
- True if the component is pressed, otherwise false.
-
isButtonPressed
public abstract boolean isButtonPressed(int buttonId)
-