Update some things.

This commit is contained in:
Signal 2026-04-06 18:30:52 -04:00
parent f215bc3742
commit 4ad41f2e2e
34 changed files with 573 additions and 905 deletions

View file

@ -6,6 +6,7 @@
namespace Artifact {
static std::array<Key, GLFW_KEY_LAST + 1> GLFWToArtifact {};
static std::array<int, static_cast<size_t>(Key::Last) + 1> ArtifactToGLFW {};
namespace {
// Ensure that GLFW is transparently initialized prior to window creation.
@ -15,7 +16,8 @@ static struct _glfwInit {
// Populate the global GLFW-to-Artifact keycode mapping.
GLFWToArtifact.fill(Key::Unknown);
#define X(glfw, artifact) GLFWToArtifact[glfw] = Key::artifact
#define X(glfw, artifact) GLFWToArtifact[glfw] = Key::artifact;\
ArtifactToGLFW[static_cast<int>(Key::artifact)] = glfw
X(GLFW_KEY_A, A);
X(GLFW_KEY_B, B);
X(GLFW_KEY_C, C);
@ -160,4 +162,16 @@ bool Window::shouldClose() {
return glfwWindowShouldClose(window);
}
void Window::setPointerLock() {
glfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_DISABLED);
}
void Window::releasePointerLock() {
glfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_NORMAL);
}
bool Window::isKeyDown(Key key) {
return glfwGetKey(window, ArtifactToGLFW[static_cast<int>(key)]) == GLFW_PRESS;
}
}