-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinput.cpp
More file actions
48 lines (47 loc) · 1.12 KB
/
input.cpp
File metadata and controls
48 lines (47 loc) · 1.12 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
#include <input.h> //мб сделать по сканкодам как в тееворлд но надо до конца разобраться
#include <managers.h>
InputManager* Input;
void InputManager::updateInput(SDL_Event e){
if (e.type == SDL_KEYDOWN || e.type == SDL_KEYUP){
bool flag = (e.type == SDL_KEYDOWN ? 1 : 0);
switch(e.key.keysym.sym){
case SDLK_w:
inpp.w = flag;
break;
case SDLK_a:
inpp.a = flag;
break;
case SDLK_s:
inpp.s = flag;
break;
case SDLK_d:
inpp.d = flag;
break;
case SDLK_1:
inpp.one = flag;
break;
}
}else
{
if (e.type == SDL_MOUSEMOTION){
SDL_GetMouseState(&(inpp.mx), &(inpp.my));
}else
{
bool flag = (e.type == SDL_MOUSEBUTTONDOWN ? 1 : 0);
switch(e.button.button){
case SDL_BUTTON_LEFT:
inpp.m1 = flag;
break;
case SDL_BUTTON_RIGHT:
inpp.m2 = flag;
break;
}
}
}
}
input* InputManager::getInput(){
return &inpp;
}
InputManager::InputManager(){
Input = this;
}