DJUI: Ignore garbage text inputs if there are no valid characters

This commit is contained in:
MysterD 2021-07-31 02:58:42 -07:00
parent 98b7dba74b
commit 0b3f363130
2 changed files with 15 additions and 7 deletions

View file

@ -1,7 +1 @@
function compiler() { make RENDER_API=D3D12 WINDOW_API=DXGI BETTERCAMERA=1 NODRAWINGDISTANCE=1 DEBUG=1 IMMEDIATELOAD=1 DEVELOPMENT=1 && ./build/us_pc/sm64.us.f3dex2e.exe
make RENDER_API=$1 WINDOW_API=$2 AUDIO_API=$3 CONTROLLER_API=$4
}
compiler D3D12 DXGI SDL2 SDL2 d3d12_2
./build/us_pc/sm64.us.f3dex2e.exe

View file

@ -307,6 +307,20 @@ static void djui_inputbox_on_text_input(struct DjuiBase *base, char* text) {
int msgLen = strlen(msg); int msgLen = strlen(msg);
int textLen = strlen(text); int textLen = strlen(text);
// make sure we're not just printing garbage characters
bool containsValidAscii = false;
char* tinput = text;
while (*tinput != NULL) {
if (*tinput >= '!' && *tinput <= '~') {
containsValidAscii = true;
break;
}
tinput++;
}
if (!containsValidAscii) {
return;
}
// truncate // truncate
if (textLen + msgLen >= inputbox->bufferSize) { if (textLen + msgLen >= inputbox->bufferSize) {
int space = (inputbox->bufferSize - msgLen); int space = (inputbox->bufferSize - msgLen);