From 2cd9f6f5f0d750dd94968be3d089d0cc963b4040 Mon Sep 17 00:00:00 2001 From: Vadim Grigoruk Date: Sat, 25 Aug 2018 01:13:36 +0300 Subject: [PATCH] no message --- src/studio.c | 4 ++++ src/system.c | 19 +++++++++++++++++++ src/system.h | 2 ++ 3 files changed, 25 insertions(+) diff --git a/src/studio.c b/src/studio.c index 8368cb1..cb1b756 100644 --- a/src/studio.c +++ b/src/studio.c @@ -237,6 +237,10 @@ static struct char getKeyboardText() { + char text = getSystem()->getKeyboardText(); + + if(text) return text; + tic_mem* tic = impl.studio.tic; static const char Symbols[] = " abcdefghijklmnopqrstuvwxyz0123456789-=[]\\;'`,./ "; diff --git a/src/system.c b/src/system.c index b85c1ad..e783433 100644 --- a/src/system.c +++ b/src/system.c @@ -65,6 +65,7 @@ static struct GPU_Image* down; } texture; + char text; } keyboard; u32 touchCounter; @@ -394,6 +395,15 @@ static void processMouse() } } +// TODO: ugly hack, but I didn't find a better solution +// will try to fix it later +static char getKeyboardText() +{ + char text = platform.keyboard.text; + platform.keyboard.text = 0; + return text; +} + static void processKeyboard() { static const u8 KeyboardCodes[] = @@ -785,6 +795,14 @@ static void pollEvent() case SDL_WINDOWEVENT_FOCUS_GAINED: platform.studio->updateProject(); break; } break; + case SDL_TEXTINPUT: + { + const char* text = event.text.text; + + if(strlen(text) == 1) + platform.keyboard.text = *text; + } + break; case SDL_QUIT: platform.studio->exit(); break; @@ -1278,6 +1296,7 @@ static System systemInterface = .preseed = preseed, .poll = pollEvent, .updateConfig = updateConfig, + .getKeyboardText = getKeyboardText, }; static void gpuTick() diff --git a/src/system.h b/src/system.h index 7473064..cb34d5b 100644 --- a/src/system.h +++ b/src/system.h @@ -29,6 +29,8 @@ typedef struct void (*updateConfig)(); + char (*getKeyboardText)(); + } System; typedef struct