-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWindowsInput.cpp
More file actions
41 lines (33 loc) · 1.06 KB
/
Copy pathWindowsInput.cpp
File metadata and controls
41 lines (33 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#include "Input.h"
#include "WindowLVE.h"
bool Input::IsKeyPressed(KeyCode key, GLFWwindow* windowHandle)
{
auto state = glfwGetKey(windowHandle, static_cast<int32_t>(key));
return state == GLFW_PRESS || state == GLFW_REPEAT;
}
bool Input::IsMouseButtonPressed(MouseCode button, GLFWwindow* windowHandle)
{
auto state = glfwGetMouseButton(windowHandle, static_cast<int32_t>(button));
return state == GLFW_PRESS;
}
bool Input::IsMouseButtonReleased(MouseCode button, GLFWwindow* windowHandle)
{
auto state = glfwGetMouseButton(windowHandle, static_cast<int32_t>(button));
return state == GLFW_RELEASE;
}
std::pair<float, float> Input::GetMousePosition(GLFWwindow* windowHandle)
{
double xpos, ypos;
glfwGetCursorPos(windowHandle, &xpos, &ypos);
return { (float)xpos, (float)ypos };
}
float Input::GetMouseX(GLFWwindow* windowHandle)
{
std::pair<float, float> coords = GetMousePosition(windowHandle);
return coords.first;
}
float Input::GetMouseY(GLFWwindow* windowHandle)
{
std::pair<float, float> coords = GetMousePosition(windowHandle);
return coords.second;
}