diff options
| author | untodesu <kirill@untode.su> | 2025-12-30 13:20:33 +0500 |
|---|---|---|
| committer | untodesu <kirill@untode.su> | 2025-12-30 13:20:33 +0500 |
| commit | a1c83d56f41e6f2e0ad86dcd76d1446bfc60a37c (patch) | |
| tree | 5754f0cd6ef3678c2e9d9c31174ae435d463c8ed /src/game/client/io/mouse.cc | |
| parent | 49d3dff9e98e70e599dfd3059f85bb08ae247fe5 (diff) | |
| download | voxelius-a1c83d56f41e6f2e0ad86dcd76d1446bfc60a37c.tar.bz2 voxelius-a1c83d56f41e6f2e0ad86dcd76d1446bfc60a37c.zip | |
begin working on qf ports (#21)
Diffstat (limited to 'src/game/client/io/mouse.cc')
| -rw-r--r-- | src/game/client/io/mouse.cc | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/src/game/client/io/mouse.cc b/src/game/client/io/mouse.cc new file mode 100644 index 0000000..b79365c --- /dev/null +++ b/src/game/client/io/mouse.cc @@ -0,0 +1,44 @@ +// SPDX-License-Identifier: BSD-2-Clause +// Copyright (c) 2025 Kirill Dmitrievich +// File: mouse.cc; Created: Tue Dec 30 2025 12:39:32 +// Description: Mouse and scroll wheel handling + +#include "client/pch.hh" + +#include "client/io/mouse.hh" + +#include "client/globals.hh" + +static void on_cursor_enter_glfw(GLFWwindow* window, int entered) +{ + ImGui_ImplGlfw_CursorEnterCallback(window, entered); +} +static void on_cursor_pos_glfw(GLFWwindow* window, double xpos, double ypos) +{ + globals::dispatcher.trigger(CursorPosEvent(xpos, ypos)); + + ImGui_ImplGlfw_CursorPosCallback(window, xpos, ypos); +} + +static void on_mouse_button_glfw(GLFWwindow* window, int button, int action, int modbits) +{ + globals::dispatcher.trigger(MouseButtonEvent(button, action, modbits)); + + ImGui_ImplGlfw_MouseButtonCallback(window, button, action, modbits); +} + +static void on_scroll_glfw(GLFWwindow* window, double xoffset, double yoffset) +{ + globals::dispatcher.trigger(ScrollEvent(xoffset, yoffset)); + + ImGui_ImplGlfw_ScrollCallback(window, xoffset, yoffset); +} + +void mouse::init(void) +{ + spdlog::info("mouse: taking over device events"); + glfwSetCursorEnterCallback(globals::window, &on_cursor_enter_glfw); + glfwSetCursorPosCallback(globals::window, &on_cursor_pos_glfw); + glfwSetMouseButtonCallback(globals::window, &on_mouse_button_glfw); + glfwSetScrollCallback(globals::window, &on_scroll_glfw); +} |
