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.Returns the position of the cursor on the screen.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) boolean
getMouseButton
(int button, boolean stopPropagation) boolean
getMouseButton
(MouseButton button) boolean
getMouseButton
(MouseButton button, boolean stopPropagation) boolean
getMouseButtonDown
(int button) boolean
getMouseButtonDown
(int button, boolean stopPropagation) boolean
getMouseButtonDown
(MouseButton button) boolean
getMouseButtonDown
(MouseButton button, boolean stopPropagation) float
Returns the horizontal scroll factor.float
Returns the vertical scroll factor.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
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
-
getMouseButton
-
getMouseButton
public boolean getMouseButton(int button) -
getMouseButton
public boolean getMouseButton(int button, boolean stopPropagation) -
getMouseButtonDown
-
getMouseButtonDown
-
getMouseButtonDown
public boolean getMouseButtonDown(int button) -
getMouseButtonDown
public boolean getMouseButtonDown(int button, boolean stopPropagation) -
getScrollX
public float getScrollX()Returns the horizontal scroll factor.- Returns:
- Horizontal scroll
-
getScrollY
public float getScrollY()Returns the vertical scroll factor.- Returns:
- Vertical scroll
-
getCursor
Returns the position of the cursor on the screen. Returnsnull
if the cursor is being blocked.- Returns:
- Position of the cursor
-
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
-
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() -
getCursorBlocker
Returns the entity that is blocking the cursor in the current frame.
-