VEX Engine
Retro looking game engine made in vulkan mostly because i wanted to understand it better.
Loading...
Searching...
No Matches
InputSystem.hpp
Go to the documentation of this file.
1
6
7#pragma once
8#define SDL_MAIN_HANDLED
9#include <SDL3/SDL.h>
11#include <unordered_map>
12#include "SDL3/SDL_mouse.h"
14#include "components/ErrorUtils.hpp"
15
16
17namespace vex {
18
23enum class InputMode {
24 Game,
25 UI,
26 GameAndUI
27};
28
31public:
35 InputSystem(vex::Registry& registry, SDL_Window* window);
36
42 void setInputMode(InputMode mode);
43
46 InputMode getInputMode() const { return m_inputMode; }
47
55 void processEvent(const SDL_Event& event, float deltaTime);
56
60 void update(float deltaTime);
61
62private:
64 struct KeyState {
65 bool isPressed = false;
66 bool wasProcessedAsPressed = false;
67 };
68
69 vex::Registry& m_registry;
70 SDL_Window* m_window;
71 InputMode m_inputMode;
72 std::unordered_map<SDL_Scancode, KeyState> keyStates;
73 std::unordered_map<SDL_GamepadButton, KeyState> gamepadButtonStates;
74 std::unordered_map<SDL_GamepadAxis, float> gamepadAxisStates;
75};
76
77}
Main header for the Entity Component System (ECS) framework.
Component you add to your GameObject to handle input, eg. add input bindings and mouse axis bindings.
void setInputMode(InputMode mode)
Sets the input processing mode.
void update(float deltaTime)
Per-frame update for continuous input states.
InputSystem(vex::Registry &registry, SDL_Window *window)
Constructor for InputSystem.
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.
Central registry for managing entities and their components in the ECS system.
Definition Registry.hpp:29
InputMode
Enum representing different input modes.
Key state structure. Used to track the state of keyboard keys needed forr held state.