diff options
Diffstat (limited to 'src/Mouse.cpp')
| -rw-r--r-- | src/Mouse.cpp | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/Mouse.cpp b/src/Mouse.cpp new file mode 100644 index 0000000..4715362 --- /dev/null +++ b/src/Mouse.cpp @@ -0,0 +1,25 @@ +#include "Mouse.hpp" +#include "Window.hpp" + +namespace MC { + +Vector<2> Mouse::update(Window& window) { + double x, y; + glfwGetCursorPos(window.get(), &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 |
