Skip to content

Commit 687fa5d

Browse files
authored
remove deprecated keycode functions (#314)
1 parent 1e49ab9 commit 687fa5d

File tree

8 files changed

+6
-25
lines changed

8 files changed

+6
-25
lines changed

include/polyscope/render/engine.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -505,7 +505,6 @@ class Engine {
505505
virtual bool windowRequestsClose() = 0;
506506
virtual void pollEvents() = 0;
507507
virtual bool isKeyPressed(char c) = 0; // for lowercase a-z and 0-9 only
508-
virtual int getKeyCode(char c) = 0; // for lowercase a-z and 0-9 only
509508
virtual std::string getClipboardText() = 0;
510509
virtual void setClipboardText(std::string text) = 0;
511510

include/polyscope/render/mock_opengl/mock_gl_engine.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,6 @@ class MockGLEngine : public Engine {
353353
bool windowRequestsClose() override;
354354
void pollEvents() override;
355355
bool isKeyPressed(char c) override; // for lowercase a-z and 0-9 only
356-
int getKeyCode(char c) override; // for lowercase a-z and 0-9 only
357356
std::string getClipboardText() override;
358357
void setClipboardText(std::string text) override;
359358

include/polyscope/render/opengl/gl_engine_egl.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ class GLEngineEGL : public GLEngine {
6262
bool windowRequestsClose() override;
6363

6464
bool isKeyPressed(char c) override; // for lowercase a-z and 0-9 only
65-
int getKeyCode(char c) override; // for lowercase a-z and 0-9 only
6665
std::string getClipboardText() override;
6766
void setClipboardText(std::string text) override;
6867

include/polyscope/render/opengl/gl_engine_glfw.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@ class GLEngineGLFW : public GLEngine {
6767
bool windowRequestsClose() override;
6868

6969
bool isKeyPressed(char c) override; // for lowercase a-z and 0-9 only
70-
int getKeyCode(char c) override; // for lowercase a-z and 0-9 only
7170
std::string getClipboardText() override;
7271
void setClipboardText(std::string text) override;
7372

src/render/mock_opengl/mock_gl_engine.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1649,8 +1649,6 @@ void MockGLEngine::pollEvents() {}
16491649

16501650
bool MockGLEngine::isKeyPressed(char c) { return false; }
16511651

1652-
int MockGLEngine::getKeyCode(char c) { return 77; }
1653-
16541652
void MockGLEngine::ImGuiNewFrame() {
16551653

16561654
// ImGUI seems to crash without a backend if we don't do this

src/render/opengl/gl_engine_egl.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -466,11 +466,6 @@ bool GLEngineEGL::isKeyPressed(char c) {
466466
return false;
467467
}
468468

469-
int GLEngineEGL::getKeyCode(char c) {
470-
// not defined in headless mode
471-
return -1;
472-
}
473-
474469
std::string GLEngineEGL::getClipboardText() {
475470
// not defined in headless mode
476471
return "";

src/render/opengl/gl_engine_glfw.cpp

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -234,14 +234,6 @@ bool GLEngineGLFW::isKeyPressed(char c) {
234234
return false;
235235
}
236236

237-
int GLEngineGLFW::getKeyCode(char c) {
238-
if (c >= '0' && c <= '9') return static_cast<int>(ImGuiKey_0) + (c - '0');
239-
if (c >= 'a' && c <= 'z') return static_cast<int>(ImGuiKey_A) + (c - 'a');
240-
if (c >= 'A' && c <= 'Z') return static_cast<int>(ImGuiKey_A) + (c - 'A');
241-
exception("getKeyCode only supports 0-9, a-z, A-Z");
242-
return -1;
243-
}
244-
245237
std::string GLEngineGLFW::getClipboardText() {
246238
std::string clipboardData = ImGui::GetClipboardText();
247239
return clipboardData;

src/view.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -297,12 +297,12 @@ void processKeyboardNavigation(ImGuiIO& io) {
297297

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

300-
if (ImGui::IsKeyDown(static_cast<ImGuiKey>(render::engine->getKeyCode('a')))) delta.x += 1.f;
301-
if (ImGui::IsKeyDown(static_cast<ImGuiKey>(render::engine->getKeyCode('d')))) delta.x += -1.f;
302-
if (ImGui::IsKeyDown(static_cast<ImGuiKey>(render::engine->getKeyCode('q')))) delta.y += 1.f;
303-
if (ImGui::IsKeyDown(static_cast<ImGuiKey>(render::engine->getKeyCode('e')))) delta.y += -1.f;
304-
if (ImGui::IsKeyDown(static_cast<ImGuiKey>(render::engine->getKeyCode('w')))) delta.z += 1.f;
305-
if (ImGui::IsKeyDown(static_cast<ImGuiKey>(render::engine->getKeyCode('s')))) delta.z += -1.f;
300+
if (ImGui::IsKeyDown(ImGuiKey_A)) delta.x += 1.f;
301+
if (ImGui::IsKeyDown(ImGuiKey_D)) delta.x += -1.f;
302+
if (ImGui::IsKeyDown(ImGuiKey_Q)) delta.y += 1.f;
303+
if (ImGui::IsKeyDown(ImGuiKey_E)) delta.y += -1.f;
304+
if (ImGui::IsKeyDown(ImGuiKey_W)) delta.z += 1.f;
305+
if (ImGui::IsKeyDown(ImGuiKey_S)) delta.z += -1.f;
306306

307307
if (glm::length(delta) > 0.) {
308308
hasMovement = true;

0 commit comments

Comments
 (0)