From 6ed978051668c08f5a957c97570f364dd580c807 Mon Sep 17 00:00:00 2001 From: Mel Date: Fri, 21 Oct 2022 01:03:18 +0200 Subject: Namespace and Folder refactor --- src/GFX/Mouse.cpp | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 src/GFX/Mouse.cpp (limited to 'src/GFX/Mouse.cpp') diff --git a/src/GFX/Mouse.cpp b/src/GFX/Mouse.cpp new file mode 100644 index 0000000..5cd2698 --- /dev/null +++ b/src/GFX/Mouse.cpp @@ -0,0 +1,24 @@ +#include "Mouse.hpp" + +namespace MC::GFX { + +Vector<2> Mouse::update(GLFWwindow* window) { + double x, y; + glfwGetCursorPos(window, &x, &y); + + if (m_first_event) { + m_last_x = x; + m_last_y = y; + + m_first_event = false; + } + + Vector<2> movement{static_cast(x) - m_last_x, static_cast(y) - m_last_y}; + + m_last_x = x; + m_last_y = y; + + return movement; +} + +} \ No newline at end of file -- cgit 1.4.1