2022-06-04 16:26:58 +00:00
|
|
|
#include "Input/InputManager.h"
|
2022-06-10 20:44:40 +00:00
|
|
|
|
2022-06-19 18:01:31 +00:00
|
|
|
namespace BarinkEngine {
|
2022-06-10 20:44:40 +00:00
|
|
|
|
2022-06-19 18:01:31 +00:00
|
|
|
void InputManager::PollEvents()
|
2022-06-10 19:06:45 +00:00
|
|
|
{
|
2022-06-19 18:01:31 +00:00
|
|
|
for (auto it = windows.begin(); it != windows.end(); ++it) {
|
|
|
|
(*it)->Poll();
|
|
|
|
}
|
2022-06-10 19:06:45 +00:00
|
|
|
}
|
|
|
|
|
2022-06-10 20:44:40 +00:00
|
|
|
|
2022-06-19 18:01:31 +00:00
|
|
|
void InputManager::setupGLFWInput(GLFWwindow* window) {
|
|
|
|
// Attach callbacks
|
|
|
|
glfwSetKeyCallback(window, BarinkEngine::Input::BE_GLFW_KEYS);
|
|
|
|
glfwSetCursorPosCallback(window, BarinkEngine::Input::BE_GLFW_CURSOR_POSITION);
|
|
|
|
glfwSetCursorEnterCallback(window, BarinkEngine::Input::BE_GLFW_CURSOR_ENTER);
|
|
|
|
glfwSetMouseButtonCallback(window, BarinkEngine::Input::BE_GLFW_MOUSE_BUTTON);
|
|
|
|
glfwSetScrollCallback(window, BarinkEngine::Input::BE_GLFW_SCROLL);
|
2022-06-10 19:06:45 +00:00
|
|
|
}
|
2022-06-10 20:44:40 +00:00
|
|
|
|
|
|
|
|
2022-06-19 18:01:31 +00:00
|
|
|
void InputManager::attach(BarinkWindow* window)
|
|
|
|
{
|
|
|
|
windows.push_back(window);
|
|
|
|
this->Subscribe((EventListener&)(*window));
|
2022-06-10 20:44:40 +00:00
|
|
|
|
2022-06-10 19:06:45 +00:00
|
|
|
}
|
2022-06-10 20:44:40 +00:00
|
|
|
|
2022-06-19 18:01:31 +00:00
|
|
|
void InputManager::detach(BarinkWindow* window)
|
|
|
|
{
|
|
|
|
windows.remove(window);
|
|
|
|
this->Unsubscribe((EventListener&)*window);
|
2022-06-10 19:06:45 +00:00
|
|
|
}
|
|
|
|
|
2022-06-10 20:44:40 +00:00
|
|
|
|
2022-06-19 18:01:31 +00:00
|
|
|
InputManager::InputManager() : EventEmitter()
|
|
|
|
{
|
|
|
|
windows = std::list<BarinkWindow*>();
|
|
|
|
}
|
2022-06-10 20:44:40 +00:00
|
|
|
|
2022-06-04 16:26:58 +00:00
|
|
|
|
|
|
|
}
|
2022-06-10 20:44:40 +00:00
|
|
|
|