1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
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);
}
|