Interface IInputHandler


public interface IInputHandler
This class handles all of the keyboard and mouse input. To access these methods, use IGameInstance.getInput().
See Also:
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    allowKeyboardEvents(boolean allow)
    A setter for wether keyboard repeat events should be allowed.
    int
    Returns the amount of delta that the mouse wheel has been shifted horizontally since the last tick.
    int
    Returns the amount of delta that the mouse wheel has been turned since the last tick.
    int
    Gets the mouse's current x coordinate on screen.
    int
    Gets the mouse's current y coordinate on screen
    boolean
    isKeyDown(int key)
    Return true if the given key is currently being held down
    boolean
    isMouseDown(int button)
    Returns true if the given mouse button is currently being held down
    boolean
    Returns true if the mouse cursor is currently inside of the window.
    boolean
    wasKeyPressed(int key)
    Returns true if a keyboard key was singly pressed inbetween the last tick and this one.
    boolean
    wasMousePressed(int button)
    Returns true if the mouse was singly pressed inbetween the last tick and this one.
  • Method Details

    • isMouseInWindow

      boolean isMouseInWindow()
      Returns true if the mouse cursor is currently inside of the window. This can be useful to avoid unnecessary mouse position checking
      Returns:
      If the mouse is in the window
    • isMouseDown

      boolean isMouseDown(int button)
      Returns true if the given mouse button is currently being held down
      Parameters:
      button - The button to query. Use the GLFW class to easily get mouse buttons' ids
      Returns:
      If the button is down
      See Also:
    • wasMousePressed

      boolean wasMousePressed(int button)
      Returns true if the mouse was singly pressed inbetween the last tick and this one. This should be used for things like buttons where you don't want a held press to trigger something multiple times.
      Parameters:
      button - The button toe query. Use the GLFW class to easily get mouse buttons' ids
      Returns:
      If the button was pressed lately
      See Also:
    • isKeyDown

      boolean isKeyDown(int key)
      Return true if the given key is currently being held down
      Parameters:
      key - The key to query. Use the GLFW class to easily get keys' ids
      Returns:
      If the key is down
      See Also:
    • wasKeyPressed

      boolean wasKeyPressed(int key)
      Returns true if a keyboard key was singly pressed inbetween the last tick and this one. This should be used for things like buttons where you don't want a held press to trigger something multiple times.
      Parameters:
      key - The key to query. Use the GLFW class to easily get keys' ids
      Returns:
      If the key was pressed lately
      See Also:
    • getMouseWheelChange

      int getMouseWheelChange()
      Returns the amount of delta that the mouse wheel has been turned since the last tick. A negative amount indicates a turning in the other direction.
      Returns:
      The mouse wheel change
      See Also:
    • getHorizontalMouseWheelChange

      int getHorizontalMouseWheelChange()
      Returns the amount of delta that the mouse wheel has been shifted horizontally since the last tick. A negative amount indicates a shifting to the left. This is, obviously, not supported by all mouses.
      Returns:
      The horizontal mouse wheel change
      See Also:
    • getMouseX

      int getMouseX()
      Gets the mouse's current x coordinate on screen.
      Returns:
      The mouse's x coordinate
      See Also:
    • getMouseY

      int getMouseY()
      Gets the mouse's current y coordinate on screen
      Returns:
      The mouse's y coordinate
      See Also:
    • allowKeyboardEvents

      void allowKeyboardEvents(boolean allow)
      A setter for wether keyboard repeat events should be allowed. Setting this to true means that, when holding down a keyboard key, wasKeyPressed(int) will be triggered again after a short while. This is automatically enabled in Guis and can be useful for when you want to, say, remove a big amount of text by just holding down the backspace key.

      Note that this method should actually be called "allowKeyboardRepeats". Oh well.

      Parameters:
      allow - If repeated keyboard events should be allowed