summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorRay <[email protected]>2022-09-25 00:14:59 +0200
committerRay <[email protected]>2022-09-25 00:14:59 +0200
commitea87491a82a0fc778056d1538d37ec851e8e0fbe (patch)
treef941e5132ff70f0c6821d18ce95cbc6479341bd6
parent810a0330abdf13c49843692407e2f77da08f8bdc (diff)
downloadraylib-ea87491a82a0fc778056d1538d37ec851e8e0fbe.tar.gz
raylib-ea87491a82a0fc778056d1538d37ec851e8e0fbe.zip
ADDED: Support CAPS/NUM lock keys registering if locked
-rw-r--r--src/rcore.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/rcore.c b/src/rcore.c
index 490ac4a1..214b9509 100644
--- a/src/rcore.c
+++ b/src/rcore.c
@@ -4136,6 +4136,8 @@ static bool InitGraphicsDevice(int width, int height)
glfwSetScrollCallback(CORE.Window.handle, MouseScrollCallback);
glfwSetCursorEnterCallback(CORE.Window.handle, CursorEnterCallback);
+ glfwSetInputMode(CORE.Window.handle, GLFW_LOCK_KEY_MODS, GLFW_TRUE); // Enable lock keys modifiers (CAPS, NUM)
+
glfwMakeContextCurrent(CORE.Window.handle);
#if !defined(PLATFORM_WEB)
@@ -5267,6 +5269,9 @@ static void KeyCallback(GLFWwindow *window, int key, int scancode, int action, i
if (action == GLFW_RELEASE) CORE.Input.Keyboard.currentKeyState[key] = 0;
else CORE.Input.Keyboard.currentKeyState[key] = 1;
+ // WARNING: Check if CAPS/NUM key modifiers are enabled and force down state for those keys
+ if (((mods & GLFW_MOD_CAPS_LOCK) > 0) || ((mods & GLFW_MOD_NUM_LOCK) > 0)) CORE.Input.Keyboard.currentKeyState[key] = 1;
+
// Check if there is space available in the key queue
if ((CORE.Input.Keyboard.keyPressedQueueCount < MAX_KEY_PRESSED_QUEUE) && (action == GLFW_PRESS))
{