From ede689d23e57c9b701ab19aa9112a0b2368865c9 Mon Sep 17 00:00:00 2001 From: HampusM Date: Mon, 28 Feb 2022 21:30:30 +0100 Subject: feat: add input handler & quitting with 'q' --- src/engine/user/input.hpp | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 src/engine/user/input.hpp (limited to 'src/engine/user/input.hpp') diff --git a/src/engine/user/input.hpp b/src/engine/user/input.hpp new file mode 100644 index 0000000..f48ab86 --- /dev/null +++ b/src/engine/user/input.hpp @@ -0,0 +1,31 @@ +#pragma once + +#include "DI/auto_wirable.hpp" +#include "interfaces/input.hpp" +#include "interfaces/observable.hpp" + +#include +#include +#include +#include + +class InputHandler : public IInputHandler, public AutoWirable +{ +public: + InputHandler() = default; + + void listen() const override; + + void attach(const char &event, Callback callback) override; + + void notify(const char &event) const override; + + void enter_raw_mode() override; + + void leave_raw_mode() override; + +private: + std::unordered_map> _key_observers; + + std::shared_ptr _original_termios = nullptr; +}; -- cgit v1.2.3-18-g5258