From 77b36f45f2bb4c5ba54925a6d9a52c29fcba35c8 Mon Sep 17 00:00:00 2001 From: A-lex-Ra Date: Fri, 23 Feb 2024 20:10:35 +0600 Subject: [PATCH] remove redundant static_cast by changing Events::pressedKeys template parameter from int to keycode --- src/frontend/gui/GUI.cpp | 2 +- src/window/Events.cpp | 2 +- src/window/Events.h | 2 +- src/window/Window.cpp | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/frontend/gui/GUI.cpp b/src/frontend/gui/GUI.cpp index 96fb59b2..293f4432 100644 --- a/src/frontend/gui/GUI.cpp +++ b/src/frontend/gui/GUI.cpp @@ -101,7 +101,7 @@ void GUI::act(float delta) { focus->typed(codepoint); } for (auto key : Events::pressedKeys) { - focus->keyPressed(static_cast(key)); // temporary solution + focus->keyPressed(key); } if (!Events::_cursor_locked) { diff --git a/src/window/Events.cpp b/src/window/Events.cpp index 1d7cafca..3b381558 100644 --- a/src/window/Events.cpp +++ b/src/window/Events.cpp @@ -13,7 +13,7 @@ glm::vec2 Events::cursor = {}; bool Events::cursor_drag = false; bool Events::_cursor_locked = false; std::vector Events::codepoints; -std::vector Events::pressedKeys; +std::vector Events::pressedKeys; std::unordered_map Events::bindings; bool Events::pressed(keycode keycode) { diff --git a/src/window/Events.h b/src/window/Events.h index 11cbb71f..bc6d911a 100644 --- a/src/window/Events.h +++ b/src/window/Events.h @@ -24,7 +24,7 @@ public: static bool cursor_drag; static bool _cursor_locked; static std::vector codepoints; - static std::vector pressedKeys; + static std::vector pressedKeys; static std::unordered_map bindings; static void pollEvents(); diff --git a/src/window/Window.cpp b/src/window/Window.cpp index d18462b7..831edf3a 100644 --- a/src/window/Window.cpp +++ b/src/window/Window.cpp @@ -27,13 +27,13 @@ void key_callback(GLFWwindow*, int key, int scancode, int action, int /*mode*/) if (key == GLFW_KEY_UNKNOWN) return; if (action == GLFW_PRESS) { Events::setKey(key, true); - Events::pressedKeys.push_back(key); + Events::pressedKeys.push_back(static_cast(key)); } else if (action == GLFW_RELEASE) { Events::setKey(key, false); } else if (action == GLFW_REPEAT) { - Events::pressedKeys.push_back(key); + Events::pressedKeys.push_back(static_cast(key)); } }