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.

44 lines
795 B

4 months ago
#pragma once
#include <GLFW/glfw3.h>
#include <map>
#include <set>
class Listener;
class MouseListener;
class Input {
friend Listener;
friend MouseListener;
public:
explicit Input(GLFWwindow* window);
static Input* instance;
static std::map<int, bool> KeyIsDown;
static std::map<int, bool> MouseButtonIsDown;
private:
GLFWwindow* window;
std::set<Listener*> listeners;
void keyPressed(int key);
void keyReleased(int key);
void mouseButtonPressed(int button);
void mouseButtonReleased(int button);
void mouseMoved(double newX, double newY);
double oldX {}, oldY {};
};
class Listener {
public:
Listener();
virtual ~Listener();
};
class KeyListener : Listener {
};
class MouseListener : public Listener {
public:
virtual void mouseMoved(float deltaX, float deltaY) {};
};