diff --git a/include/polyscope/render/engine.h b/include/polyscope/render/engine.h index 7a89a93b..0caf7754 100644 --- a/include/polyscope/render/engine.h +++ b/include/polyscope/render/engine.h @@ -505,7 +505,6 @@ class Engine { virtual bool windowRequestsClose() = 0; virtual void pollEvents() = 0; virtual bool isKeyPressed(char c) = 0; // for lowercase a-z and 0-9 only - virtual int getKeyCode(char c) = 0; // for lowercase a-z and 0-9 only virtual std::string getClipboardText() = 0; virtual void setClipboardText(std::string text) = 0; diff --git a/include/polyscope/render/mock_opengl/mock_gl_engine.h b/include/polyscope/render/mock_opengl/mock_gl_engine.h index 6560902c..f9d512f5 100644 --- a/include/polyscope/render/mock_opengl/mock_gl_engine.h +++ b/include/polyscope/render/mock_opengl/mock_gl_engine.h @@ -353,7 +353,6 @@ class MockGLEngine : public Engine { bool windowRequestsClose() override; void pollEvents() override; bool isKeyPressed(char c) override; // for lowercase a-z and 0-9 only - int getKeyCode(char c) override; // for lowercase a-z and 0-9 only std::string getClipboardText() override; void setClipboardText(std::string text) override; diff --git a/include/polyscope/render/opengl/gl_engine_egl.h b/include/polyscope/render/opengl/gl_engine_egl.h index 45f50d41..2a53d5c3 100644 --- a/include/polyscope/render/opengl/gl_engine_egl.h +++ b/include/polyscope/render/opengl/gl_engine_egl.h @@ -62,7 +62,6 @@ class GLEngineEGL : public GLEngine { bool windowRequestsClose() override; bool isKeyPressed(char c) override; // for lowercase a-z and 0-9 only - int getKeyCode(char c) override; // for lowercase a-z and 0-9 only std::string getClipboardText() override; void setClipboardText(std::string text) override; diff --git a/include/polyscope/render/opengl/gl_engine_glfw.h b/include/polyscope/render/opengl/gl_engine_glfw.h index 67caddf2..574f2b27 100644 --- a/include/polyscope/render/opengl/gl_engine_glfw.h +++ b/include/polyscope/render/opengl/gl_engine_glfw.h @@ -67,7 +67,6 @@ class GLEngineGLFW : public GLEngine { bool windowRequestsClose() override; bool isKeyPressed(char c) override; // for lowercase a-z and 0-9 only - int getKeyCode(char c) override; // for lowercase a-z and 0-9 only std::string getClipboardText() override; void setClipboardText(std::string text) override; diff --git a/src/render/mock_opengl/mock_gl_engine.cpp b/src/render/mock_opengl/mock_gl_engine.cpp index 0e6ce5c0..ca6b1226 100644 --- a/src/render/mock_opengl/mock_gl_engine.cpp +++ b/src/render/mock_opengl/mock_gl_engine.cpp @@ -1649,8 +1649,6 @@ void MockGLEngine::pollEvents() {} bool MockGLEngine::isKeyPressed(char c) { return false; } -int MockGLEngine::getKeyCode(char c) { return 77; } - void MockGLEngine::ImGuiNewFrame() { // ImGUI seems to crash without a backend if we don't do this diff --git a/src/render/opengl/gl_engine_egl.cpp b/src/render/opengl/gl_engine_egl.cpp index c6c0c01d..4e57a9d1 100644 --- a/src/render/opengl/gl_engine_egl.cpp +++ b/src/render/opengl/gl_engine_egl.cpp @@ -466,11 +466,6 @@ bool GLEngineEGL::isKeyPressed(char c) { return false; } -int GLEngineEGL::getKeyCode(char c) { - // not defined in headless mode - return -1; -} - std::string GLEngineEGL::getClipboardText() { // not defined in headless mode return ""; diff --git a/src/render/opengl/gl_engine_glfw.cpp b/src/render/opengl/gl_engine_glfw.cpp index be75bc69..bbcff2a2 100644 --- a/src/render/opengl/gl_engine_glfw.cpp +++ b/src/render/opengl/gl_engine_glfw.cpp @@ -234,14 +234,6 @@ bool GLEngineGLFW::isKeyPressed(char c) { return false; } -int GLEngineGLFW::getKeyCode(char c) { - if (c >= '0' && c <= '9') return static_cast(ImGuiKey_0) + (c - '0'); - if (c >= 'a' && c <= 'z') return static_cast(ImGuiKey_A) + (c - 'a'); - if (c >= 'A' && c <= 'Z') return static_cast(ImGuiKey_A) + (c - 'A'); - exception("getKeyCode only supports 0-9, a-z, A-Z"); - return -1; -} - std::string GLEngineGLFW::getClipboardText() { std::string clipboardData = ImGui::GetClipboardText(); return clipboardData; diff --git a/src/view.cpp b/src/view.cpp index b81665d9..4511205e 100644 --- a/src/view.cpp +++ b/src/view.cpp @@ -297,12 +297,12 @@ void processKeyboardNavigation(ImGuiIO& io) { glm::vec3 delta{0.f, 0.f, 0.f}; - if (ImGui::IsKeyDown(static_cast(render::engine->getKeyCode('a')))) delta.x += 1.f; - if (ImGui::IsKeyDown(static_cast(render::engine->getKeyCode('d')))) delta.x += -1.f; - if (ImGui::IsKeyDown(static_cast(render::engine->getKeyCode('q')))) delta.y += 1.f; - if (ImGui::IsKeyDown(static_cast(render::engine->getKeyCode('e')))) delta.y += -1.f; - if (ImGui::IsKeyDown(static_cast(render::engine->getKeyCode('w')))) delta.z += 1.f; - if (ImGui::IsKeyDown(static_cast(render::engine->getKeyCode('s')))) delta.z += -1.f; + if (ImGui::IsKeyDown(ImGuiKey_A)) delta.x += 1.f; + if (ImGui::IsKeyDown(ImGuiKey_D)) delta.x += -1.f; + if (ImGui::IsKeyDown(ImGuiKey_Q)) delta.y += 1.f; + if (ImGui::IsKeyDown(ImGuiKey_E)) delta.y += -1.f; + if (ImGui::IsKeyDown(ImGuiKey_W)) delta.z += 1.f; + if (ImGui::IsKeyDown(ImGuiKey_S)) delta.z += -1.f; if (glm::length(delta) > 0.) { hasMovement = true;