From 2c92e07f337e42cf58970443f9de678f85a9b2a4 Mon Sep 17 00:00:00 2001 From: rtk0c Date: Thu, 19 Oct 2023 22:50:07 -0700 Subject: The great renaming: switch to "module style" --- src/brussel.engine/Input.cpp | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 src/brussel.engine/Input.cpp (limited to 'src/brussel.engine/Input.cpp') diff --git a/src/brussel.engine/Input.cpp b/src/brussel.engine/Input.cpp new file mode 100644 index 0000000..9f304ff --- /dev/null +++ b/src/brussel.engine/Input.cpp @@ -0,0 +1,23 @@ +#include "Input.hpp" + +#include + +GLFWkeyboard* InputState::FindKeyboard(std::string_view name) { + assert(false); + // TODO +} + +GlfwKeyboardAttachment* InputState::ConnectKeyboard(GLFWkeyboard* keyboard) { + auto attachment = new GlfwKeyboardAttachment(); + glfwSetKeyboardUserPointer(keyboard, attachment); + + return attachment; +} + +void InputState::DisconnectKeyboard(GLFWkeyboard* keyboard) { + InputState::instance->DisconnectKeyboard(keyboard); + auto attachment = static_cast(glfwGetKeyboardUserPointer(keyboard)); + // Defensive: this GLFWkeyboard* will be deleted after this callback ends anyways + glfwSetKeyboardUserPointer(keyboard, nullptr); + delete attachment; +} -- cgit v1.2.3-70-g09d2