Skip to content

Commit

Permalink
Fix GetKeyPressed and GetCharPressed for SDL (#3604)
Browse files Browse the repository at this point in the history
  • Loading branch information
ubkp authored Dec 5, 2023
1 parent 731b210 commit 984e83c
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/platforms/rcore_desktop_sdl.c
Original file line number Diff line number Diff line change
Expand Up @@ -1110,6 +1110,25 @@ void PollInputEvents(void)
if (key != KEY_NULL) CORE.Input.Keyboard.currentKeyState[key] = 0;
} break;

case SDL_TEXTINPUT:
{
// Check if there is space available in the key queue
if (CORE.Input.Keyboard.keyPressedQueueCount < MAX_KEY_PRESSED_QUEUE)
{
// Add character to the queue
CORE.Input.Keyboard.keyPressedQueue[CORE.Input.Keyboard.keyPressedQueueCount] = event.text.text[0];
CORE.Input.Keyboard.keyPressedQueueCount++;
}

// Check if there is space available in the queue
if (CORE.Input.Keyboard.charPressedQueueCount < MAX_CHAR_PRESSED_QUEUE)
{
// Add character to the queue
CORE.Input.Keyboard.charPressedQueue[CORE.Input.Keyboard.charPressedQueueCount] = event.text.text[0];
CORE.Input.Keyboard.charPressedQueueCount++;
}
} break;

// Check mouse events
case SDL_MOUSEBUTTONDOWN:
{
Expand Down

0 comments on commit 984e83c

Please sign in to comment.