summaryrefslogtreecommitdiff
path: root/src/managers/InputManager.cpp
diff options
context:
space:
mode:
authorvaxerski <43317083+vaxerski@users.noreply.github.com>2022-03-18 20:03:39 +0100
committervaxerski <43317083+vaxerski@users.noreply.github.com>2022-03-18 20:03:39 +0100
commita9773bd91a2c01982cc9b9807233c95303feada1 (patch)
tree3d5936042a0e7330ee9bda9f49601f09beb86b17 /src/managers/InputManager.cpp
parent854c827911b898d38fd54cdfab6bbd57296d3842 (diff)
XWayland and moved managers
Diffstat (limited to 'src/managers/InputManager.cpp')
-rw-r--r--src/managers/InputManager.cpp57
1 files changed, 57 insertions, 0 deletions
diff --git a/src/managers/InputManager.cpp b/src/managers/InputManager.cpp
new file mode 100644
index 00000000..e2e88b9e
--- /dev/null
+++ b/src/managers/InputManager.cpp
@@ -0,0 +1,57 @@
+#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);
+ }
+}
+
+void CInputManager::onMouseWarp(wlr_event_pointer_motion_absolute* e) {
+ wlr_cursor_warp_absolute(g_pCompositor->m_sWLRCursor, e->device, e->x, e->y);
+}
+
+Vector2D CInputManager::getMouseCoordsInternal() {
+ return m_vMouseCoords;
+}
+
+void CInputManager::newKeyboard(wlr_input_device* keyboard) {
+ m_dKeyboards.push_back(SKeyboard());
+
+ const auto PNEWKEYBOARD = &m_dKeyboards.back();
+
+ PNEWKEYBOARD->keyboard = keyboard;
+
+ xkb_rule_names rules;
+
+ const auto CONTEXT = xkb_context_new(XKB_CONTEXT_NO_FLAGS);
+ const auto KEYMAP = xkb_keymap_new_from_names(CONTEXT, &rules, XKB_KEYMAP_COMPILE_NO_FLAGS);
+
+ wlr_keyboard_set_keymap(keyboard->keyboard, KEYMAP);
+ xkb_keymap_unref(KEYMAP);
+ xkb_context_unref(CONTEXT);
+ wlr_keyboard_set_repeat_info(keyboard->keyboard, 25, 600);
+
+ wl_signal_add(&keyboard->keyboard->events.modifiers, &PNEWKEYBOARD->listen_keyboardMod);
+ wl_signal_add(&keyboard->keyboard->events.key, &PNEWKEYBOARD->listen_keyboardKey);
+ wl_signal_add(&keyboard->events.destroy, &PNEWKEYBOARD->listen_keyboardDestroy);
+
+ wlr_seat_set_keyboard(g_pCompositor->m_sWLRSeat, keyboard);
+}
+
+void CInputManager::onKeyboardKey(wlr_event_keyboard_key* event) {
+
+}
+
+void CInputManager::onKeyboardMod(void* data) {
+
+} \ No newline at end of file