aboutsummaryrefslogtreecommitdiff
path: root/src/engine/user/input.hpp
blob: 12c27ee51396d5d8afc67e8a03731a9c260c050c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#pragma once

#include "interfaces/input.hpp"

#include <yacppdic/auto_wirable.hpp>

#include <memory>
#include <mutex>
#include <string>

class UserInputObserver
	: public IUserInputObserver,
	  public yacppdic::AutoWirable<IUserInputObserver, UserInputObserver>
{
public:
	UserInputObserver() noexcept = default;

	void listen() noexcept override;

	auto get_currently_pressed_key() noexcept -> Key override;

private:
	std::string _input_buffer;
	mutable std::mutex _input_buffer_mutex;

	auto _get_input_buffer() const noexcept -> std::string;

	void _set_input_buffer(const std::string &input_buffer) noexcept;
};