remove redundant static_cast by changing Events::pressedKeys template parameter from int to keycode

This commit is contained in:
A-lex-Ra 2024-02-23 20:10:35 +06:00
parent 659a2610aa
commit 77b36f45f2
4 changed files with 5 additions and 5 deletions

View File

@ -101,7 +101,7 @@ void GUI::act(float delta) {
focus->typed(codepoint);
}
for (auto key : Events::pressedKeys) {
focus->keyPressed(static_cast<keycode>(key)); // temporary solution
focus->keyPressed(key);
}
if (!Events::_cursor_locked) {

View File

@ -13,7 +13,7 @@ glm::vec2 Events::cursor = {};
bool Events::cursor_drag = false;
bool Events::_cursor_locked = false;
std::vector<uint> Events::codepoints;
std::vector<int> Events::pressedKeys;
std::vector<keycode> Events::pressedKeys;
std::unordered_map<std::string, Binding> Events::bindings;
bool Events::pressed(keycode keycode) {

View File

@ -24,7 +24,7 @@ public:
static bool cursor_drag;
static bool _cursor_locked;
static std::vector<uint> codepoints;
static std::vector<int> pressedKeys;
static std::vector<keycode> pressedKeys;
static std::unordered_map<std::string, Binding> bindings;
static void pollEvents();

View File

@ -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<keycode>(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<keycode>(key));
}
}