Package rosequartz.input
Class InputManager
java.lang.Object
rosequartz.input.InputManager
Used to receive input from the user.
-
Method Summary
Modifier and TypeMethodDescriptionStops requesting text input from the user.voidforDisplayInput(BiConsumer<Float,Float> action)Executes the given function for all touch positions on mobile and the mouse position on desktop.voidforDisplayInput(Consumer<Vec2> action)Executes the given function for all touch positions on mobile and the mouse position on desktop.voidforTouch(BiConsumer<Float,Float> action)Executes the given function for all touch positions on mobile devices.voidExecutes the given function for all touch positions on mobile devices.Gamepad[]gamepads()Gets an array of all connected gamepads.static InputManagerget()Gets the input manager.booleanGets if touch input is used.booleanGets if a keyboard key is currently pressed.Gets the last used gamepad.booleanGets if a mouse button is currently pressed.mousePos()Gets the mouse's position.booleanGets if the mouse cursor is currently visible.floatmouseX()Gets the mouse's position on the x-axis.floatmouseY()Gets the mouse's position on the y-axis.Gets how far has been scrolled on the x- and y-axes.floatGets how far has been scrolled on the x-axis.floatGets how far has been scrolled on the y-axis.setMousePos(float x, float y)Sets the position of the mouse cursor.setMousePos(Vec2 xy)Sets the position of the mouse cursor.setMouseVisible(boolean v)Sets if the mouse cursor is visible.setScrolledDist(float x, float y)Sets how far has been scrolled on both axes.setScrolledDist(Vec2 xy)Sets how far has been scrolled on both axes.startTextInput(String value, boolean multiline)Start requesting text input from the user.booleanGets if the text input is currently active.booleanGets if the text input is currently multiline.Gets the value of the text input (what has been typed).
-
Method Details
-
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
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
Executes the given function for all touch positions on mobile devices.- Parameters:
action- function to execute
-
forTouch
Executes the given function for all touch positions on mobile devices.- Parameters:
action- function to execute
-
forDisplayInput
Executes the given function for all touch positions on mobile and the mouse position on desktop.- Parameters:
action- function to execute
-
forDisplayInput
Executes the given function for all touch positions on mobile and the mouse position on desktop.- Parameters:
action- function to execute
-
mouseButton
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
Sets the position of the mouse cursor.- Parameters:
x- new position on the x-axisy- new position on the y-axis- Returns:
- this
- Throws:
NotOnGraphicsThreadException
-
setMousePos
Sets the position of the mouse cursor.- Parameters:
xy- new position- Returns:
- this
- Throws:
NotOnGraphicsThreadException
-
setMouseVisible
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
Gets how far has been scrolled on the x- and y-axes.- Returns:
- scroll distance
-
setScrolledDist
Sets how far has been scrolled on both axes.- Parameters:
x- new scroll distance on x-axisy- new scroll distance on y-axis- Returns:
- this
-
setScrolledDist
Sets how far has been scrolled on both axes.- Parameters:
xy- new scroll distance- Returns:
- this
-
key
Gets if a keyboard key is currently pressed.- Parameters:
k- keyboard key to check- Returns:
- keyboard key pressed
-
startTextInput
Start requesting text input from the user. On mobile devices, this would open the soft keyboard.- Parameters:
value- starting input valuemultiline- support new lines- Returns:
- this
-
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
Stops requesting text input from the user. On mobile devices, this would close the soft keyboard.- Returns:
- this
-
gamepads
Gets an array of all connected gamepads.- Returns:
- array of all connected gamepads
-
mainGamepad
Gets the last used gamepad.- Returns:
- last used gamepad, NullGamepad if no gamepad connected
- See Also:
NullGamepad
-