-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInputController.cpp
More file actions
95 lines (82 loc) · 1.85 KB
/
Copy pathInputController.cpp
File metadata and controls
95 lines (82 loc) · 1.85 KB
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#include "src/InputController.h"
namespace gamein{
bool InputController::_playerDead = false;
bool InputController::_respawn = false;
InputController::InputController(){}
InputController& InputController::get()
{
static InputController instance;
return instance;
}
bool InputController::getExitSignal()
{
return _exitSignal;
}
bool InputController::HandleInput(Camera * cam, bool& fireSignal, bool running)
{
SDL_Event event;
while(SDL_PollEvent(&event))
{
switch(event.type)
{
case SDL_QUIT:
running = false;
break;
case SDL_KEYDOWN:
switch(event.key.keysym.sym)
{
case SDLK_ESCAPE:
running = false;
_exitSignal = true;
break;
case SDLK_p:
cam->mouseIn();
SDL_ShowCursor(SDL_ENABLE);
break;
case SDLK_RETURN:
break;
default: break;
}
break;
case SDL_KEYUP:
switch(event.key.keysym.sym)
{
case SDLK_ESCAPE:
running = false;
_exitSignal = true;
break;
case SDLK_p:
cam-> mouseOut();
SDL_ShowCursor(SDL_ENABLE);
_mouseHidden = false;
break;
default: break;
}
break;
case SDL_MOUSEBUTTONDOWN:
if(!_mouseHidden)
{
cam->mouseIn();
SDL_ShowCursor(SDL_DISABLE);
_mouseHidden = true;
running = true;
}
else
{
fireSignal = true;
}
break;
default: break;
}
}
return running;
}
void InputController::setExitSignal(bool exitSignal)
{
_exitSignal = exitSignal;
}
void InputController::setMouseHidden(bool hidden)
{
_mouseHidden = hidden;
}
}// namespace gamein