Skip to content

Engine → Platform → input_state.h

gamepad_state

Syntax

struct gamepad_state

Variables

AccessNameTypeDefaultDescription
publicaxesstd::array<f32, GAMEPAD_AXIS_COUNT>{}
publicbuttonsDownu320
publicbuttonsPressedu320
publicbuttonsReleasedu320
publicconnectedboolfalse

Functions

Public

axis

[[nodiscard]] f32 axis(
    gamepad_axis axisId) const noexcept;

The axis value; 0 for an invalid axis.

is_down

[[nodiscard]] bool is_down(
    gamepad_button button) const noexcept;

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

is_held

[[nodiscard]] bool is_held(
    gamepad_button button) const noexcept;

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

is_pressed

[[nodiscard]] bool is_pressed(
    gamepad_button button) const noexcept;

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

is_released

[[nodiscard]] bool is_released(
    gamepad_button button) const noexcept;

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

Operator Overloads

Public

operator==

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