You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

50 lines
939 B

4 months ago
#pragma once
#include <GLFW/glfw3.h>
#include <map>
#include <set>
#include "glm/vec2.hpp"
4 months ago
class Listener;
3 months ago
4 months ago
class MouseListener;
class Input {
friend Listener;
friend MouseListener;
public:
3 months ago
explicit Input(GLFWwindow *window);
static Input *instance;
4 months ago
static std::map<int, bool> KeyIsDown;
static std::map<int, bool> MouseButtonIsDown;
glm::vec2 currentCursorPosition {};
4 months ago
private:
3 months ago
GLFWwindow *window;
std::set<Listener *> listeners;
4 months ago
void keyPressed(int key);
void keyReleased(int key);
void mouseButtonPressed(int button);
void mouseButtonReleased(int button);
3 months ago
void mouseMoved(const glm::vec2 &newCursorPosition);
4 months ago
};
class Listener {
public:
Listener();
virtual ~Listener();
};
class KeyListener : Listener {
};
class MouseListener : public Listener {
public:
3 months ago
virtual void mouseMoved(const glm::vec2 &delta) {};
virtual void mouseButtonPressed(int button) {};
3 months ago
virtual void mouseButtonReleased(int button) {};
4 months ago
};