-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinput.hpp
45 lines (36 loc) · 977 Bytes
/
input.hpp
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
#ifndef INPUT_H
#define INPUT_H
#ifndef DEBUG
#include <SDL.h>
#endif // DEBUG
#include <vector>
#include "window.hpp"
enum mouse_buttons {
LEFT = 0,
MIDDLE = 1,
RIGHT = 2
};
class Input {
private:
static Input* _input;
std::vector<bool> _mouseButtonStates;
std::vector<bool> _prevMouseButtonStates;
SDL_Point _mPos;
const Uint8* _keyStates;
Uint8 _prevKeyStates[SDL_NUM_SCANCODES];
int _numkeys;
void _onMouseButtonDown(const SDL_Event& event);
void _onMouseButtonUp(const SDL_Event& event);
void _onMouseMotion(const SDL_Event& event);
public:
Input();
static Input* getInputHandler();
void updatePrevKeyStates();
bool update();
const bool& getMouseButtonState(const int& buttonNumber) const;
const SDL_Point& getMousePosition() const;
bool isKeyDown(const SDL_Scancode& key) const;
bool isKeyReleased(const SDL_Scancode& key) const;
bool isMouseKeyReleased(const int& buttonNumber) const;
};
#endif