Basic input binding and command publishing system

This commit is contained in:
2014-05-05 09:17:58 +02:00
parent 5e7537b903
commit 0e068be77b
10 changed files with 233 additions and 11 deletions
+25 -1
View File
@@ -2,12 +2,19 @@
#define InputSystem_h__
#include <array>
#include <unordered_map>
#include "System.h"
#include "Renderer.h"
#include "Components/Input.h"
#include "Events/KeyUp.h"
#include "Events/KeyDown.h"
#include "Events/MousePress.h"
#include "Events/MouseRelease.h"
#include "Events/BindKey.h"
#include "Events/BindMouseButton.h"
#include "Events/InputCommand.h"
#include "Events/InputCommandValue.h"
namespace Systems
{
@@ -27,9 +34,26 @@ public:
private:
std::shared_ptr<Renderer> m_Renderer;
// Events
// Input binding tables
std::unordered_map<int, std::string> m_KeyBindings; // GLFW_KEY... -> command string
std::unordered_map<int, std::string> m_MouseButtonBindings; // GLFW_MOUSE_BUTTON... -> command string
// Input events
EventRelay<Events::KeyDown> m_EKeyDown;
bool OnKeyDown(const Events::KeyDown &event);
EventRelay<Events::KeyUp> m_EKeyUp;
bool OnKeyUp(const Events::KeyUp &event);
EventRelay<Events::MousePress> m_EMousePress;
bool OnMousePress(const Events::MousePress &event);
EventRelay<Events::MouseRelease> m_EMouseRelease;
bool OnMouseRelease(const Events::MouseRelease &event);
// Input binding events
EventRelay<Events::BindKey> m_EBindKey;
bool OnBindKey(const Events::BindKey &event);
EventRelay<Events::BindMouseButton> m_EBindMouseButton;
bool OnBindMouseButton(const Events::BindMouseButton &event);
void PublishCommand(int playerID, std::string command, bool release = false);
};
}