Class KeyBindings<Action extends Enum<Action>>

java.lang.Object
dev.prozilla.pine.core.state.input.KeyBindings<Action>
Type Parameters:
Action - Enum of actions

public class KeyBindings<Action extends Enum<Action>> extends Object
Handles key bindings for the input system.
  • Constructor Details

    • KeyBindings

      public KeyBindings(Input input)
      Creates new key bindings.
      Parameters:
      input - Reference to input system
  • Method Details

    • addAction

      public void addAction(Action action, Key key)
      Binds a key to an action.
      Parameters:
      action - Action
      key - Key
    • addAction

      public void addAction(Action action, Key[] keys)
      Binds multiple keys to a single action.
      Parameters:
      action - Action
      keys - Key
    • removeAction

      public void removeAction(Action action)
      Unbinds the keys for a given action.
      Parameters:
      action - Action
    • getActionKey

      public Key getActionKey(Action action)
      Returns the key bound to a given action.
      Parameters:
      action - Action
      Returns:
      Key
    • getActionKeys

      public Key[] getActionKeys(Action action)
      Returns the keys bound to a given action.
      Parameters:
      action - Action
      Returns:
      Keys
    • isActive

      public boolean isActive(Action action)
      Checks whether the key(s) bound to a given action are pressed.
      Parameters:
      action - Action
      Returns:
      True if any key bound to the action is pressed
    • print

      public void print(Logger logger)
      Prints all key bindings.