~kiwec/ke

ke/src/Input.h -rw-r--r-- 684 bytes
1cc8481d — Wolf Clément Fix compilation 3 years ago
                                                                                
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
#pragma once

class InputHandler;
struct tb_event;

class Input {
private:
	static InputHandler* m_head;

public:
	static void add_handler(InputHandler*);
	static void remove_handler(InputHandler*);
	static void handle(tb_event* ev, bool is_mouse);
};

class InputHandler {
private:
	InputHandler* m_next = nullptr;
	friend class Input;

public:
	InputHandler() {
		Input::add_handler(this);
	}

	virtual ~InputHandler() {
		Input::remove_handler(this);
	}

	/// Handle keypresses
	/// returns true if the key was handled
	virtual bool handle_key(tb_event* ev) = 0;

	/// Handle mouse events
	/// returns true if the event was handled
	virtual bool handle_mouse(tb_event* ev) = 0;
};