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
Modifier and TypeFieldDescriptionprotected final AtomicBoolean
protected long
Delay between axis events.protected long
Delay between axis poll operations.protected long
Delay between button poll operations.protected final EventManager
protected long
protected long
protected com.badlogic.gdx.controllers.Controller
protected IGamepadMappings
protected static final float
-
Constructor Summary
ModifierConstructorDescriptionprotected
AbstractGamepadListener
(IGamepadMappings mappings) protected
AbstractGamepadListener
(String mappingsFile) -
Method Summary
Modifier and TypeMethodDescriptionvoid
activate()
boolean
anyPressed
(int... buttonCodes) Returns true if any of the buttons are pressed in the last controller used.boolean
anyPressed
(com.badlogic.gdx.controllers.Controller controller, int... buttonCodes) protected double
applyZeroPoint
(double value) Zero-point function for the axes.boolean
axisMoved
(com.badlogic.gdx.controllers.Controller controller, int axisCode, float value) boolean
buttonDown
(com.badlogic.gdx.controllers.Controller controller, int buttonCode) boolean
buttonUp
(com.badlogic.gdx.controllers.Controller controller, int buttonCode) void
connected
(com.badlogic.gdx.controllers.Controller controller) void
void
disconnected
(com.badlogic.gdx.controllers.Controller controller) boolean
isActive()
boolean
isKeyPressed
(int buttonCode) Checks whether the button with the given code is pressed in the last controller used.boolean
isKeyPressed
(com.badlogic.gdx.controllers.Controller controller, int buttonCode) void
Event notification call.abstract boolean
pollAxes()
abstract boolean
void
setMappings
(IGamepadMappings mappings) void
update()
-
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:
buttonDown
in interfacecom.badlogic.gdx.controllers.ControllerListener
-
buttonUp
public boolean buttonUp(com.badlogic.gdx.controllers.Controller controller, int buttonCode) - Specified by:
buttonUp
in interfacecom.badlogic.gdx.controllers.ControllerListener
-
axisMoved
public boolean axisMoved(com.badlogic.gdx.controllers.Controller controller, int axisCode, float value) - Specified by:
axisMoved
in 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:
connected
in interfacecom.badlogic.gdx.controllers.ControllerListener
-
disconnected
public void disconnected(com.badlogic.gdx.controllers.Controller controller) - Specified by:
disconnected
in interfacecom.badlogic.gdx.controllers.ControllerListener
-
pollAxes
public abstract boolean pollAxes() -
pollButtons
public abstract boolean pollButtons() -
update
public void update()- Specified by:
update
in interfaceIInputListener
-
activate
public void activate()- Specified by:
activate
in interfaceIInputListener
-
deactivate
public void deactivate()- Specified by:
deactivate
in interfaceIInputListener
-
isActive
public boolean isActive() -
notify
Description copied from interface:IObserver
Event notification call.
-