aboutsummaryrefslogtreecommitdiff
path: root/src/engine/user/input.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/engine/user/input.hpp')
-rw-r--r--src/engine/user/input.hpp37
1 files changed, 10 insertions, 27 deletions
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 <yacppdic/auto_wirable.hpp>
-#include <array>
-#include <climits>
#include <memory>
-#include <termios.h>
-#include <vector>
+#include <mutex>
-class InputHandler : public IInputHandler,
- public yacppdic::AutoWirable<IInputHandler, InputHandler>
+class UserInputObserver
+ : public IUserInputObserver,
+ public yacppdic::AutoWirable<IUserInputObserver, UserInputObserver>
{
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<ISubscriber<Context>> &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<std::shared_ptr<ISubscriber<Context>>>,
- static_cast<std::size_t>(CHAR_MAX * 2U)>
- _subscribers;
-
- std::shared_ptr<termios> _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;
};