Files
TSE/TSE_Core/src/interfaces/IKeyInputHandler.cpp

52 lines
1.0 KiB
C++

#include "IKeyInputHandler.hpp"
#include "IInputManager.hpp"
TSE::IKeyInputHandler::~IKeyInputHandler()
{
if(enabled()) Disable();
}
bool TSE::IKeyInputHandler::enabled() const
{
return Enabled;
}
void TSE::IKeyInputHandler::Enable()
{
if(!enabled())
{
IInputManager::instance()->RegisterKeyHandler(this);
Enabled = true;
}
}
void TSE::IKeyInputHandler::Disable()
{
if(enabled())
{
IInputManager::instance()->UnregisterKeyHandler(this);
Enabled = false;
}
}
void TSE::IKeyInputHandler::onKeyDown(IKeyInputHandler *handler, const Key &key, const Modifier &mods)
{
handler->OnKeyDown(key, mods);
}
void TSE::IKeyInputHandler::onKeyUp(IKeyInputHandler *handler, const Key &key, const Modifier &mods)
{
handler->OnKeyUp(key, mods);
}
void TSE::IKeyInputHandler::onKeyHold(IKeyInputHandler *handler, const Key &key, const Modifier &mods)
{
handler->OnKeyHold(key, mods);
}
void TSE::IKeyInputHandler::onChar(IKeyInputHandler *handler, const std::string &c)
{
handler->OnChar(c);
}