-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathModuleInput.h
75 lines (56 loc) · 1.14 KB
/
ModuleInput.h
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#ifndef __MODULEINPUT_H__
#define __MODULEINPUT_H__
#include "Module.h"
#include "Point.h"
#include "SDL_scancode.h"
#define NUM_MOUSE_BUTTONS 5
enum EventWindow
{
WE_QUIT = 0,
WE_HIDE = 1,
WE_SHOW = 2,
WE_COUNT
};
enum KeyState
{
KEY_IDLE = 0,
KEY_DOWN,
KEY_REPEAT,
KEY_UP
};
class ModuleInput : public Module
{
public:
ModuleInput();
// Destructor
virtual ~ModuleInput();
// Called before render is available
bool Init();
// Called before the first frame
bool Start();
// Called each loop iteration
update_status PreUpdate();
// Called before quitting
bool CleanUp();
// Check key states (includes mouse and joy buttons)
KeyState GetKey(int id) const
{
return keyboard[id];
}
KeyState GetMouseButtonDown(int id) const
{
return mouse_buttons[id - 1];
}
// Check for window events last frame
bool GetWindowEvent(EventWindow code) const;
// Get mouse / axis position
const iPoint& GetMouseMotion() const;
const iPoint& GetMousePosition() const;
private:
bool windowEvents[WE_COUNT];
KeyState* keyboard;
KeyState mouse_buttons[NUM_MOUSE_BUTTONS];
iPoint mouse_motion;
iPoint mouse;
};
#endif // __MODULEINPUT_H__