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
11#include "Util/Position.hpp" // Util::PTSDPosition
12
13namespace Util {
14
22class Input {
23public:
24 Input() = delete;
25 Input(const Input &) = delete;
26 Input(Input &&) = delete;
27 ~Input() = delete;
28 Input &operator=(const Input &) = delete;
29
44 static glm::vec2 GetScrollDistance();
45
55
67 static bool IsKeyPressed(const Keycode &key);
68
80 static bool IsKeyDown(const Keycode &key);
81
93 static bool IsKeyUp(const Keycode &key);
94
100 static bool IfScroll();
101
106 static bool IsMouseMoving();
107
112 static bool IfExit();
113
123 static void SetCursorPosition(const Util::PTSDPosition &pos);
124
130 static void Update();
131
132private:
133 static void UpdateKeyState(const SDL_Event *event);
134
135 static SDL_Event s_Event;
136
137 static Util::PTSDPosition s_CursorPosition;
138 static glm::vec2 s_ScrollDistance;
139
140 static std::unordered_map<Keycode, std::pair<bool, bool>> s_KeyState;
141
142 static bool s_Scroll;
143 static bool s_MouseMoving;
144 static bool s_Exit;
145
146 static ImGuiIO s_Io;
147};
148
149} // namespace Util
150
151#endif // UTIL_EVENT_HPP
The Input class provides access to keyboard and mouse input.
Definition: Input.hpp:22
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 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 void SetCursorPosition(const Util::PTSDPosition &pos)
Sets the position of the cursor.
static Util::PTSDPosition GetCursorPosition()
Retrieves the current position of the cursor.
static bool IfExit()
Checks if the window is closed.
static bool IfScroll()
Checks if the mouse wheel is currently being scrolled.
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
A class representing a position in a Cartesian coordinates.
Definition: Position.hpp:43