From b74611d2b20fc071b8a699f2ce25e61f60118d6e Mon Sep 17 00:00:00 2001 From: HampusM Date: Sun, 22 May 2022 23:13:29 +0200 Subject: refactor: improve input handling & remove commands --- src/engine/user/input.hpp | 37 ++++++++++--------------------------- 1 file changed, 10 insertions(+), 27 deletions(-) (limited to 'src/engine/user/input.hpp') diff --git a/src/engine/user/input.hpp b/src/engine/user/input.hpp index f17472b..2fb97ac 100644 --- a/src/engine/user/input.hpp +++ b/src/engine/user/input.hpp @@ -5,40 +5,23 @@ #include -#include -#include #include -#include -#include +#include -class InputHandler : public IInputHandler, - public yacppdic::AutoWirable +class UserInputObserver + : public IUserInputObserver, + public yacppdic::AutoWirable { public: - InputHandler() noexcept = default; + UserInputObserver() noexcept = default; - void listen() const noexcept override; + void listen() noexcept override; - void subscribe( - const Event &event, - const std::shared_ptr> &subscriber) noexcept override; + bool is_key_pressed(Key key) noexcept override; - void notify_subscribers(const Event &event, const Context &context) - const noexcept override; - - void enter_raw_mode() noexcept override; - - void leave_raw_mode() noexcept override; + void clear_currently_pressed() noexcept override; private: - std::array< - std::vector>>, - static_cast(CHAR_MAX * 2U)> - _subscribers; - - std::shared_ptr _original_termios = nullptr; - - using SubscribersSizeType = decltype(_subscribers)::size_type; - - static auto _event_as_index(const Event &event) noexcept -> SubscribersSizeType; + Key _currently_pressed; + std::mutex _currently_pressed_mutex; }; -- cgit v1.2.3-18-g5258