Class AbstractGamepadListener
java.lang.Object
gaiasky.input.AbstractGamepadListener
- All Implemented Interfaces:
com.badlogic.gdx.controllers.ControllerListener, IObserver, IInputListener
- Direct Known Subclasses:
GuiGamepadListener, MainGamepadListener, SpacecraftGamepadListener
public abstract class AbstractGamepadListener
extends Object
implements com.badlogic.gdx.controllers.ControllerListener, IInputListener, IObserver
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final AtomicBooleanIs this listener active?protected longDelay between axis events.protected longDelay between axis poll operations.protected longDelay between button poll operations.protected final EventManagerReference to the global event manager.protected longLast axis event time.protected longLast button poll time.protected com.badlogic.gdx.controllers.ControllerReference to the last gaming controller that registered an input.protected IGamepadMappingsGamepad mappings instance.protected static final float -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractGamepadListener(IGamepadMappings mappings) protectedAbstractGamepadListener(String mappingsFile) -
Method Summary
Modifier and TypeMethodDescriptionvoidactivate()Activate the listener.booleananyPressed(int... buttonCodes) Returns true if any of the buttons are pressed in the last controller used.booleananyPressed(com.badlogic.gdx.controllers.Controller controller, int... buttonCodes) Returns true if any of the buttons are pressed in the given controller.protected doubleapplyZeroPoint(double value) Zero-point function for the axes.booleanaxisMoved(com.badlogic.gdx.controllers.Controller controller, int axisCode, float value) booleanbuttonDown(com.badlogic.gdx.controllers.Controller controller, int buttonCode) booleanbuttonUp(com.badlogic.gdx.controllers.Controller controller, int buttonCode) voidconnected(com.badlogic.gdx.controllers.Controller controller) voidDeactivate the listener.voiddisconnected(com.badlogic.gdx.controllers.Controller controller) Get the mappings instance.booleanisActive()Is this listener active?booleanisKeyPressed(int buttonCode) Checks whether the button with the given code is pressed in the last controller used.booleanisKeyPressed(com.badlogic.gdx.controllers.Controller controller, int buttonCode) voidEvent notification call.abstract booleanpollAxes()abstract booleanvoidsetMappings(IGamepadMappings mappings) voidupdate()Update the listener.
-
Field Details
-
MIN_ZERO_POINT
protected static final float MIN_ZERO_POINT- See Also:
-
axisEventDelay
protected long axisEventDelayDelay between axis events. -
axisPollDelay
protected long axisPollDelayDelay between axis poll operations. -
buttonPollDelay
protected long buttonPollDelayDelay between button poll operations. -
em
Reference to the global event manager. -
active
Is this listener active? -
lastControllerUsed
protected com.badlogic.gdx.controllers.Controller lastControllerUsedReference to the last gaming controller that registered an input. -
mappings
Gamepad mappings instance. -
lastAxisEvtTime
protected long lastAxisEvtTimeLast axis event time. -
lastButtonPollTime
protected long lastButtonPollTimeLast button poll time.
-
-
Constructor Details
-
AbstractGamepadListener
-
AbstractGamepadListener
-
-
Method Details
-
applyZeroPoint
protected double applyZeroPoint(double value) Zero-point function for the axes. -
getMappings
Get the mappings instance.- Returns:
- The
IGamepadMappingsinstance for this listener.
-
setMappings
-
buttonDown
public boolean buttonDown(com.badlogic.gdx.controllers.Controller controller, int buttonCode) - Specified by:
buttonDownin interfacecom.badlogic.gdx.controllers.ControllerListener
-
buttonUp
public boolean buttonUp(com.badlogic.gdx.controllers.Controller controller, int buttonCode) - Specified by:
buttonUpin interfacecom.badlogic.gdx.controllers.ControllerListener
-
axisMoved
public boolean axisMoved(com.badlogic.gdx.controllers.Controller controller, int axisCode, float value) - Specified by:
axisMovedin interfacecom.badlogic.gdx.controllers.ControllerListener
-
isKeyPressed
public boolean isKeyPressed(int buttonCode) Checks whether the button with the given code is pressed in the last controller used.- Parameters:
buttonCode- The button code.- Returns:
- Whether the button is pressed in the last controller used.
-
isKeyPressed
public boolean isKeyPressed(com.badlogic.gdx.controllers.Controller controller, int buttonCode) -
anyPressed
public boolean anyPressed(int... buttonCodes) Returns true if any of the buttons are pressed in the last controller used.- Parameters:
buttonCodes- The buttons to test.- Returns:
- True if any of the given buttons is pressed.
-
anyPressed
public boolean anyPressed(com.badlogic.gdx.controllers.Controller controller, int... buttonCodes) Returns true if any of the buttons are pressed in the given controller.- Parameters:
controller- The controller.buttonCodes- The buttons to test.- Returns:
- True if any of the given buttons is pressed.
-
connected
public void connected(com.badlogic.gdx.controllers.Controller controller) - Specified by:
connectedin interfacecom.badlogic.gdx.controllers.ControllerListener
-
disconnected
public void disconnected(com.badlogic.gdx.controllers.Controller controller) - Specified by:
disconnectedin interfacecom.badlogic.gdx.controllers.ControllerListener
-
pollAxes
public abstract boolean pollAxes() -
pollButtons
public abstract boolean pollButtons() -
update
public void update()Description copied from interface:IInputListenerUpdate the listener.- Specified by:
updatein interfaceIInputListener
-
activate
public void activate()Description copied from interface:IInputListenerActivate the listener.- Specified by:
activatein interfaceIInputListener
-
deactivate
public void deactivate()Description copied from interface:IInputListenerDeactivate the listener.- Specified by:
deactivatein interfaceIInputListener
-
isActive
public boolean isActive()Is this listener active?- Returns:
- True if the listener is currently active.
-
notify
-