vengine  0.0.1
3D graphics engine
Loading...
Searching...
No Matches
EventManager.hpp
Go to the documentation of this file.
1///
2/// @file EventManager.hpp
3/// @brief This file contains the EventManager class
4/// @namespace ven
5///
6
7#pragma once
8
11
12namespace ven {
13
14 struct KeyAction {
15 uint16_t key;
16 glm::vec3* dir;
17 glm::vec3 value;
18 };
19
20 struct KeyMappings {
21 uint16_t moveLeft = GLFW_KEY_A;
22 uint16_t moveRight = GLFW_KEY_D;
23 uint16_t moveForward = GLFW_KEY_W;
24 uint16_t moveBackward = GLFW_KEY_S;
25 uint16_t moveUp = GLFW_KEY_SPACE;
26 uint16_t moveDown = GLFW_KEY_LEFT_SHIFT;
27 uint16_t lookLeft = GLFW_KEY_LEFT;
28 uint16_t lookRight = GLFW_KEY_RIGHT;
29 uint16_t lookUp = GLFW_KEY_UP;
30 uint16_t lookDown = GLFW_KEY_DOWN;
31 uint16_t toggleGui = GLFW_KEY_0;
32 };
33
34 static constexpr float EPSILON = std::numeric_limits<float>::epsilon();
36
37 ///
38 /// @class EventManager
39 /// @brief Class for event manager
40 /// @namespace ven
41 ///
43
44 public:
45
46 EventManager() = default;
47 ~EventManager() = default;
48
49 EventManager(const EventManager&) = delete;
53
54 void handleEvents(GLFWwindow *window, ENGINE_STATE *engineState, Camera& camera, Gui& gui, float dt) const;
55
56 private:
57
58 static void moveCamera(GLFWwindow* window, Camera& camera, float dt);
59 static void updateEngineState(ENGINE_STATE *engineState, const ENGINE_STATE newState) { *engineState = newState; }
60 static bool isKeyJustPressed(GLFWwindow* window, long unsigned int key, std::array<bool, GLFW_KEY_LAST>& keyStates);
61
62 template<typename Iterator>
63 static void processKeyActions(GLFWwindow* window, Iterator begin, Iterator end);
64
65 mutable std::array<bool, GLFW_KEY_LAST> m_keyState{};
66
67 }; // class EventManager
68
69} // namespace ven
This file contains the ImGuiWindowManager class.
This file contains utils for VEngine.
Class for camera.
Definition Camera.hpp:28
Class for event manager.
EventManager & operator=(const EventManager &)=delete
EventManager()=default
EventManager(EventManager &&)=delete
~EventManager()=default
void handleEvents(GLFWwindow *window, ENGINE_STATE *engineState, Camera &camera, Gui &gui, float dt) const
std::array< bool, GLFW_KEY_LAST > m_keyState
static void moveCamera(GLFWwindow *window, Camera &camera, float dt)
static void processKeyActions(GLFWwindow *window, Iterator begin, Iterator end)
static bool isKeyJustPressed(GLFWwindow *window, long unsigned int key, std::array< bool, GLFW_KEY_LAST > &keyStates)
static void updateEngineState(ENGINE_STATE *engineState, const ENGINE_STATE newState)
EventManager(const EventManager &)=delete
EventManager & operator=(EventManager &&)=delete
Class for Gui.
Definition Gui.hpp:30
ENGINE_STATE
Definition Utils.hpp:13
static constexpr KeyMappings DEFAULT_KEY_MAPPINGS
static constexpr float EPSILON
glm::vec3 * dir