diff options
| author | vaxerski <43317083+vaxerski@users.noreply.github.com> | 2022-03-17 15:53:45 +0100 |
|---|---|---|
| committer | vaxerski <43317083+vaxerski@users.noreply.github.com> | 2022-03-17 16:19:10 +0100 |
| commit | cf51ab71a25cbb60ebcf13edd4b7413c23264128 (patch) | |
| tree | 18b649470346c8815a156b5599ee7be1c4135a79 /src/input | |
| parent | 52090853dafb75dd99969a0cecdd291c109210f8 (diff) | |
input basics
Diffstat (limited to 'src/input')
| -rw-r--r-- | src/input/InputManager.cpp | 17 | ||||
| -rw-r--r-- | src/input/InputManager.hpp | 17 |
2 files changed, 34 insertions, 0 deletions
diff --git a/src/input/InputManager.cpp b/src/input/InputManager.cpp new file mode 100644 index 00000000..3140e22d --- /dev/null +++ b/src/input/InputManager.cpp @@ -0,0 +1,17 @@ +#include "InputManager.hpp" +#include "../Compositor.hpp" + +void CInputManager::onMouseMoved(wlr_event_pointer_motion* e) { + // TODO: sensitivity + + float sensitivity = 0.25f; + + m_vMouseCoords = m_vMouseCoords + Vector2D(e->delta_x * sensitivity, e->delta_y * sensitivity); + + if (m_vMouseCoords.floor() != m_vWLRMouseCoords) { + Vector2D delta = m_vMouseCoords - m_vWLRMouseCoords; + m_vWLRMouseCoords = m_vMouseCoords.floor(); + + wlr_cursor_move(g_pCompositor->m_sWLRCursor, e->device, delta.floor().x, delta.floor().y); + } +}
\ No newline at end of file diff --git a/src/input/InputManager.hpp b/src/input/InputManager.hpp new file mode 100644 index 00000000..38ec419a --- /dev/null +++ b/src/input/InputManager.hpp @@ -0,0 +1,17 @@ +#pragma once + +#include "../defines.hpp" + +class CInputManager { +public: + + void onMouseMoved(wlr_event_pointer_motion*); + void onMouseButton(int); + +private: + Vector2D m_vMouseCoords = Vector2D(0,0); + Vector2D m_vWLRMouseCoords = Vector2D(0,0); + +}; + +inline std::unique_ptr<CInputManager> g_pInputManager;
\ No newline at end of file |
