Class InputManager

java.lang.Object
rosequartz.input.InputManager

public final class InputManager extends Object
Used to receive input from the user.
  • Method Details

    • get

      public static InputManager get()
      Gets the input manager.
      Returns:
      InputManager-object
      See Also:
      InputManager
    • mouseX

      public float mouseX()
      Gets the mouse's position on the x-axis. Returns the position of the 'primary' touching finger on mobile devices.
      Returns:
      mouse position on x-axis
    • mouseY

      public float mouseY()
      Gets the mouse's position on the y-axis. Returns the position of the 'primary' touching finger on mobile devices.
      Returns:
      mouse position on y-axis
    • mousePos

      public Vec2 mousePos()
      Gets the mouse's position. Returns the position of the 'primary' touching finger on mobile devices.
      Returns:
      mouse position on y-axis
    • hasTouchInput

      public boolean hasTouchInput()
      Gets if touch input is used. This may be used to show a digital touch-joystick on the screen for mobile users instead of requesting key inputs.
      Returns:
      touch input in use
    • forTouch

      public void forTouch(BiConsumer<Float,​Float> action)
      Executes the given function for all touch positions on mobile devices.
      Parameters:
      action - function to execute
    • forTouch

      public void forTouch(Consumer<Vec2> action)
      Executes the given function for all touch positions on mobile devices.
      Parameters:
      action - function to execute
    • forDisplayInput

      public void forDisplayInput(BiConsumer<Float,​Float> action)
      Executes the given function for all touch positions on mobile and the mouse position on desktop.
      Parameters:
      action - function to execute
    • forDisplayInput

      public void forDisplayInput(Consumer<Vec2> action)
      Executes the given function for all touch positions on mobile and the mouse position on desktop.
      Parameters:
      action - function to execute
    • mouseButton

      public boolean mouseButton(MouseButton b)
      Gets if a mouse button is currently pressed. If 'b' is equal to 'MouseButton.LEFT', it checks if the screen is touched instead.
      Parameters:
      b - mouse button to check
      Returns:
      mouse button pressed
    • mouseVisible

      public boolean mouseVisible()
      Gets if the mouse cursor is currently visible.
      Returns:
      mouse cursor visible
    • setMousePos

      public InputManager setMousePos(float x, float y) throws NotOnGraphicsThreadException
      Sets the position of the mouse cursor.
      Parameters:
      x - new position on the x-axis
      y - new position on the y-axis
      Returns:
      this
      Throws:
      NotOnGraphicsThreadException
    • setMousePos

      public InputManager setMousePos(Vec2 xy) throws NotOnGraphicsThreadException
      Sets the position of the mouse cursor.
      Parameters:
      xy - new position
      Returns:
      this
      Throws:
      NotOnGraphicsThreadException
    • setMouseVisible

      public InputManager setMouseVisible(boolean v)
      Sets if the mouse cursor is visible.
      Parameters:
      v - mouse cursor visible
      Returns:
      this
    • scrolledX

      public float scrolledX()
      Gets how far has been scrolled on the x-axis.
      Returns:
      scroll distance on x-axis
    • scrolledY

      public float scrolledY()
      Gets how far has been scrolled on the y-axis.
      Returns:
      scroll distance on y-axis
    • scrolledDist

      public Vec2 scrolledDist()
      Gets how far has been scrolled on the x- and y-axes.
      Returns:
      scroll distance
    • setScrolledDist

      public InputManager setScrolledDist(float x, float y)
      Sets how far has been scrolled on both axes.
      Parameters:
      x - new scroll distance on x-axis
      y - new scroll distance on y-axis
      Returns:
      this
    • setScrolledDist

      public InputManager setScrolledDist(Vec2 xy)
      Sets how far has been scrolled on both axes.
      Parameters:
      xy - new scroll distance
      Returns:
      this
    • key

      public boolean key(Key k)
      Gets if a keyboard key is currently pressed.
      Parameters:
      k - keyboard key to check
      Returns:
      keyboard key pressed
    • startTextInput

      public InputManager startTextInput(String value, boolean multiline)
      Start requesting text input from the user. On mobile devices, this would open the soft keyboard.
      Parameters:
      value - starting input value
      multiline - support new lines
      Returns:
      this
    • textInputText

      public String textInputText()
      Gets the value of the text input (what has been typed).
      Returns:
      text input value
    • textInputActive

      public boolean textInputActive()
      Gets if the text input is currently active.
      Returns:
      text input active
    • textInputMultiline

      public boolean textInputMultiline()
      Gets if the text input is currently multiline. Returns false if the text input is not active
      Returns:
      text input multiline && text input active
    • endTextInput

      public InputManager endTextInput()
      Stops requesting text input from the user. On mobile devices, this would close the soft keyboard.
      Returns:
      this
    • gamepads

      public Gamepad[] gamepads()
      Gets an array of all connected gamepads.
      Returns:
      array of all connected gamepads
    • mainGamepad

      public Gamepad mainGamepad()
      Gets the last used gamepad.
      Returns:
      last used gamepad, NullGamepad if no gamepad connected
      See Also:
      NullGamepad