VEX Engine
Retro looking game engine made in vulkan mostly because i wanted to understand it better.
Loading...
Searching...
No Matches
vex::InputSystem Class Reference

Input system class responsible for handling input events and updating input components. More...

#include <InputSystem.hpp>

Classes

struct  KeyState
 Key state structure. Used to track the state of keyboard keys needed forr held state. More...

Public Member Functions

 InputSystem (vex::Registry &registry, SDL_Window *window)
 Constructor for InputSystem.
void setInputMode (InputMode mode)
 Sets the input processing mode.
InputMode getInputMode () const
 Gets the current input mode.
void processEvent (const SDL_Event &event, float deltaTime)
 Processes raw SDL events and maps them to Game Component actions.
void update (float deltaTime)
 Per-frame update for continuous input states.

Private Attributes

vex::Registrym_registry
SDL_Window * m_window
InputMode m_inputMode
std::unordered_map< SDL_Scancode, KeyStatekeyStates
std::unordered_map< SDL_GamepadButton, KeyStategamepadButtonStates
std::unordered_map< SDL_GamepadAxis, float > gamepadAxisStates

Detailed Description

Input system class responsible for handling input events and updating input components.

Definition at line 30 of file InputSystem.hpp.

Constructor & Destructor Documentation

◆ InputSystem()

vex::InputSystem::InputSystem ( vex::Registry & registry,
SDL_Window * window )

Constructor for InputSystem.

Parameters
vex::Registry&registry Reference to the entity registry.
SDL_Window*window Pointer to the SDL window.

Definition at line 10 of file InputSystem.cpp.

Member Function Documentation

◆ getInputMode()

InputMode vex::InputSystem::getInputMode ( ) const
inline

Gets the current input mode.

Returns
InputMode The current input mode.

Definition at line 46 of file InputSystem.hpp.

◆ processEvent()

void vex::InputSystem::processEvent ( const SDL_Event & event,
float deltaTime )

Processes raw SDL events and maps them to Game Component actions.

Handles:

  • Keyboard: Updates internal keyStates and triggers InputComponent bindings (Pressed/Released/Held).
  • Mouse: Accumulates relative motion deltas for axis bindings.
  • Gamepad: Handles button presses and axis motion (normalized to 0.0-1.0).
    Parameters
    constSDL_Event& event - The raw SDL_Event to parse.
    floatdeltaTime - Time elapsed, passed to action callbacks.

Definition at line 32 of file InputSystem.cpp.

◆ setInputMode()

void vex::InputSystem::setInputMode ( InputMode mode)

Sets the input processing mode.

  • Game: Captures the mouse (Relative Mode) and hides the cursor via SDL_SetWindowRelativeMouseMode.
  • UI: Releases the mouse and shows the cursor.
    Parameters
    InputModemode - The desired InputMode.

Definition at line 21 of file InputSystem.cpp.

◆ update()

void vex::InputSystem::update ( float deltaTime)

Per-frame update for continuous input states.

Specifically checks for and triggers actions bound to InputActionState::Held for both Keyboard and Gamepad buttons.

Parameters
floatdeltaTime - Time elapsed since last frame.

Definition at line 89 of file InputSystem.cpp.

Member Data Documentation

◆ gamepadAxisStates

std::unordered_map<SDL_GamepadAxis, float> vex::InputSystem::gamepadAxisStates
private

Definition at line 74 of file InputSystem.hpp.

◆ gamepadButtonStates

std::unordered_map<SDL_GamepadButton, KeyState> vex::InputSystem::gamepadButtonStates
private

Definition at line 73 of file InputSystem.hpp.

◆ keyStates

std::unordered_map<SDL_Scancode, KeyState> vex::InputSystem::keyStates
private

Definition at line 72 of file InputSystem.hpp.

◆ m_inputMode

InputMode vex::InputSystem::m_inputMode
private

Definition at line 71 of file InputSystem.hpp.

◆ m_registry

vex::Registry& vex::InputSystem::m_registry
private

Definition at line 69 of file InputSystem.hpp.

◆ m_window

SDL_Window* vex::InputSystem::m_window
private

Definition at line 70 of file InputSystem.hpp.


The documentation for this class was generated from the following files: