diff options
| author | Uneven Prankster <unevenprankster@protonmail.com> | 2023-07-18 13:30:13 -0300 |
|---|---|---|
| committer | Uneven Prankster <unevenprankster@protonmail.com> | 2023-07-18 13:30:13 -0300 |
| commit | 2ad64da53834d6bacc65a5ac4afddf901d1218e3 (patch) | |
| tree | 436fd3f6671efd17e416abbbfeb52311f0aac0a0 /raylib/rcore.c | |
| parent | 049779039009991b39d62df7823baa21c53bfbf4 (diff) | |
Change to keys based on a active Raylib fork by Dan Bechard.
Diffstat (limited to 'raylib/rcore.c')
| -rw-r--r-- | raylib/rcore.c | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/raylib/rcore.c b/raylib/rcore.c index 45495bb..a6d2df1 100644 --- a/raylib/rcore.c +++ b/raylib/rcore.c @@ -5458,6 +5458,16 @@ static void WindowFocusCallback(GLFWwindow *window, int focused) static void KeyCallback(GLFWwindow *window, int key, int scancode, int action, int mods) { if (key < 0) return; // Security check, macOS fn key generates -1 + + // Check if there is space available in the key queue + if (CORE.Input.Keyboard.keyPressedQueueCount < MAX_KEY_PRESSED_QUEUE && + (action == GLFW_PRESS || action == GLFW_REPEAT) && + !IsKeyPressed(key)) + { + // Add character to the queue + CORE.Input.Keyboard.keyPressedQueue[CORE.Input.Keyboard.keyPressedQueueCount] = key; + CORE.Input.Keyboard.keyPressedQueueCount++; + } // WARNING: GLFW could return GLFW_REPEAT, we need to consider it as 1 // to work properly with our implementation (IsKeyDown/IsKeyUp checks) @@ -5470,14 +5480,6 @@ static void KeyCallback(GLFWwindow *window, int key, int scancode, int action, i ((key == KEY_NUM_LOCK) && ((mods & GLFW_MOD_NUM_LOCK) > 0))) CORE.Input.Keyboard.currentKeyState[key] = 1; #endif - // Check if there is space available in the key queue - if ((CORE.Input.Keyboard.keyPressedQueueCount < MAX_KEY_PRESSED_QUEUE) && (action == GLFW_PRESS)) - { - // Add character to the queue - CORE.Input.Keyboard.keyPressedQueue[CORE.Input.Keyboard.keyPressedQueueCount] = key; - CORE.Input.Keyboard.keyPressedQueueCount++; - } - // Check the exit key to set close window if ((key == CORE.Input.Keyboard.exitKey) && (action == GLFW_PRESS)) glfwSetWindowShouldClose(CORE.Window.handle, GLFW_TRUE); |
