From 1cc08c51eb4b0f95c30c0a98ad1fc5ad3459b2df Mon Sep 17 00:00:00 2001 From: Nicolas James Date: Wed, 12 Feb 2025 18:05:18 +1100 Subject: initial commit --- src/client/input.hh | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 src/client/input.hh (limited to 'src/client/input.hh') diff --git a/src/client/input.hh b/src/client/input.hh new file mode 100644 index 0000000..d5287a7 --- /dev/null +++ b/src/client/input.hh @@ -0,0 +1,48 @@ +#ifndef CLIENT_INPUT_HH_ +#define CLIENT_INPUT_HH_ + +#include +#include +#include +#include + +#include +#include + +#include "client/render/render.hh" + +namespace client { + +namespace input { + +// Called on every event during update, supports multiple handlers. +// using event_callback = void (*)(const SDL_Event&); +using event_callback = std::function; +void register_event_handler(const event_callback&) noexcept; + +// Empties our event queue while updating our inlines - also calls our +// registered callback functions per event. +void update() noexcept; + +void set_text_input(const bool should_start) noexcept; +void set_mouse_relative(const bool is_relative) noexcept; +void set_mouse_position(const glm::ivec2& d) noexcept; + +bool is_key_pressed(const SDL_Keycode& key) noexcept; +bool is_key_toggled(const SDL_Keycode& key) noexcept; + +struct state { + std::string text_input; + bool quit; + bool focused = true; + bool typing; + glm::vec2 mouse_pos; +}; + +inline state state; + +} // namespace input + +} // namespace client + +#endif -- cgit v1.2.3