summary refs log tree commit diff
path: root/src/GFX/Mouse.cpp
diff options
context:
space:
mode:
authorMel <einebeere@gmail.com>2022-10-21 01:03:18 +0200
committerMel <einebeere@gmail.com>2022-10-21 01:03:18 +0200
commit6ed978051668c08f5a957c97570f364dd580c807 (patch)
treee3db93c52fcd86e26bc859d46e755290d2a7f40c /src/GFX/Mouse.cpp
parent0464a83dfaebaa75d6e2d3b7431e84ebd83fccfd (diff)
downloadmeowcraft-6ed978051668c08f5a957c97570f364dd580c807.tar.zst
meowcraft-6ed978051668c08f5a957c97570f364dd580c807.zip
Namespace and Folder refactor
Diffstat (limited to 'src/GFX/Mouse.cpp')
-rw-r--r--src/GFX/Mouse.cpp24
1 files changed, 24 insertions, 0 deletions
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<float>(x) - m_last_x,  static_cast<float>(y) - m_last_y};
+
+    m_last_x = x;
+    m_last_y = y;
+
+    return movement;
+}
+
+}
\ No newline at end of file