/** * @author: Thomas Brandého */ #ifndef KEYBINDINGS_H #define KEYBINDINGS_H #include #include #define NO_KEY -1 #define NO_ACTION -1 struct Binding{ int action; int key; int type; }; //write a function to add new Binding? class IKeysMap{ public: enum {PRESSED, RELEASED, HOLD}; IKeysMap(); std::vector getBindings(int action) const; protected: std::vector keys; }; class Context { public: Context(std::string name, std::vector actions); std::string getName(); std::vector getActions() const; private: std::string name; std::vector actions; }; class KeyBindings { public: KeyBindings(); KeyBindings(const Context &context, const IKeysMap &keysmap); int getPressedAction(int key) const; int getReleasedAction(int key) const; int getHoldAction(int key) const; private: std::unordered_map bindings_pressed; std::unordered_map bindings_released; std::unordered_map bindings_hold; void setPressedAction(int key, int action); void setReleasedAction(int key, int action); void setHoldAction(int key, int action); }; #endif