Program Listing for File input_manager.h

Return to documentation for file (simple2dengine/managers/input_manager.h)

#ifndef _SIMPLE2DENGINE_MANAGERS_INPUT_MANAGER_H_
#define _SIMPLE2DENGINE_MANAGERS_INPUT_MANAGER_H_

#include <string>
#include <unordered_map>
#include <vector>

#include "SFML/Window/Keyboard.hpp"
#include "SFML/Window/Mouse.hpp"

#include "simple2dengine/nodes/node.h"

namespace simple2dengine
{
    class InputManager
    {
      public:
        void registerAction(const std::string& action, const sf::Keyboard::Key keyboardKey);
        void registerAction(const std::string& action, const sf::Mouse::Button mouseButton);
        void unregisterAction(const std::string& action);
        bool isActionPressed(const std::string& action) const;
        sf::Vector2i getMousePosition(const sf::Window& relativeTo) const;

      private:
        std::unordered_map<std::string, std::vector<sf::Keyboard::Key>>
            keyboardActions; // actions for keyboard buttons
        std::unordered_map<std::string, std::vector<sf::Mouse::Button>>
            mouseActions; // actions for mouse buttons
    };

} // namespace simple2dengine

#endif // _SIMPLE2DENGINE_MANAGERS_INPUT_MANAGER_H_