Skip to content

πŸ“¦ Input

Ekrol34 edited this page Nov 25, 2025 · 1 revision

The Input module provides a unified system to handle user input from the keyboard, mouse, and joystick devices. It simplifies checking for pressed, held, or released states of keys and buttons, as well as retrieving mouse position and joystick axes.

It is built around the singleton INPUT class, with helper namespaces for Keyboard, Mouse, and Joystick.

Behaviour

  • Keyboard defines a complete set of key codes.
  • Mouse defines mouse button codes.
  • Joystick defines common controller buttons and exposes axis values.

The INPUT class manages all states and provides functions to query them.

Methods

Keyboard

IsKeyPressed

bool IsKeyPressed(Keyboard::Key key)

Checks if a key is currently being pressed.

Parameters:

  • key: Key code.

Returns: True if the key is pressed.


IsKeyDown

bool IsKeyDown(Keyboard::Key key)

Checks if a key was just pressed down (triggers once per press).

Parameters:

  • key: Key code.

Returns: True if the key was pressed in the current frame.


Mouse

IsMouseButtonPressed

bool IsMouseButtonPressed(Mouse::Button button)

Checks if a mouse button is currently being pressed.

Parameters:

  • button: Mouse button.

Returns: True if pressed.


IsMouseButtonDown

bool IsMouseButtonDown(Mouse::Button button)

Checks if a mouse button was just pressed down (triggers once per press).

Parameters:

  • button: Mouse button.

Returns: True if pressed in the current frame.


GetMousePosition

Vector2 GetMousePosition()

Retrieves the mouse position in world coordinates relative to the active window.

Returns: A Vector2 with the mouse coordinates.


GetMousePositionOnWindow

Vector2 GetMousePositionOnWindow()

Retrieves the mouse position in window pixel coordinates.

Returns: A Vector2 with the raw mouse position on the window.


Joystick

IsButtonPressed

bool IsButtonPressed(Joystick::Button button)

Checks if a joystick button is currently pressed.

Parameters:

  • button: Joystick button.

Returns: True if pressed.


IsButtonDown

bool IsButtonDown(Joystick::Button button)

Checks if a joystick button was just pressed down (triggers once per press).

Parameters:

  • button: Joystick button.

Returns: True if pressed in the current frame.


GetXYAxis

Vector2 GetXYAxis()

Gets the X/Y axis values of the joystick.

Returns: A Vector2 with axis data.


GetZRAxis

Vector2 GetZRAxis()

Gets the Z/R axis values of the joystick.

Returns: A Vector2 with axis data.


GetUVAxis

Vector2 GetUVAxis()

Gets the U/V axis values of the joystick.

Returns: A Vector2 with axis data.


GetPovAxis

Vector2 GetPovAxis()

Gets the POV hat axis values of the joystick.

Returns: A Vector2 with axis data.


GetJoystick

Joystick::JoystickPtr GetJoystick(int joystick)

Retrieves a joystick object by index.

Parameters:

  • joystick: Joystick ID (0–7).

Returns: A pointer to the joystick, or nullptr if not connected.


IsJoystickConnected

bool IsJoystickConnected(int joystick)

Checks if a joystick is connected.

Parameters:

  • joystick: Joystick ID (0–7).

Returns: True if connected.

Clone this wiki locally