-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinput.cpp
More file actions
29 lines (23 loc) · 690 Bytes
/
input.cpp
File metadata and controls
29 lines (23 loc) · 690 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
#include "input.h"
#include <SDL.h>
void Input::beginNewFrame() {
this->_pressedKeys.clear();
this->_releasedKeys.clear();
}
void Input::keyUpEvent(const SDL_Event& event) {
this->_releasedKeys[event.key.keysym.scancode] = true;
this->_heldKeys[event.key.keysym.scancode] = false;
}
void Input::keyDownEvent(const SDL_Event& event) {
this->_pressedKeys[event.key.keysym.scancode] = true;
this->_heldKeys[event.key.keysym.scancode] = true;
}
bool Input::isKeyHeld(SDL_Scancode key) {
return this->_heldKeys[key];
}
bool Input::wasKeyPressed(SDL_Scancode key) {
return this->_pressedKeys[key];
}
bool Input::wasKeyReleased(SDL_Scancode key) {
return this->_releasedKeys[key];
}