Tesseract-Engine/src/Engine/InputManager.cpp

30 lines
544 B
C++
Raw Normal View History

2025-01-01 07:36:53 +00:00
// InputManager.cpp
#include "InputManager.h"
#include <GLFW/glfw3.h>
void InputManager::Update(GLFWwindow* window)
{
if (!window)
{
return;
}
// Update the state of each key
for (int key = 0; key <= GLFW_KEY_LAST; ++key)
{
m_KeyStates[key] = glfwGetKey(window, key) == GLFW_PRESS;
}
}
bool InputManager::IsKeyPressed(KeyCode key) const
{
int keyInt = static_cast<int>(key);
if (keyInt >= 0 && keyInt <= GLFW_KEY_LAST)
{
return m_KeyStates[keyInt];
}
return false;
}