From bbe357a83eee4e35b2588c38f75684437c83984a Mon Sep 17 00:00:00 2001 From: Krylov Yaroslav Date: Thu, 20 Jun 2019 10:29:48 +0300 Subject: [PATCH] fix shift and caps lock logic in evdev --- src/evdev.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/evdev.c b/src/evdev.c index 91ea495ef..1af0d1792 100644 --- a/src/evdev.c +++ b/src/evdev.c @@ -36,6 +36,7 @@ #include #include #include +#include #ifndef SYN_DROPPED // < v2.6.39 kernel headers // Workaround for CentOS-6, which is supported till 2020-11-30, but still on v2.6.32 @@ -350,9 +351,13 @@ static void handleKeyEvent(_GLFWeventDevice* ed, int code, int value) _glfwEvdevInputKey(key, ed->scancode, action, mods); if (action != GLFW_RELEASE){ - upper = ((mods & GLFW_MOD_SHIFT) != 0) != ((mods & GLFW_MOD_CAPS_LOCK) != 0); // shift xor capsl - if ((codepoint = translateGlfwKeyCodeToChar(key, upper))) + upper = mods & GLFW_MOD_SHIFT; + if ((codepoint = translateGlfwKeyCodeToChar(key, upper))){ + if( (mods & GLFW_MOD_CAPS_LOCK) && isalpha(codepoint) ){ + codepoint = isupper(codepoint) ? tolower(codepoint) : toupper(codepoint); + } _glfwEvdevInputChar(codepoint, mods, GLFW_TRUE); + } } } }