galaxy 1.0.0
Real-Time C++23 Game Programming Framework. Built on data-driven design principles and agile software engineering.
Loading...
Searching...
No Matches
Input.cpp
Go to the documentation of this file.
1
7
8#include <SDL3/SDL_keyboard.h>
9
10#include "Input.hpp"
11
12namespace galaxy
13{
14 namespace input
15 {
16 bool is_key_mod_down(const KeyMods modifier) noexcept
17 {
18 const auto mod = static_cast<SDL_Keymod>(modifier);
19 return SDL_GetModState() & mod;
20 }
21
22 bool is_key_down(const Keys key) noexcept
23 {
24 const auto keys = SDL_GetKeyboardState(nullptr);
25 return keys[static_cast<SDL_Keycode>(key)];
26 }
27
28 bool is_mouse_down(const MouseButton btn) noexcept
29 {
30 const auto buttons = SDL_GetMouseState(nullptr, nullptr);
31 return buttons & SDL_BUTTON_MASK(static_cast<SDL_MouseButtonFlags>(btn));
32 }
33
34 glm::vec2 get_cursor_pos() noexcept
35 {
36 glm::vec2 vec2;
37 SDL_GetMouseState(&vec2.x, &vec2.y);
38
39 return vec2;
40 }
41 } // namespace input
42} // namespace galaxy
glm::vec2 get_cursor_pos() noexcept
Get current cursor position.
Definition Input.cpp:34
bool is_key_mod_down(const KeyMods modifier) noexcept
See if a key mod is being held down.
Definition Input.cpp:16
bool is_key_down(const Keys key) noexcept
See if a key is being held down.
Definition Input.cpp:22
bool is_mouse_down(const MouseButton btn) noexcept
Check if a mouse button was pressed.
Definition Input.cpp:28
Animated.cpp galaxy.
Definition Animated.cpp:16
Keys
Enum class representing keys.
Definition Keys.hpp:19
KeyMods
Enum class for key modifiers.
Definition Keys.hpp:282
MouseButton
Enum class representing mouse buttons.