aboutsummaryrefslogtreecommitdiff
path: root/src/engine/user/input.hpp
blob: 9e8196def7f7a62d75ee0a8fd44d7cf0a9baf9b6 (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
#pragma once

#include "interfaces/input.hpp"

#include <memory>
#include <mutex>
#include <string>
#include <yacppdic/auto_wirable.hpp>

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;
};