Skip to content

Commit

Permalink
remove deprecated keycode functions (#314)
Browse files Browse the repository at this point in the history
  • Loading branch information
nmwsharp authored Dec 30, 2024
1 parent 1e49ab9 commit 687fa5d
Show file tree
Hide file tree
Showing 8 changed files with 6 additions and 25 deletions.
1 change: 0 additions & 1 deletion include/polyscope/render/engine.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
1 change: 0 additions & 1 deletion include/polyscope/render/mock_opengl/mock_gl_engine.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
1 change: 0 additions & 1 deletion include/polyscope/render/opengl/gl_engine_egl.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
1 change: 0 additions & 1 deletion include/polyscope/render/opengl/gl_engine_glfw.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
2 changes: 0 additions & 2 deletions src/render/mock_opengl/mock_gl_engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 0 additions & 5 deletions src/render/opengl/gl_engine_egl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 "";
Expand Down
8 changes: 0 additions & 8 deletions src/render/opengl/gl_engine_glfw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -234,14 +234,6 @@ bool GLEngineGLFW::isKeyPressed(char c) {
return false;
}

int GLEngineGLFW::getKeyCode(char c) {
if (c >= '0' && c <= '9') return static_cast<int>(ImGuiKey_0) + (c - '0');
if (c >= 'a' && c <= 'z') return static_cast<int>(ImGuiKey_A) + (c - 'a');
if (c >= 'A' && c <= 'Z') return static_cast<int>(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;
Expand Down
12 changes: 6 additions & 6 deletions src/view.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -297,12 +297,12 @@ void processKeyboardNavigation(ImGuiIO& io) {

glm::vec3 delta{0.f, 0.f, 0.f};

if (ImGui::IsKeyDown(static_cast<ImGuiKey>(render::engine->getKeyCode('a')))) delta.x += 1.f;
if (ImGui::IsKeyDown(static_cast<ImGuiKey>(render::engine->getKeyCode('d')))) delta.x += -1.f;
if (ImGui::IsKeyDown(static_cast<ImGuiKey>(render::engine->getKeyCode('q')))) delta.y += 1.f;
if (ImGui::IsKeyDown(static_cast<ImGuiKey>(render::engine->getKeyCode('e')))) delta.y += -1.f;
if (ImGui::IsKeyDown(static_cast<ImGuiKey>(render::engine->getKeyCode('w')))) delta.z += 1.f;
if (ImGui::IsKeyDown(static_cast<ImGuiKey>(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;
Expand Down

0 comments on commit 687fa5d

Please sign in to comment.