From 3926753c0dab318ba16e8d805cdf584f3d5bd8c0 Mon Sep 17 00:00:00 2001 From: Daryl Borth Date: Tue, 29 Jan 2019 18:19:21 -0700 Subject: [PATCH] fix issues with on-screen keyboard --- source/gui/gui_keyboard.cpp | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/source/gui/gui_keyboard.cpp b/source/gui/gui_keyboard.cpp index 457f017..7604744 100644 --- a/source/gui/gui_keyboard.cpp +++ b/source/gui/gui_keyboard.cpp @@ -17,12 +17,7 @@ static char * GetDisplayText(char * t) if(!t) return NULL; - int len = strlen(t); - - if(len < MAX_KEYBOARD_DISPLAY) - return t; - - snprintf(tmptxt, MAX_KEYBOARD_DISPLAY, "%s", &t[len-MAX_KEYBOARD_DISPLAY]); + snprintf(tmptxt, MAX_KEYBOARD_DISPLAY, "%s", t); return &tmptxt[0]; } @@ -330,16 +325,19 @@ void GuiKeyboard::Update(GuiTrigger * t) if(keyBtn[i][j]->GetState() == STATE_CLICKED) { - if(strlen(kbtextstr) < kbtextmaxlen) + int len = strlen(kbtextstr); + + if(len < kbtextmaxlen-1) { if(shift || caps) { - kbtextstr[strlen(kbtextstr)] = keys[i][j].chShift; + kbtextstr[len] = keys[i][j].chShift; } else { - kbtextstr[strlen(kbtextstr)] = keys[i][j].ch; + kbtextstr[len] = keys[i][j].ch; } + kbtextstr[len+1] = '\0'; } kbText->SetText(GetDisplayText(kbtextstr)); keyBtn[i][j]->SetState(STATE_SELECTED, t->chan);