summaryrefslogtreecommitdiffstats
path: root/src/game/client/io/keyboard.cc
diff options
context:
space:
mode:
authoruntodesu <kirill@untode.su>2025-12-30 13:20:33 +0500
committeruntodesu <kirill@untode.su>2025-12-30 13:20:33 +0500
commita1c83d56f41e6f2e0ad86dcd76d1446bfc60a37c (patch)
tree5754f0cd6ef3678c2e9d9c31174ae435d463c8ed /src/game/client/io/keyboard.cc
parent49d3dff9e98e70e599dfd3059f85bb08ae247fe5 (diff)
downloadvoxelius-a1c83d56f41e6f2e0ad86dcd76d1446bfc60a37c.tar.bz2
voxelius-a1c83d56f41e6f2e0ad86dcd76d1446bfc60a37c.zip
begin working on qf ports (#21)
Diffstat (limited to 'src/game/client/io/keyboard.cc')
-rw-r--r--src/game/client/io/keyboard.cc29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/game/client/io/keyboard.cc b/src/game/client/io/keyboard.cc
new file mode 100644
index 0000000..71db460
--- /dev/null
+++ b/src/game/client/io/keyboard.cc
@@ -0,0 +1,29 @@
+// SPDX-License-Identifier: BSD-2-Clause
+// Copyright (c) 2025 Kirill Dmitrievich
+// File: keyboard.cc; Created: Tue Dec 30 2025 12:27:50
+// Description: Keyboard handling
+
+#include "client/pch.hh"
+
+#include "client/io/keyboard.hh"
+
+#include "client/globals.hh"
+
+static void on_char_glfw(GLFWwindow* window, unsigned int codepoint)
+{
+ ImGui_ImplGlfw_CharCallback(window, codepoint);
+}
+
+static void on_key_glfw(GLFWwindow* window, int keycode, int scancode, int action, int modbits)
+{
+ globals::dispatcher.trigger(KeyEvent(keycode, scancode, action, modbits));
+
+ ImGui_ImplGlfw_KeyCallback(window, keycode, scancode, action, modbits);
+}
+
+void keyboard::init(void)
+{
+ spdlog::info("keyboard: taking over device events");
+ glfwSetCharCallback(globals::window, &on_char_glfw);
+ glfwSetKeyCallback(globals::window, &on_key_glfw);
+}