CS4850 Final Project
Loading...
Searching...
No Matches
InputManager.hpp
1
#pragma once
2
3
#include <SDL2/SDL.h>
4
#include <string>
5
10
struct
InputManager
{
11
17
static
InputManager
&
Instance
() {
18
if
(
nullptr
== mInstance) {
19
mInstance =
new
InputManager
;
20
}
21
22
return
*mInstance;
23
}
24
32
bool
IsKeyPressed
(std::string key) {
33
const
Uint8 *state = SDL_GetKeyboardState(
nullptr
);
34
if
(state[SDL_GetScancodeFromName(key.c_str())]) {
35
return
true
;
36
}
37
return
false
;
38
}
39
40
private
:
41
InputManager
() {
42
}
43
44
inline
static
InputManager
* mInstance {
nullptr
};
45
};
InputManager
Singleton class that handles input.
Definition
InputManager.hpp:10
InputManager::Instance
static InputManager & Instance()
Get the instance of the InputManager.
Definition
InputManager.hpp:17
InputManager::IsKeyPressed
bool IsKeyPressed(std::string key)
Check if a key is pressed. Use SDL_Scancode for key.
Definition
InputManager.hpp:32
Generated by
1.10.0