#ifndef ROGUE_INPUT_H #define ROGUE_INPUT_H #include <SDL2/SDL_events.h> #include <SDL2/SDL_scancode.h> #include <functional> #include <set> namespace rogue { struct InputHandler { InputHandler(); virtual ~InputHandler(); virtual void process_event(SDL_Event event) = 0; }; struct KeyEventHandler : public InputHandler { typedef std::function<void(bool down)> Listener; KeyEventHandler(std::set<SDL_Scancode> code, Listener listener); virtual void process_event(SDL_Event event) override; std::set<SDL_Scancode> scancode{}; Listener listener{}; }; class Input { public: static void add_handler(InputHandler *handler); static void remove_handler(InputHandler *handler); static void process_event(SDL_Event event); private: static std::set<InputHandler*> handlers; }; } #endif // !ROGUE_INPUT_H