#pragma once // Must be the first include #include // Other includes #include #include "RenderBackend.h" #include namespace Gedeng { class Input { public: static void initialize(GLFWwindow *window) { glfwSetKeyCallback(window, key_callback); } // FIXME: Ignore warnings produced by these unused variables -- they're required for the callback to work static void key_callback(GLFWwindow *window, int key, int scancode, int action, int mods) { if (key == GLFW_KEY_ESCAPE && action == GLFW_PRESS) glfwSetWindowShouldClose(window, GLFW_TRUE); Input::set_key_down(key, action == GLFW_RELEASE ? false : true); } static void poll_input() { glfwPollEvents(); } static void set_key_down(int key, bool down) { keys_down[key] = down; } static bool is_key_down(int key) { return keys_down[key]; } inline static std::map keys_down; }; } // namespace Gedeng