couch/core/Input.h

37 lines
897 B
C
Raw Permalink Normal View History

#ifndef COUCH_H
#define COUCH_H
2021-01-13 18:51:58 -06:00
#include <GL/glew.h>
#include <GLFW/glfw3.h>
#include <vector>
2021-01-13 18:51:58 -06:00
#include "types.h"
2021-03-08 13:50:50 -06:00
#include "Window.h"
2021-01-13 18:51:58 -06:00
2021-03-08 13:50:50 -06:00
typedef void (*KeyHandler)(int key, int code, int action, int mods);
typedef void (*MousePositionHandler)(double xpos, double ypos, double xrel, double yrel);
2021-01-13 18:51:58 -06:00
class Input {
public:
2021-08-02 14:34:49 -05:00
enum MouseMode {
VISIBLE, HIDDEN, CAPTURED
};
2021-01-13 18:51:58 -06:00
static Input *GetInstance();
2021-08-02 14:34:49 -05:00
void Use(Window *window);
void SetMouseMode(MouseMode mouseMode);
std::vector<KeyHandler> keyHandlers;
std::vector<MousePositionHandler> mousePositionHandlers;
2021-01-13 18:51:58 -06:00
private:
2021-01-15 16:15:47 -06:00
bool firstMousePositionUpdate = true;
2021-01-13 22:50:01 -06:00
double lastx, lasty;
2021-08-02 14:34:49 -05:00
MouseMode mouseMode;
Window *window;
2021-01-13 18:51:58 -06:00
Input();
2021-03-08 13:50:50 -06:00
static void HandleKeys(GLFWwindow *_, int key, int code, int action, int mods);
static void HandleMousePosition(GLFWwindow *_, double xpos, double ypos);
2021-01-13 18:51:58 -06:00
static Input *instance;
};
#endif // COUCH_H