Skip to content

Engine → Platform → input_state.h

input_state

Syntax

struct input_state

Variables

AccessNameTypeDefaultDescription
publiccursorInWindowbooltrue
publicframeIndexu640
publicgamepadsstd::array<gamepad_state, MAX_GAMEPADS>{}
publickeysDownkey_bitset{}
publickeysPressedkey_bitset{}
publickeysReleasedkey_bitset{}
publicmodifierskey_modifier_flagskey_modifier_flags::NONE
publicmouseButtonsDownu320
publicmouseButtonsPressedu320
publicmouseButtonsReleasedu320
publicmouseDeltamath::vec2math::vec2(0.0f)
publicmousePositionmath::vec2math::vec2(0.0f)
publicscrollDeltamath::vec2math::vec2(0.0f)
publictextCodepointsstd::array<u32, MAX_TEXT_CODEPOINTS_PER_FRAME>{}
publictextCountu320

Functions

Public

gamepad

[[nodiscard]] const gamepad_state &gamepad(
    u32 index) const noexcept;

The gamepad in a slot. Asserts on index >= MAX_GAMEPADS and then returns the last slot.

is_key_down

[[nodiscard]] bool is_key_down(
    key code) const noexcept;

True while the key is down, including the frame it was pressed in (is_key_held leaves that frame out).

is_key_held

[[nodiscard]] bool is_key_held(
    key code) const noexcept;

True while the key is down and this is not the frame it was pressed in.

is_key_pressed

[[nodiscard]] bool is_key_pressed(
    key code) const noexcept;

True in the frame the key went down.

is_key_released

[[nodiscard]] bool is_key_released(
    key code) const noexcept;

True in the frame the key came up.

is_mouse_button_down

[[nodiscard]] bool is_mouse_button_down(
    mouse_button button) const noexcept;

True while the mouse button is down, including the frame it was pressed in (is_mouse_button_held leaves that frame out); false for an invalid button.

is_mouse_button_held

[[nodiscard]] bool is_mouse_button_held(
    mouse_button button) const noexcept;

True while the mouse button is down and this is not the frame it was pressed in; false for an invalid button.

is_mouse_button_pressed

[[nodiscard]] bool is_mouse_button_pressed(
    mouse_button button) const noexcept;

True in the frame the mouse button went down; false for an invalid button.

is_mouse_button_released

[[nodiscard]] bool is_mouse_button_released(
    mouse_button button) const noexcept;

True in the frame the mouse button came up; false for an invalid button.

text

[[nodiscard]] std::span<const u32> text() const noexcept;

The UTF-32 code points typed this frame, in order (at most MAX_TEXT_CODEPOINTS_PER_FRAME).

Operator Overloads

Public

operator==

[[nodiscard]] bool operator==(
    const input_state &) const noexcept = default;