aboutsummaryrefslogtreecommitdiff
path: root/src/engine/user/input.hpp
blob: 9f565c1de66f83d5a1b1bab7382360397b25d02a (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 <yacppdic/auto_wirable.hpp>

#include <memory>
#include <mutex>

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

	void listen() noexcept override;

	auto is_key_pressed(Key key) noexcept -> bool override;

	[[nodiscard]] auto get_currently_pressed_key() const noexcept -> Key override;

	void clear_currently_pressed() noexcept override;

private:
	Key _currently_pressed{};
	std::mutex _currently_pressed_mutex;
};