Package gaiasky.input
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 AtomicBooleanprotected longDelay between axis events.protected longDelay between axis poll operations.protected longDelay between button poll operations.protected final EventManagerprotected longprotected longprotected com.badlogic.gdx.controllers.Controllerprotected IGamepadMappingsprotected static final float -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractGamepadListener(IGamepadMappings mappings) protectedAbstractGamepadListener(String mappingsFile) -
Method Summary
Modifier and TypeMethodDescriptionvoidactivate()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) 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) voidvoiddisconnected(com.badlogic.gdx.controllers.Controller controller) booleanisActive()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()
-
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
-
active
-
lastControllerUsed
protected com.badlogic.gdx.controllers.Controller lastControllerUsed -
mappings
-
lastAxisEvtTime
protected long lastAxisEvtTime -
lastButtonPollTime
protected long lastButtonPollTime
-
-
Constructor Details
-
AbstractGamepadListener
-
AbstractGamepadListener
-
-
Method Details
-
applyZeroPoint
protected double applyZeroPoint(double value) Zero-point function for the axes. -
getMappings
-
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) -
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()- Specified by:
updatein interfaceIInputListener
-
activate
public void activate()- Specified by:
activatein interfaceIInputListener
-
deactivate
public void deactivate()- Specified by:
deactivatein interfaceIInputListener
-
isActive
public boolean isActive() -
notify
-