Interface TestInput
@NonExtendable
public interface TestInput
The client gametest input handler used to simulate inputs to the client.
-
Method Summary
Modifier and TypeMethodDescriptionvoid
holdAlt()
Starts holding down left alt.void
Starts holding down left control, or left super on macOS.void
holdKey
(int keyCode) Starts holding down a key.void
holdKey
(Function<GameOptions, KeyBinding> keyBindingGetter) Starts holding down a key binding.void
holdKey
(KeyBinding keyBinding) Starts holding down a key binding.void
holdKey
(InputUtil.Key key) Starts holding down a key or mouse button.void
holdKeyFor
(int keyCode, int ticks) Holds a key for the specified number of ticks and then releases it.void
holdKeyFor
(Function<GameOptions, KeyBinding> keyBindingGetter, int ticks) Holds a key binding for the specified number of ticks and then releases it.void
holdKeyFor
(KeyBinding keyBinding, int ticks) Holds a key binding for the specified number of ticks and then releases it.void
holdKeyFor
(InputUtil.Key key, int ticks) Holds a key or mouse button for the specified number of ticks and then releases it.void
holdMouse
(int button) Starts holding down a mouse button.void
holdMouseFor
(int button, int ticks) Holds a mouse button for the specified number of ticks and then releases it.void
Starts holding down left shift.void
moveCursor
(double deltaX, double deltaY) Moves the cursor position.void
pressKey
(int keyCode) Presses and releases a key.void
pressKey
(Function<GameOptions, KeyBinding> keyBindingGetter) Presses and releases a key binding.void
pressKey
(KeyBinding keyBinding) Presses and releases a key binding.void
pressKey
(InputUtil.Key key) Presses and releases a key or mouse button.void
pressMouse
(int button) Presses and releases a mouse button.void
Releases left alt.void
Releases left control, or left super on macOS.void
releaseKey
(int keyCode) Releases a key.void
releaseKey
(Function<GameOptions, KeyBinding> keyBindingGetter) Releases a key binding.void
releaseKey
(KeyBinding keyBinding) Releases a key binding.void
releaseKey
(InputUtil.Key key) Releases a key or mouse button.void
releaseMouse
(int button) Releases a mouse button.void
Releases left shift.void
resizeWindow
(int width, int height) Resizes the window to match the given size.void
scroll
(double amount) Scrolls the mouse vertically.void
scroll
(double xAmount, double yAmount) Scrolls the mouse horizontally and vertically.void
setCursorPos
(double x, double y) Sets the cursor position.void
typeChar
(int codePoint) Types a code point (character).void
Types a sequence of code points (characters) one after the other.
-
Method Details
-
holdKey
Starts holding down a key binding. The key binding will be held until it is released. The key binding must be bound. Does nothing if the key binding is already being held.- Parameters:
keyBinding
- The key binding to hold- See Also:
-
holdKey
Starts holding down a key binding. The key binding will be held until it is released. The key binding must be bound. Does nothing if the key binding is already being held.- Parameters:
keyBindingGetter
- The function to get the key binding from the game options- See Also:
-
holdKey
Starts holding down a key or mouse button. The key will be held until it is released. Does nothing if the key or mouse button is already being held.- Parameters:
key
- The key or mouse button to hold- See Also:
-
holdKey
void holdKey(int keyCode) Starts holding down a key. The key will be held until it is released. Does nothing if the key is already being held.- Parameters:
keyCode
- The key code of the key to hold- See Also:
-
holdMouse
void holdMouse(int button) Starts holding down a mouse button. The mouse button will be held until it is released. Does nothing if the mouse button is already being held.- Parameters:
button
- The mouse button to hold- See Also:
-
holdControl
void holdControl()Starts holding down left control, or left super on macOS. Suitable for triggeringScreen.hasControlDown()
. The key will be held until it is released. Does nothing if the key is already being held.- See Also:
-
holdShift
void holdShift()Starts holding down left shift. Suitable for triggeringScreen.hasShiftDown()
. The key will be held until it is released. Does nothing if the key is already being held.- See Also:
-
holdAlt
void holdAlt()Starts holding down left alt. Suitable for triggeringScreen.hasAltDown()
. The key will be held until it is released. Does nothing if the key is already being held.- See Also:
-
releaseKey
Releases a key binding. The key binding must be bound. Does nothing if the key binding is not being held.- Parameters:
keyBinding
- The key binding to release- See Also:
-
releaseKey
Releases a key binding. The key binding must be bound. Does nothing if the key binding is not being held.- Parameters:
keyBindingGetter
- The function to get the key binding from the game options- See Also:
-
releaseKey
Releases a key or mouse button. Does nothing if the key or mouse button is not being held.- Parameters:
key
- The key or mouse button to release- See Also:
-
releaseKey
void releaseKey(int keyCode) Releases a key. Does nothing if the key is not being held.- Parameters:
keyCode
- The GLFW key code of the key to release- See Also:
-
releaseMouse
void releaseMouse(int button) Releases a mouse button. Does nothing if the mouse button is not being held.- Parameters:
button
- The GLFW mouse button to release- See Also:
-
releaseControl
void releaseControl()Releases left control, or left super on macOS. Suitable for un-triggeringScreen.hasControlDown()
. Does nothing if the key is not being held.- See Also:
-
releaseShift
void releaseShift()Releases left shift. Suitable for un-triggeringScreen.hasShiftDown()
. Does nothing if the key is not being held.- See Also:
-
releaseAlt
void releaseAlt()Releases left alt. Suitable for un-triggeringScreen.hasAltDown()
. Does nothing if the key is not being held.- See Also:
-
pressKey
Presses and releases a key binding. The key binding must be bound.- Parameters:
keyBinding
- The key binding to press- See Also:
-
pressKey
Presses and releases a key binding. The key binding must be bound.- Parameters:
keyBindingGetter
- The function to get the key binding from the game options- See Also:
-
pressKey
Presses and releases a key or mouse button.- Parameters:
key
- The key or mouse button to press.- See Also:
-
pressKey
void pressKey(int keyCode) Presses and releases a key.For sending Unicode text input (e.g. into text boxes), use
typeChar(int)
ortypeChars(String)
instead.- Parameters:
keyCode
- The GLFW key code of the key to press- See Also:
-
pressMouse
void pressMouse(int button) Presses and releases a mouse button.- Parameters:
button
- The GLFW mouse button to press- See Also:
-
holdKeyFor
Holds a key binding for the specified number of ticks and then releases it. Waits until this process is finished. The key binding must be bound.- Parameters:
keyBinding
- The key binding to holdticks
- The number of ticks to hold the key binding for- See Also:
-
holdKeyFor
Holds a key binding for the specified number of ticks and then releases it. Waits until this process is finished. The key binding must be bound.- Parameters:
keyBindingGetter
- The key binding to holdticks
- The number of ticks to hold the key binding for- See Also:
-
holdKeyFor
Holds a key or mouse button for the specified number of ticks and then releases it. Waits until this process is finished.- Parameters:
key
- The key or mouse button to holdticks
- The number of ticks to hold the key or mouse button for- See Also:
-
holdKeyFor
void holdKeyFor(int keyCode, int ticks) Holds a key for the specified number of ticks and then releases it. Waits until this process is finished.- Parameters:
keyCode
- The GLFW key code of the key to holdticks
- The number of ticks to hold the key for- See Also:
-
holdMouseFor
void holdMouseFor(int button, int ticks) Holds a mouse button for the specified number of ticks and then releases it. Waits until this process is finished.- Parameters:
button
- The GLFW mouse button to holdticks
- The number of ticks to hold the mouse button for- See Also:
-
typeChar
void typeChar(int codePoint) Types a code point (character). Useful for typing in text boxes.This method is for sending Unicode text input, not for pressing keys on the keyboard for other purposes, such as pressing
W
for moving the player. For those use cases, use one of thepressKey
overloads instead.- Parameters:
codePoint
- The code point to type- See Also:
-
typeChars
Types a sequence of code points (characters) one after the other. Useful for typing in text boxes.- Parameters:
chars
- The code points to type
-
scroll
void scroll(double amount) Scrolls the mouse vertically.- Parameters:
amount
- The amount to scroll by- See Also:
-
scroll
void scroll(double xAmount, double yAmount) Scrolls the mouse horizontally and vertically.- Parameters:
xAmount
- The horizontal amount to scroll byyAmount
- The vertical amount to scroll by- See Also:
-
setCursorPos
void setCursorPos(double x, double y) Sets the cursor position.- Parameters:
x
- The x position of the new cursor positiony
- The y position of the new cursor position- See Also:
-
moveCursor
void moveCursor(double deltaX, double deltaY) Moves the cursor position.- Parameters:
deltaX
- The amount to add to the x position of the cursordeltaY
- The amount to add to the y position of the cursor- See Also:
-
resizeWindow
void resizeWindow(int width, int height) Resizes the window to match the given size. Also attempts to resize the physical window, but whether the physical window was successfully resized or not, the window size accessible by the game will always be changed to the value specified, causing widget layouts and screenshots to work as expected.- Parameters:
width
- The new window widthheight
- The new window height
-