ferx/engine/core/input/Input.cpp

30 lines
679 B
C++
Raw Normal View History

2024-08-28 12:38:19 +00:00
#include "Engine.h"
#include "Input.h"
bool Input::IsKeyPressed(const KeyCode key)
{
2024-11-22 00:37:06 +00:00
return glfwGetKey(Engine::Get()->GetWindow()->GetNativeWindow(), key) == GLFW_PRESS;
2024-08-28 12:38:19 +00:00
}
bool Input::IsMouseButtonPressed(const MouseCode button)
{
2024-11-22 00:37:06 +00:00
return glfwGetMouseButton(Engine::Get()->GetWindow()->GetNativeWindow(), button) == GLFW_PRESS;
2024-08-28 12:38:19 +00:00
}
glm::vec2 Input::GetMousePosition()
{
double xPos, yPos;
2024-11-22 00:37:06 +00:00
glfwGetCursorPos(Engine::Get()->GetWindow()->GetNativeWindow(), &xPos, &yPos);
2024-08-28 12:38:19 +00:00
return { static_cast<float>(xPos), static_cast<float>(yPos) };
}
float Input::GetMouseX()
{
return GetMousePosition().x;
}
float Input::GetMouseY()
{
return GetMousePosition().y;
}