-
Notifications
You must be signed in to change notification settings - Fork 0
/
input.hpp
54 lines (37 loc) · 1.11 KB
/
input.hpp
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#ifndef INPUT_H
#define INPUT_H
#include <SFML/Graphics.hpp>
#include <map>
namespace input {
enum class Action { NONE, UP, DOWN, LEFT, RIGHT, DROP };
class InputHandler {
public:
virtual float get_value(const Action ac) = 0;
virtual bool is_connected() const = 0;
virtual ~InputHandler() = default;
bool in_use = false;
};
class KeyboardInputHandler : public InputHandler {
public:
KeyboardInputHandler(
sf::Keyboard::Key up,
sf::Keyboard::Key down,
sf::Keyboard::Key left,
sf::Keyboard::Key right,
sf::Keyboard::Key drop
);
virtual float get_value(const Action ac);
virtual bool is_connected() const;
private:
std::map<Action, sf::Keyboard::Key> action_map;
};
class ControllerInputHandler : public InputHandler {
public:
ControllerInputHandler(int id);
virtual float get_value(const Action ac);
virtual bool is_connected() const;
private:
int id;
};
}
#endif /* ifndef INPUT_H */