summary refs log tree commit diff
path: root/src/GFX/Mouse.cpp
blob: 49f697264c46060e82dc8bb31eb5e34ccd19ae6f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include "Mouse.hpp"

namespace MC::GFX {

Vector<2> Mouse::update(GLFWwindow* window) {
    Real 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<Real>(x) - m_last_x,  static_cast<Real>(y) - m_last_y};

    m_last_x = x;
    m_last_y = y;

    return movement;
}

}