-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathModuleInput.cpp
More file actions
48 lines (38 loc) · 876 Bytes
/
ModuleInput.cpp
File metadata and controls
48 lines (38 loc) · 876 Bytes
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 "Globals.h"
#include "Application.h"
#include "ModuleInput.h"
#include "SDL/include/SDL.h"
ModuleInput::ModuleInput() : Module()
{}
// Destructor
ModuleInput::~ModuleInput()
{}
// Called before render is available
bool ModuleInput::Init()
{
LOG("Init SDL input event system");
bool ret = true;
SDL_Init(0);
if(SDL_InitSubSystem(SDL_INIT_EVENTS) < 0)
{
LOG("SDL_EVENTS could not initialize! SDL_Error: %s\n", SDL_GetError());
ret = false;
}
return ret;
}
// Called every draw update
update_status ModuleInput::Update()
{
SDL_PumpEvents();
keyboard = SDL_GetKeyboardState(NULL);
if (keyboard[SDL_SCANCODE_ESCAPE])
return update_status::UPDATE_STOP;
return update_status::UPDATE_CONTINUE;
}
// Called before quitting
bool ModuleInput::CleanUp()
{
LOG("Quitting SDL input event subsystem");
SDL_QuitSubSystem(SDL_INIT_EVENTS);
return true;
}