30 lines
544 B
C++
30 lines
544 B
C++
|
// 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;
|
||
|
}
|