-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathInput.h
48 lines (35 loc) · 987 Bytes
/
Input.h
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
#ifndef _TINY_PIYO_INPUT_H
#define _TINY_PIYO_INPUT_H
#include "GL/glew.h"
#include <GLFW/glfw3.h>
#include "Window.h"
#include "Types.h"
#include <map>
class Window;
enum KeyState
{
UP = 0,
PRESS = 1,
DOWN = 2
};
class InputManager
{
public:
void Init(Window* window);
void Destroy();
bool IsKeyDown(int key);
bool IsKeyPressed(int key);
void LockMouse();
void UnlockMouse();
float2 GetCursorPos() { return float2(this->_x, this->_y); }
static void sKeyCallback(GLFWwindow* window, int key, int scancode, int action, int mods);
void KeyCallback(GLFWwindow* window, int key, int scancode, int action, int mods);
static void sCursorPosCallback(GLFWwindow* window, double x, double y);
void CursorPosCallback(GLFWwindow* window, double x, double y);
private:
Window* _window;
std::map<int, int> _keyMap;
double _x;
double _y;
};
#endif