mirror of
https://github.com/raysan5/raylib.git
synced 2025-09-06 03:18:14 +00:00
REVIEWED: SDL text input to Unicode codepoints #3650
REVIEWED: GLFW naming conventions to reflect codepoints reading
This commit is contained in:
@@ -126,7 +126,7 @@ static void WindowDropCallback(GLFWwindow *window, int count, const char **paths
|
|||||||
|
|
||||||
// Input callbacks events
|
// Input callbacks events
|
||||||
static void KeyCallback(GLFWwindow *window, int key, int scancode, int action, int mods); // GLFW3 Keyboard Callback, runs on key pressed
|
static void KeyCallback(GLFWwindow *window, int key, int scancode, int action, int mods); // GLFW3 Keyboard Callback, runs on key pressed
|
||||||
static void CharCallback(GLFWwindow *window, unsigned int key); // GLFW3 Char Key Callback, runs on key pressed (get char value)
|
static void CharCallback(GLFWwindow *window, unsigned int codepoint); // GLFW3 Char Callback, runs on key pressed (get codepoint value)
|
||||||
static void MouseButtonCallback(GLFWwindow *window, int button, int action, int mods); // GLFW3 Mouse Button Callback, runs on mouse button pressed
|
static void MouseButtonCallback(GLFWwindow *window, int button, int action, int mods); // GLFW3 Mouse Button Callback, runs on mouse button pressed
|
||||||
static void MouseCursorPosCallback(GLFWwindow *window, double x, double y); // GLFW3 Cursor Position Callback, runs on mouse move
|
static void MouseCursorPosCallback(GLFWwindow *window, double x, double y); // GLFW3 Cursor Position Callback, runs on mouse move
|
||||||
static void MouseScrollCallback(GLFWwindow *window, double xoffset, double yoffset); // GLFW3 Scrolling Callback, runs on mouse wheel
|
static void MouseScrollCallback(GLFWwindow *window, double xoffset, double yoffset); // GLFW3 Scrolling Callback, runs on mouse wheel
|
||||||
@@ -1714,10 +1714,10 @@ static void KeyCallback(GLFWwindow *window, int key, int scancode, int action, i
|
|||||||
if ((key == CORE.Input.Keyboard.exitKey) && (action == GLFW_PRESS)) glfwSetWindowShouldClose(platform.handle, GLFW_TRUE);
|
if ((key == CORE.Input.Keyboard.exitKey) && (action == GLFW_PRESS)) glfwSetWindowShouldClose(platform.handle, GLFW_TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
// GLFW3 Char Key Callback, runs on key down (gets equivalent unicode char value)
|
// GLFW3 Char Callback, get unicode codepoint value
|
||||||
static void CharCallback(GLFWwindow *window, unsigned int key)
|
static void CharCallback(GLFWwindow *window, unsigned int codepoint)
|
||||||
{
|
{
|
||||||
//TRACELOG(LOG_DEBUG, "Char Callback: KEY:%i(%c)", key, key);
|
//TRACELOG(LOG_DEBUG, "Char Callback: Codepoint: %i", codepoint);
|
||||||
|
|
||||||
// NOTE: Registers any key down considering OS keyboard layout but
|
// NOTE: Registers any key down considering OS keyboard layout but
|
||||||
// does not detect action events, those should be managed by user...
|
// does not detect action events, those should be managed by user...
|
||||||
@@ -1728,7 +1728,7 @@ static void CharCallback(GLFWwindow *window, unsigned int key)
|
|||||||
if (CORE.Input.Keyboard.charPressedQueueCount < MAX_CHAR_PRESSED_QUEUE)
|
if (CORE.Input.Keyboard.charPressedQueueCount < MAX_CHAR_PRESSED_QUEUE)
|
||||||
{
|
{
|
||||||
// Add character to the queue
|
// Add character to the queue
|
||||||
CORE.Input.Keyboard.charPressedQueue[CORE.Input.Keyboard.charPressedQueueCount] = key;
|
CORE.Input.Keyboard.charPressedQueue[CORE.Input.Keyboard.charPressedQueueCount] = codepoint;
|
||||||
CORE.Input.Keyboard.charPressedQueueCount++;
|
CORE.Input.Keyboard.charPressedQueueCount++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1111,19 +1111,23 @@ void PollInputEvents(void)
|
|||||||
|
|
||||||
case SDL_TEXTINPUT:
|
case SDL_TEXTINPUT:
|
||||||
{
|
{
|
||||||
|
// NOTE: event.text.text data comes an UTF-8 text sequence but we register codepoints (int)
|
||||||
|
|
||||||
|
int codepointSize = 0;
|
||||||
|
|
||||||
// Check if there is space available in the key queue
|
// Check if there is space available in the key queue
|
||||||
if (CORE.Input.Keyboard.keyPressedQueueCount < MAX_KEY_PRESSED_QUEUE)
|
if (CORE.Input.Keyboard.keyPressedQueueCount < MAX_KEY_PRESSED_QUEUE)
|
||||||
{
|
{
|
||||||
// Add character to the queue
|
// Add character (key) to the queue
|
||||||
CORE.Input.Keyboard.keyPressedQueue[CORE.Input.Keyboard.keyPressedQueueCount] = event.text.text[0];
|
CORE.Input.Keyboard.keyPressedQueue[CORE.Input.Keyboard.keyPressedQueueCount] = GetCodepointNext(event.text.text, &codepointSize);
|
||||||
CORE.Input.Keyboard.keyPressedQueueCount++;
|
CORE.Input.Keyboard.keyPressedQueueCount++;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if there is space available in the queue
|
// Check if there is space available in the queue
|
||||||
if (CORE.Input.Keyboard.charPressedQueueCount < MAX_CHAR_PRESSED_QUEUE)
|
if (CORE.Input.Keyboard.charPressedQueueCount < MAX_CHAR_PRESSED_QUEUE)
|
||||||
{
|
{
|
||||||
// Add character to the queue
|
// Add character (codepoint) to the queue
|
||||||
CORE.Input.Keyboard.charPressedQueue[CORE.Input.Keyboard.charPressedQueueCount] = event.text.text[0];
|
CORE.Input.Keyboard.charPressedQueue[CORE.Input.Keyboard.charPressedQueueCount] = GetCodepointNext(event.text.text, &codepointSize);
|
||||||
CORE.Input.Keyboard.charPressedQueueCount++;
|
CORE.Input.Keyboard.charPressedQueueCount++;
|
||||||
}
|
}
|
||||||
} break;
|
} break;
|
||||||
|
Reference in New Issue
Block a user