aboutsummaryrefslogtreecommitdiff
path: root/src/brussel.engine/Input.cpp
blob: 9f304ffa62f9d495e68540ba9d146f242b8224fe (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include "Input.hpp"

#include <cassert>

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<GlfwKeyboardAttachment*>(glfwGetKeyboardUserPointer(keyboard));
	// Defensive: this GLFWkeyboard* will be deleted after this callback ends anyways
	glfwSetKeyboardUserPointer(keyboard, nullptr);
	delete attachment;
}