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 Details

    • MIN_ZERO_POINT

      protected static final float MIN_ZERO_POINT
      See Also:
    • axisEventDelay

      protected long axisEventDelay
      Delay between axis events.
    • axisPollDelay

      protected long axisPollDelay
      Delay between axis poll operations.
    • buttonPollDelay

      protected long buttonPollDelay
      Delay between button poll operations.
    • em

      protected final EventManager em
    • active

      protected final AtomicBoolean active
    • lastControllerUsed

      protected com.badlogic.gdx.controllers.Controller lastControllerUsed
    • mappings

      protected IGamepadMappings mappings
    • lastAxisEvtTime

      protected long lastAxisEvtTime
    • lastButtonPollTime

      protected long lastButtonPollTime
  • Constructor Details

    • AbstractGamepadListener

      public AbstractGamepadListener(String mappingsFile)
    • AbstractGamepadListener

      public AbstractGamepadListener(IGamepadMappings mappings)
  • Method Details

    • applyZeroPoint

      protected double applyZeroPoint(double value)
      Zero-point function for the axes.
    • getMappings

      public IGamepadMappings getMappings()
    • setMappings

      public void setMappings(IGamepadMappings mappings)
    • buttonDown

      public boolean buttonDown(com.badlogic.gdx.controllers.Controller controller, int buttonCode)
      Specified by:
      buttonDown in interface com.badlogic.gdx.controllers.ControllerListener
    • buttonUp

      public boolean buttonUp(com.badlogic.gdx.controllers.Controller controller, int buttonCode)
      Specified by:
      buttonUp in interface com.badlogic.gdx.controllers.ControllerListener
    • axisMoved

      public boolean axisMoved(com.badlogic.gdx.controllers.Controller controller, int axisCode, float value)
      Specified by:
      axisMoved in interface com.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 interface com.badlogic.gdx.controllers.ControllerListener
    • disconnected

      public void disconnected(com.badlogic.gdx.controllers.Controller controller)
      Specified by:
      disconnected in interface com.badlogic.gdx.controllers.ControllerListener
    • pollAxes

      public abstract boolean pollAxes()
    • pollButtons

      public abstract boolean pollButtons()
    • update

      public void update()
      Specified by:
      update in interface IInputListener
    • activate

      public void activate()
      Specified by:
      activate in interface IInputListener
    • deactivate

      public void deactivate()
      Specified by:
      deactivate in interface IInputListener
    • isActive

      public boolean isActive()
    • notify

      public void notify(Event event, Object source, Object... data)
      Description copied from interface: IObserver
      Event notification call.
      Specified by:
      notify in interface IObserver
      Parameters:
      event - The event type.
      source - The source object, if any.
      data - The data associated with this event.