Vivid
Loading...
Searching...
No Matches
InputHandler.cpp
1#include "../editor/Application.h"
2#include "InputHandler.h"
3#include "common/maths/Vec.h"
4
6{
7 GLFWwindow* window = Application::GetInstance()->GetWindow().GetGLFWWindow();
8 int state = glfwGetKey(window, key);
9
10 return state == GLFW_PRESS || state == GLFW_REPEAT;
11}
12
14{
15 GLFWwindow* window = Application::GetInstance()->GetWindow().GetGLFWWindow();
16 double xpos, ypos;
17 glfwGetCursorPos(window, &xpos, &ypos);
18
19 return Vivid::Maths::Vec2((float)xpos, (float)ypos);
20}
21
23{
24 GLFWwindow* window = Application::GetInstance()->GetWindow().GetGLFWWindow();
25 int state = glfwGetMouseButton(window, button);
26
27 return state == GLFW_PRESS;
28}
29
31{
33 mousePos.x -= Application::GetInstance()->GetWindow().GetViewportPosition().x;
34 mousePos.y -= Application::GetInstance()->GetWindow().GetViewportPosition().y;
35 mousePos.y = Application::GetInstance()->GetWindow().GetViewportHeight() - mousePos.y;
36
37 return mousePos;
38}
bool IsMouseButtonPressed(int button)
Checks if a mouse button is pressed or not.
Vivid::Maths::Vec2 GetMousePositionOnViewport()
Gets the mouse position on the viewport.
bool IsKeyPressed(int key)
Checks if a key is pressed or not.
Definition: InputHandler.cpp:5
Vivid::Maths::Vec2 GetMousePosition()
Gets the mouse position.
Contains a 2D vector.
Definition: Vec.h:108