YoggieEngine/BarinkEngine/Input/InputManager.cpp

45 lines
1.0 KiB
C++

#include "Input/InputManager.h"
namespace BarinkEngine {
void InputManager::PollEvents()
{
for (auto it = windows.begin(); it != windows.end(); ++it) {
(*it)->Poll();
}
}
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);
}
void InputManager::attach(BarinkWindow* window)
{
windows.push_back(window);
this->Subscribe((EventListener&)(*window));
}
void InputManager::detach(BarinkWindow* window)
{
windows.remove(window);
this->Unsubscribe((EventListener&)*window);
}
InputManager::InputManager() : EventEmitter()
{
windows = std::list<BarinkWindow*>();
}
}