Practical Tools for Simple Design
Loading...
Searching...
No Matches
Input.hpp
1#ifndef UTIL_EVENT_HPP
2#define UTIL_EVENT_HPP
3
4#include "pch.hpp" // IWYU pragma: export
5
6#include <SDL_events.h> // for SDL_Event
7#include <SDL_stdinc.h> // for Uint8
8
9#include "Util/Keycode.hpp" // for Keycode
10
11namespace Util {
12
20class Input {
21public:
22 Input() = delete;
23 Input(const Input &) = delete;
24 Input(Input &&) = delete;
25 ~Input() = delete;
26 Input &operator=(const Input &) = delete;
27
42 static glm::vec2 GetScrollDistance();
43
53 static glm::vec2 GetCursorPosition();
54
66 static bool IsKeyPressed(const Keycode &key);
67
79 static bool IsKeyDown(const Keycode &key);
80
92 static bool IsKeyUp(const Keycode &key);
93
99 static bool IfScroll();
100
105 static bool IsMouseMoving();
106
111 static bool IfExit();
112
122 static void SetCursorPosition(const glm::vec2 &pos);
123
129 static void Update();
130
131private:
132 static void UpdateKeyState(const SDL_Event *event);
133
134 static SDL_Event s_Event;
135
136 static glm::vec2 s_CursorPosition;
137 static glm::vec2 s_ScrollDistance;
138
139 static std::unordered_map<Keycode, std::pair<bool, bool>> s_KeyState;
140
141 static bool s_Scroll;
142 static bool s_MouseMoving;
143 static bool s_Exit;
144
145 static ImGuiIO s_Io;
146};
147
148} // namespace Util
149
150#endif // UTIL_EVENT_HPP
static bool IsMouseMoving()
Checks if the mouse is currently moving.
static bool IsKeyDown(const Keycode &key)
Check if a specific key is being pressed.
static void SetCursorPosition(const glm::vec2 &pos)
Sets the position of the cursor.
static glm::vec2 GetScrollDistance()
Retrieves the scroll distance of an element. .
static void Update()
Updates the state of the input.
static bool IsKeyPressed(const Keycode &key)
Check if a specific key is currently pressed.
static bool IfExit()
Checks if the window is closed.
static bool IfScroll()
Checks if the mouse wheel is currently being scrolled.
static glm::vec2 GetCursorPosition()
Retrieves the current position of the cursor.
static bool IsKeyUp(const Keycode &key)
Check if a specific key is being un-pressed.
Useful tools for development.
Definition Animation.hpp:12
Keycode
Definition Keycode.hpp:11