SpiecsEngine
 
Loading...
Searching...
No Matches
WindowsInput.cpp
Go to the documentation of this file.
1/**
2* @file Input.h.
3* @brief The WindowsInput Class Implementation.
4* @author The Cherno.
5*/
6
7#include "Pchheader.h"
8#include "WindowsInput.h"
9#include "Render/Vulkan/VulkanRenderBackend.h"
10
11#include <GLFW/glfw3.h>
12
13namespace Spices {
14
15 /**
16 * @brief Instance a WindowsInput single instance.
17 */
19
20 bool WindowsInput::IsKeyPressedImpl(const int& keycode)
21 {
23
24 /**
25 * @brief Get GLFW Window Pointer.
26 */
27 const auto window = VulkanRenderBackend::GetState().m_Windows;
28
29 /**
30 * @brief Query GLFW Window Key State.
31 */
32 const auto state = glfwGetKey(window, keycode);
33
34 return state == GLFW_PRESS || state == GLFW_REPEAT;
35 }
36
37 bool WindowsInput::IsMouseButtonPressedImpl(const int& button)
38 {
40
41 /**
42 * @brief Get GLFW Window Pointer.
43 */
44 const auto window = VulkanRenderBackend::GetState().m_Windows;
45
46 /**
47 * @brief Query GLFW Window Mouse State.
48 */
49 const auto state = glfwGetMouseButton(window, button);
50
51 return state == GLFW_PRESS;
52 }
53
54 std::pair<float, float> WindowsInput::GetMousePositionImpl()
55 {
57
58 /**
59 * @brief Get GLFW Window Pointer.
60 */
61 const auto window = VulkanRenderBackend::GetState().m_Windows;
62
63 /**
64 * @brief Query GLFW Window Cursor Position.
65 */
66 double xPos, yPos;
67 glfwGetCursorPos(window, &xPos, &yPos);
68
69 return { static_cast<float>(xPos), static_cast<float>(yPos) };
70 }
71
73 {
75
76 auto [x, y] = GetMousePositionImpl();
77 return x;
78 }
79
81 {
83
84 auto [x, y] = GetMousePositionImpl();
85 return y;
86 }
87}
#define SPICES_PROFILE_ZONE
static std::unique_ptr< Input > s_Instance
Platform Specific Input Class.
Definition Input.h:105
This Class Is a wrapper of Platform Specific Input Query.
Definition Input.h:16
static VulkanState & GetState()
Get VulkanState in use.
This class defines the render backend behaves of Vulkan.
virtual std::pair< float, float > GetMousePositionImpl() override
Query Mouse Position in Windows.
virtual bool IsMouseButtonPressedImpl(const int &button) override
Query If given Mouse Button is Pressed.
virtual float GetMouseXImpl() override
Query Mouse X Position in Windows.
virtual float GetMouseYImpl() override
Query Mouse Y Position in Windows.
virtual bool IsKeyPressedImpl(const int &keycode) override
Query If given Key is Pressed.
This Class Is Windows Platform Specific Input Class.