Class Input

java.lang.Object
dev.prozilla.pine.core.state.input.Input
All Implemented Interfaces:
Lifecycle

public class Input extends Object implements Lifecycle
Handles the GLFW input system.
  • Constructor Details

    • Input

      public Input(Application application)
      Creates an input system.
  • Method Details

    • init

      public void init(long window)
      Initializes the input system.
      Specified by:
      init in interface Lifecycle
      Parameters:
      window - Window
    • input

      public void input()
      Prepare handling of input before input systems.
      Specified by:
      input in interface Lifecycle
    • update

      public void update()
      Finalize input handling after input systems.
      Specified by:
      update in interface Lifecycle
    • destroy

      public void destroy()
      Destroys this input system.
      Specified by:
      destroy in interface Lifecycle
    • getAnyKey

      public boolean getAnyKey(Key[] keys)
      Checks whether any key in an array is pressed.
      Parameters:
      keys - Keys
      Returns:
      True if any key is pressed
    • getAnyKey

      public boolean getAnyKey(int[] keys)
      Checks whether any key in an array is pressed.
      Parameters:
      keys - Keys
      Returns:
      True if any key is pressed
    • getKeys

      public boolean getKeys(Key[] keys)
      Checks whether a combination of keys is pressed.
      Parameters:
      keys - Keys
      Returns:
      True if all keys are pressed
    • getKeys

      public boolean getKeys(int[] keys)
      Checks whether a combination of keys is pressed. Returns true in every frame that the key is pressed.
      Parameters:
      keys - Keys
      Returns:
      True if all keys are pressed
    • getKey

      public boolean getKey(Key key)
      Checks whether a key is pressed. Returns true in every frame that the key is pressed.
      Returns:
      True if the key is pressed
    • getKey

      public boolean getKey(Key key, boolean stopPropagation)
      Checks whether a key is pressed. Returns true in every frame that the key is pressed.
      Parameters:
      stopPropagation - Whether to stop this key from affecting other listeners
      Returns:
      True if the key is pressed
    • getKey

      public boolean getKey(int key)
      Checks whether a key is pressed. Returns true in every frame that the key is pressed.
      Parameters:
      key - GLFW integer value for a key
      Returns:
      True if the key is pressed.
    • getKey

      public boolean getKey(int key, boolean stopPropagation)
      Checks whether a key is pressed. Returns true in every frame that the key is pressed.
      Parameters:
      key - GLFW integer value for a key
      stopPropagation - Whether to stop this key from affecting other listeners
      Returns:
      True if the key is pressed.
    • getKeyDown

      public boolean getKeyDown(Key key)
      Checks whether a key is down. Returns true only in the first frame that the key is pressed.
      Returns:
      True if the key is down in the current frame
    • getKeyDown

      public boolean getKeyDown(Key key, boolean stopPropagation)
      Checks whether a key is down. Returns true only in the first frame that the key is pressed.
      Parameters:
      stopPropagation - Whether to stop this key from affecting other listeners
      Returns:
      True if the key is down in the current frame
    • getKeyDown

      public boolean getKeyDown(int key)
      Checks whether a key is down. Returns true only in the first frame that the key is pressed.
      Parameters:
      key - GLFW integer value for a key
      Returns:
      True if the key is down in the current frame
    • getKeyDown

      public boolean getKeyDown(int key, boolean stopPropagation)
      Checks whether a key is down. Returns true only in the first frame that the key is pressed.
      Parameters:
      key - GLFW integer value for a key
      stopPropagation - Whether to stop this key from affecting other listeners
      Returns:
      True if the key is down in the current frame
    • getMouseButton

      public boolean getMouseButton(MouseButton button)
    • getMouseButton

      public boolean getMouseButton(MouseButton button, boolean stopPropagation)
    • getMouseButton

      public boolean getMouseButton(int button)
    • getMouseButton

      public boolean getMouseButton(int button, boolean stopPropagation)
    • getMouseButtonDown

      public boolean getMouseButtonDown(MouseButton button)
    • getMouseButtonDown

      public boolean getMouseButtonDown(MouseButton button, boolean stopPropagation)
    • getMouseButtonDown

      public boolean getMouseButtonDown(int button)
    • getMouseButtonDown

      public boolean getMouseButtonDown(int button, boolean stopPropagation)
    • getScrollX

      public float getScrollX()
      Returns the horizontal scroll factor.
      Returns:
      Horizontal scroll
    • getScrollY

      public float getScrollY()
      Returns the vertical scroll factor.
      Returns:
      Vertical scroll
    • getCursor

      public Vector2i getCursor()
      Returns the position of the cursor on the screen. Returns null if the cursor is being blocked.
      Returns:
      Position of the cursor
    • getCursor

      public Vector2i getCursor(boolean ignoreBlock)
      Returns the position of the cursor on the screen. Returns null if the cursor is being blocked, unless blocks are being ignored.
      Parameters:
      ignoreBlock - Whether to ignore blocks.
      Returns:
      Position of the cursor
    • getWorldCursor

      public Vector2f getWorldCursor()
      Returns the position of the cursor inside the world. Returns null if the cursor is being blocked.
      Returns:
      Position of the cursor
    • getWorldCursor

      public Vector2f getWorldCursor(boolean ignoreBlock)
      Returns the position of the cursor inside the world. Returns null if the cursor is being blocked, unless blocks are being ignored.
      Parameters:
      ignoreBlock - Whether to ignore blocks.
      Returns:
      Position of the cursor
    • setCursorType

      public void setCursorType(CursorType cursorType)
      Setter for the cursor type. This value resets after every frame.
      Parameters:
      cursorType - Cursor type
    • setCursorType

      public void setCursorType(int cursorType)
      Setter for the cursor type. This value resets after every frame.
      Parameters:
      cursorType - GLFW cursor type integer
    • blockCursor

      public void blockCursor(Entity entity)
      Prevents the cursor from sending input to remaining entities in the current frame.
      Parameters:
      entity - Entity that is blocking the cursor
    • blockCursor

      public void blockCursor(Entity entity, boolean override)
      Prevents the cursor from sending input to remaining entities in the current frame.
      Parameters:
      entity - Entity that is blocking the cursor
      override - Whether to override any existing blocking entity.
    • isCursorBlocked

      public boolean isCursorBlocked()
    • getCursorBlocker

      public Entity getCursorBlocker()
      Returns the entity that is blocking the cursor in the current frame.