2025-01-19 14:17:36 +01:00

40 lines
863 B
C++

#pragma once
#include <map>
#include <glm/glm.hpp>
#include "KeyObserver.h"
struct KeyState {
bool IsPressed;
bool WasPressed;
bool WasReleased;
};
class InputSystem
{
private:
GLFWwindow* _window;
std::map<int, KeyObserver> _keyCodeDictionaryObserver;
public:
InputSystem() { _window = nullptr; }
void ObserveKey(int key);
void Update();
void SetWindow(GLFWwindow* window);
bool IsLeftMouseDown() const;
bool IsRightMouseDown() const;
void GetMousePos(glm::vec2& position) const;
void GetPickingRay(const glm::mat4& tansform, glm::vec3& startingPoint, glm::vec3& direction) const;
bool IsKeyPressed(int key) { return _keyCodeDictionaryObserver[key].IsPressed; }
bool WasKeyPressed(int key) { return _keyCodeDictionaryObserver[key].WasPressed; }
bool WasKeyReleased(int key) { return _keyCodeDictionaryObserver[key].WasReleased; }
};