Class InputUtils

java.lang.Object
com.toxicrain.rainengine.util.InputUtils

public class InputUtils extends Object
The InputUtils class provides help working with mice
  • Constructor Summary

    Constructors
    Constructor
    Description
    InputUtils(com.github.strubium.windowmanager.window.WindowManager window)
    Constructs a InputUtils object with the specified window handle.
  • Method Summary

    Modifier and Type
    Method
    Description
    static float[]
    convertToOpenGLCoordinates(float mouseX, float mouseY, int screenWidth, int screenHeight)
    Converts mouse coordinates to OpenGL coordinates.
    static float[]
    convertToOpenGLCoordinatesOffset(float mouseX, float mouseY, int screenWidth, int screenHeight, float offsetX, float offsetY)
    Converts mouse coordinates to OpenGL coordinates with an offset
    float[]
    Gets the mouse position relative to the window.
    boolean
    isKeyPressed(int button)
     
    boolean
     

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • InputUtils

      public InputUtils(com.github.strubium.windowmanager.window.WindowManager window)
      Constructs a InputUtils object with the specified window handle.
      Parameters:
      window - The window handle
  • Method Details

    • getMousePosition

      public float[] getMousePosition()
      Gets the mouse position relative to the window.
      Returns:
      A float array containing [mouseX, mouseY] coordinates
    • convertToOpenGLCoordinatesOffset

      public static float[] convertToOpenGLCoordinatesOffset(float mouseX, float mouseY, int screenWidth, int screenHeight, float offsetX, float offsetY)
      Converts mouse coordinates to OpenGL coordinates with an offset
      Parameters:
      mouseX - The x-coordinate of the mouse
      mouseY - The y-coordinate of the mouse
      screenWidth - The width of the screen or window
      screenHeight - The height of the screen or window
      Returns:
      A float array containing [openglMouseX, openglMouseY] coordinates
    • convertToOpenGLCoordinates

      public static float[] convertToOpenGLCoordinates(float mouseX, float mouseY, int screenWidth, int screenHeight)
      Converts mouse coordinates to OpenGL coordinates.
      Parameters:
      mouseX - The x-coordinate of the mouse
      mouseY - The y-coordinate of the mouse
      screenWidth - The width of the screen or window
      screenHeight - The height of the screen or window
      Returns:
      A float array containing [openglMouseX, openglMouseY] coordinates
    • isMouseButtonPressed

      public boolean isMouseButtonPressed(int button)
    • isKeyPressed

      public boolean isKeyPressed(int button)