CS4850 Final Project
Loading...
Searching...
No Matches
InputManager.hpp
1#pragma once
2
3#include <SDL2/SDL.h>
4#include <string>
5
11
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};
Singleton class that handles input.
Definition InputManager.hpp:10
static InputManager & Instance()
Get the instance of the InputManager.
Definition InputManager.hpp:17
bool IsKeyPressed(std::string key)
Check if a key is pressed. Use SDL_Scancode for key.
Definition InputManager.hpp:32