#include "IInputManager.hpp"

TSE::IInputManager* TSE::IInputManager::Instance = nullptr;

TSE::IInputManager *TSE::IInputManager::instance()
{
    return Instance;
}

void TSE::IInputManager::RegisterCursorHandler(ICursorHandler *handler)
{
    cursorHandler.push_back(handler);
}

void TSE::IInputManager::UnregisterCursorHandler(ICursorHandler *handler)
{
    for(auto it = cursorHandler.begin(); it != cursorHandler.end(); it++)
    {
        if(*it == handler)
        {
            cursorHandler.erase(it);
            return;
        }
    }
}

void TSE::IInputManager::RegisterKeyHandler(IKeyInputHandler *handler)
{
    keyHandler.push_back(handler);
}

void TSE::IInputManager::UnregisterKeyHandler(IKeyInputHandler *handler)
{
    for(auto it = keyHandler.begin(); it != keyHandler.end(); it++)
    {
        if(*it == handler)
        {
            keyHandler.erase(it);
            return;
        }
    }
}
