Package com.toxicrain.rainengine.util
Class InputUtils
java.lang.Object
com.toxicrain.rainengine.util.InputUtils
The InputUtils class provides help working with mice
-
Constructor Summary
ConstructorsConstructorDescriptionInputUtils
(com.github.strubium.windowmanager.window.WindowManager window) Constructs a InputUtils object with the specified window handle. -
Method Summary
Modifier and TypeMethodDescriptionstatic 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 offsetfloat[]
Gets the mouse position relative to the window.boolean
isKeyPressed
(int button) boolean
isMouseButtonPressed
(int button)
-
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 mousemouseY
- The y-coordinate of the mousescreenWidth
- The width of the screen or windowscreenHeight
- 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 mousemouseY
- The y-coordinate of the mousescreenWidth
- The width of the screen or windowscreenHeight
- 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)
-