Add support for receiving control characters.

This commit is contained in:
nthung-2k5 2023-07-17 21:06:29 +07:00
parent e0c80f5ddd
commit a52ddc14bb
3 changed files with 7 additions and 1 deletions

View File

@ -70,6 +70,8 @@
// By default EndDrawing() does this job: draws everything + SwapScreenBuffer() + manage frame timing + PollInputEvents()
// Enabling this flag allows manual control of the frame processes, use at your own risk
//#define SUPPORT_CUSTOM_FRAME_CONTROL 1
// Support receiving input of control characters, mainly for backspace and newline characters
//#define SUPPORT_INPUT_CONTROL_CHARS 1
// rcore: Configuration values
//------------------------------------------------------------------------------------

View File

@ -314,7 +314,7 @@ void _glfwInputChar(_GLFWwindow* window, uint32_t codepoint, int mods, GLFWbool
assert(mods == (mods & GLFW_MOD_MASK));
assert(plain == GLFW_TRUE || plain == GLFW_FALSE);
if (codepoint < 32 || (codepoint > 126 && codepoint < 160))
if (codepoint > 126 && codepoint < 160) // original: if (codepoint < 32 || (codepoint > 126 && codepoint < 160)) // @nthung-2k5
return;
if (!window->lockKeyMods)

View File

@ -5553,6 +5553,10 @@ static void CharCallback(GLFWwindow *window, unsigned int key)
// Ref: https://github.com/glfw/glfw/issues/668#issuecomment-166794907
// Ref: https://www.glfw.org/docs/latest/input_guide.html#input_char
#if !defined(SUPPORT_INPUT_CONTROL_CHARS)
// Control characters
if (key < 32) return;
#endif
// Check if there is space available in the queue
if (CORE.Input.Keyboard.charPressedQueueCount < MAX_CHAR_PRESSED_QUEUE)
{