Class Input
java.lang.Object
dev.prozilla.pine.core.state.input.Input
- All Implemented Interfaces:
Lifecycle
Handles the GLFW input system.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
blockCursor
(Entity entity) Prevents the cursor from sending input to remaining entities in the current frame.void
blockCursor
(Entity entity, boolean override) Prevents the cursor from sending input to remaining entities in the current frame.void
destroy()
Destroys this input system.boolean
getAnyKey
(int... keys) Checks whether any key in an array is pressed.boolean
Checks whether any key in an array is pressed.getCursor
(boolean ignoreBlock) Returns the position of the cursor on the screen.Returns the entity that is blocking the cursor in the current frame.boolean
getKey
(int key) Checks whether a key is pressed.boolean
getKey
(int key, boolean stopPropagation) Checks whether a key is pressed.boolean
Checks whether a key is pressed.boolean
Checks whether a key is pressed.boolean
getKeyDown
(int key) Checks whether a key is down.boolean
getKeyDown
(int key, boolean stopPropagation) Checks whether a key is down.boolean
getKeyDown
(Key key) Checks whether a key is down.boolean
getKeyDown
(Key key, boolean stopPropagation) Checks whether a key is down.boolean
getKeys
(int... keys) Checks whether a combination of keys is pressed.boolean
Checks whether a combination of keys is pressed.boolean
getMouseButton
(int button) Checks whether a mouse button is pressed.boolean
getMouseButton
(int button, boolean stopPropagation) Checks whether a mouse button is pressed.boolean
getMouseButton
(MouseButton button) Checks whether a mouse button is pressed.boolean
getMouseButton
(MouseButton button, boolean stopPropagation) Checks whether a mouse button is pressed.boolean
getMouseButtonDown
(int button) Checks whether a mouse button is down.boolean
getMouseButtonDown
(int button, boolean stopPropagation) Checks whether a mouse button is down.boolean
getMouseButtonDown
(MouseButton button) Checks whether a mouse button is down.boolean
getMouseButtonDown
(MouseButton button, boolean stopPropagation) Checks whether a mouse button is down.float
float
Returns the position of the cursor inside the world.getWorldCursor
(boolean ignoreBlock) Returns the position of the cursor inside the world.void
init
(long window) Initializes the input system.void
input()
Prepare handling of input before input systems.boolean
Checks whether the cursor is being blocked.void
void
setCursorImage
(Image image) void
setCursorImage
(Image image, int offsetX, int offsetY) void
setCursorImage
(Image image, Vector2i offset) void
setCursorType
(int cursorType) Setter for the cursor type.void
setCursorType
(CursorType cursorType) Setter for the cursor type.void
update()
Finalize input handling after input systems.
-
Constructor Details
-
Input
Creates an input system.
-
-
Method Details
-
init
public void init(long window) Initializes the input system. -
input
public void input()Prepare handling of input before input systems. -
update
public void update()Finalize input handling after input systems. -
destroy
public void destroy()Destroys this input system. -
getAnyKey
Checks whether any key in an array is pressed.- Parameters:
keys
- Keys- Returns:
- True if any key is pressed
-
getAnyKey
public boolean getAnyKey(int... keys) Checks whether any key in an array is pressed.- Parameters:
keys
- Keys- Returns:
- True if any key is pressed
-
getKeys
Checks whether a combination of keys is pressed.- Parameters:
keys
- Keys- Returns:
- True if all keys are pressed
-
getKeys
public boolean getKeys(int... keys) Checks whether a combination of keys is pressed. Returns true in every frame that the key is pressed.- Parameters:
keys
- Keys- Returns:
- True if all keys are pressed
-
getKey
Checks whether a key is pressed. Returns true in every frame that the key is pressed.- Returns:
- True if the key is pressed
-
getKey
Checks whether a key is pressed. Returns true in every frame that the key is pressed.- Parameters:
stopPropagation
- Whether to stop this key from affecting other listeners- Returns:
- True if the key is pressed
-
getKey
public boolean getKey(int key) Checks whether a key is pressed. Returns true in every frame that the key is pressed.- Parameters:
key
- GLFW integer value for a key- Returns:
- True if the key is pressed.
-
getKey
public boolean getKey(int key, boolean stopPropagation) Checks whether a key is pressed. Returns true in every frame that the key is pressed.- Parameters:
key
- GLFW integer value for a keystopPropagation
- Whether to stop this key from affecting other listeners- Returns:
- True if the key is pressed.
-
getKeyDown
Checks whether a key is down. Returns true only in the first frame that the key is pressed.- Returns:
- True if the key is down in the current frame
-
getKeyDown
Checks whether a key is down. Returns true only in the first frame that the key is pressed.- Parameters:
stopPropagation
- Whether to stop this key from affecting other listeners- Returns:
- True if the key is down in the current frame
-
getKeyDown
public boolean getKeyDown(int key) Checks whether a key is down. Returns true only in the first frame that the key is pressed.- Parameters:
key
- GLFW integer value for a key- Returns:
- True if the key is down in the current frame
-
getKeyDown
public boolean getKeyDown(int key, boolean stopPropagation) Checks whether a key is down. Returns true only in the first frame that the key is pressed.- Parameters:
key
- GLFW integer value for a keystopPropagation
- Whether to stop this key from affecting other listeners- Returns:
- True if the key is down in the current frame
-
getMouseButton
Checks whether a mouse button is pressed.- Returns:
- True if the key is pressed.
-
getMouseButton
Checks whether a mouse button is pressed.- Parameters:
stopPropagation
- Whether to stop this mouse button from affecting other listeners- Returns:
- True if the key is pressed.
-
getMouseButton
public boolean getMouseButton(int button) Checks whether a mouse button is pressed.- Parameters:
button
- GLFW integer value for a mouse button- Returns:
- True if the key is pressed.
-
getMouseButton
public boolean getMouseButton(int button, boolean stopPropagation) Checks whether a mouse button is pressed.- Parameters:
button
- GLFW integer value for a mouse buttonstopPropagation
- Whether to stop this mouse button from affecting other listeners- Returns:
- True if the key is pressed.
-
getMouseButtonDown
Checks whether a mouse button is down.- Returns:
- True if the mouse button is down in the current frame
-
getMouseButtonDown
Checks whether a mouse button is down.- Parameters:
stopPropagation
- Whether to stop this mouse button from affecting other listeners- Returns:
- True if the mouse button is down in the current frame
-
getMouseButtonDown
public boolean getMouseButtonDown(int button) Checks whether a mouse button is down.- Parameters:
button
- GLFW integer value for a mouse button- Returns:
- True if the mouse button is down in the current frame
-
getMouseButtonDown
public boolean getMouseButtonDown(int button, boolean stopPropagation) Checks whether a mouse button is down.- Parameters:
button
- GLFW integer value for a mouse buttonstopPropagation
- Whether to stop this mouse button from affecting other listeners- Returns:
- True if the mouse button is down in the current frame
-
getScrollX
public float getScrollX()- Returns:
- Horizontal scroll factor.
-
getScrollY
public float getScrollY()- Returns:
- Vertical scroll factor.
-
getCursor
- Returns:
- Position of the cursor on the screen, or
null
if the cursor is being blocked.
-
getCursor
Returns the position of the cursor on the screen. Returnsnull
if the cursor is being blocked, unless blocks are being ignored.- Parameters:
ignoreBlock
- Whether to ignore blocks.- Returns:
- Position of the cursor
-
getWorldCursor
Returns the position of the cursor inside the world. Returnsnull
if the cursor is being blocked.- Returns:
- Position of the cursor
-
getWorldCursor
Returns the position of the cursor inside the world. Returnsnull
if the cursor is being blocked, unless blocks are being ignored.- Parameters:
ignoreBlock
- Whether to ignore blocks.- Returns:
- Position of the cursor
-
setCursorType
Setter for the cursor type. This value resets after every frame.- Parameters:
cursorType
- Cursor type
-
setCursorType
public void setCursorType(int cursorType) Setter for the cursor type. This value resets after every frame.- Parameters:
cursorType
- GLFW cursor type integer
-
setCursorImage
-
setCursorImage
-
setCursorImage
-
blockCursor
Prevents the cursor from sending input to remaining entities in the current frame.- Parameters:
entity
- Entity that is blocking the cursor
-
blockCursor
Prevents the cursor from sending input to remaining entities in the current frame.- Parameters:
entity
- Entity that is blocking the cursoroverride
- Whether to override any existing blocking entity.
-
isCursorBlocked
public boolean isCursorBlocked()Checks whether the cursor is being blocked. -
getCursorBlocker
Returns the entity that is blocking the cursor in the current frame. -
printCursorBlocker
public void printCursorBlocker()
-