← API Reference Class

asge::input::InputState

Queryable keyboard/mouse state, built by feeding it the SystemEvent stream.

#include <InputState.hpp>

Not a second input source: NewFrame()/Consume() accumulate the same SystemEvents Application::Run already pumps through IGame::OnSystemEvent, so games can poll (IsKeyDown, ...) instead of hand-tracking bools themselves.

Private Attributes

#std::array< bool, kKeyCount > m_KeyCurrentFrame {}private
#std::array< bool, kKeyCount > m_KeyPreviousFrame {}private
#std::array< bool, kMouseBCount > m_MouseCurrentFrame {}private
#std::array< bool, kMouseBCount > m_MousePreviousFrame {}private
#math::Float2 m_MousePos {}private
#math::Float2 m_PreviousMousePos {}private
#math::Float2 m_ScrollDelta {}private

Public Member Functions

#InputState()=default
#InputState(InputState const &)=default
#InputState(InputState &&)=default
#InputState & operator=(InputState const &)=default
#InputState & operator=(InputState &&)=default
#~InputState()=default
#void Consume(event::SystemEvent const &inEvent) noexcept

Folds one SystemEvent's key/mouse data into the current-frame state.

#void NewFrame() noexcept

Call once per frame, before pumping this frame's events, to roll current into previous.

#bool IsKeyDown(Keycode inKey) const noexcept

True while inKey is held down.

#bool IsKeyPressed(Keycode inKey) const noexcept

True only on the frame inKey went from up to down.

#bool IsKeyReleased(Keycode inKey) const noexcept

True only on the frame inKey went from down to up.

#bool IsMouseButtonDown(MouseButton inButton) const noexcept

True while inButton is held down.

#bool IsMouseButtonPressed(MouseButton inButton) const noexcept

True only on the frame inButton went from up to down.

#bool IsMouseButtonReleased(MouseButton inButton) const noexcept

True only on the frame inButton went from down to up.

#math::Float2 GetMousePosition() const noexcept

Mouse position, relative to the window.

#math::Float2 GetMouseDelta() const noexcept

Mouse movement since the last NewFrame().

#math::Float2 GetScrollDelta() const noexcept

Wheel scroll accumulated since the last NewFrame().