sdl12-compat: Use fallback for unicode on keydown when CTRL is pressed.

From c59075cd443f82b31179d5f18602e78e5139d35b Mon Sep 17 00:00:00 2001
From: Aaron Barany <[EMAIL REDACTED]>
Date: Thu, 28 Jul 2022 00:32:40 -0700
Subject: [PATCH] Use fallback for unicode on keydown when CTRL is pressed.

Text events aren't sent when CTRL is pressed, causing applications that
depend on it to ignore some keyboard commands.

fixes #187
---
 src/SDL12_compat.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/src/SDL12_compat.c b/src/SDL12_compat.c
index 45613181..1339644f 100644
--- a/src/SDL12_compat.c
+++ b/src/SDL12_compat.c
@@ -4056,7 +4056,16 @@ EventFilter20to12(void *data, SDL_Event *event20)
                     FlushPendingKeydownEvent(0x1B); /* '\e' */
                     break;
                 default:
-                    /* not a supported control character */
+                    /* not a supported control character
+                       when CTRL is pressed, text events aren't sent so use fallback for unicode */
+                    if (PendingKeydownEvent.key.keysym.mod & KMOD_CTRL) {
+                        const char *keyName = SDL_GetKeyName(PendingKeydownEvent.key.keysym.sym);
+                        /* use key name as unicode if it's a single character */
+                        if (keyName[0] && !keyName[1])
+                            FlushPendingKeydownEvent(keyName[0]);
+                        else
+                            FlushPendingKeydownEvent(0);
+                    }
                     break;
             }