InputProxy with a KeyboardInputHandler to translate keyboard keys to input commands. Input origins are bound to commands through the BindOrigin event, or through loading them from a config file.

This commit is contained in:
2015-12-11 11:39:20 +01:00
parent 5d46a10a4e
commit 35624008e7
13 changed files with 328 additions and 509 deletions
+8 -8
View File
@@ -31,7 +31,7 @@ Game::Game(int argc, char* argv[])
m_InputManager = new InputManager(m_Renderer->Window(), m_EventBroker);
m_InputProxy = new InputProxy(m_EventBroker);
m_InputProxy->AddHandler<KeyboardInputHandler>();
m_InputProxy->AddHandler<SteamControllerInputHandler>();
m_InputProxy->LoadBindings("Input.ini");
// Create the root level GUI frame
m_FrameStack = new GUI::Frame(m_EventBroker);
@@ -54,7 +54,7 @@ Game::Game(int argc, char* argv[])
m_LastTime = glfwGetTime();
testIntialize();
debugInitialize();
}
Game::~Game()
@@ -80,7 +80,7 @@ void Game::Tick()
// Iterate through systems and update world!
m_SystemPipeline->Update(m_World, dt);
testTick(dt);
debugTick(dt);
m_Renderer->Update(dt);
m_RenderQueueFactory->Update(m_World);
@@ -93,9 +93,9 @@ void Game::Tick()
}
bool Game::testOnKeyUp(const Events::KeyUp& e)
bool Game::debugOnInputCommand(const Events::InputCommand& e)
{
if (e.KeyCode == GLFW_KEY_R) {
if (e.Command == "DebugReload" && e.Value == 1) {
std::string mapToLoad = m_Config->Get<std::string>("Debug.LoadMap", "");
if (!mapToLoad.empty()) {
delete m_World;
@@ -108,12 +108,12 @@ bool Game::testOnKeyUp(const Events::KeyUp& e)
return false;
}
void Game::testIntialize()
void Game::debugInitialize()
{
EVENT_SUBSCRIBE_MEMBER(m_EKeyUp, &Game::testOnKeyUp);
EVENT_SUBSCRIBE_MEMBER(m_EInputCommand, &Game::debugOnInputCommand);
}
void Game::testTick(double dt)
void Game::debugTick(double dt)
{
m_EventBroker->Process<Game>();
}