lets see if this helps with issue #139

This commit is contained in:
titiger
2016-11-12 18:04:12 +01:00
parent 7b47f5edb1
commit 1dfe1b8b42

View File

@@ -80,16 +80,6 @@ static HWND GetSDLWindow()
#endif #endif
static bool isUnprintableChar(SDL_keysym key, SDL_Keymod mod) { static bool isUnprintableChar(SDL_keysym key, SDL_Keymod mod) {
if(mod) {
if ((mod & (KMOD_SHIFT)) && (key.sym <= 127 || key.sym >= 0x20)) {
return false;
}
//if((mod & (KMOD_SHIFT)) && (key.sym == SDLK_QUESTION || key.sym == SDLK_SLASH)) {
// return false;
//}
}
switch (key.sym) { switch (key.sym) {
// We want to allow some, which are handled specially // We want to allow some, which are handled specially
case SDLK_RETURN: case SDLK_RETURN:
@@ -105,9 +95,15 @@ static bool isUnprintableChar(SDL_keysym key, SDL_Keymod mod) {
case SDLK_PAGEUP: case SDLK_PAGEUP:
case SDLK_PAGEDOWN: case SDLK_PAGEDOWN:
return true; return true;
default: default:// do nothing
break;
}
// U+0000 to U+001F are control characters // U+0000 to U+001F are control characters
/* Don't post text events for unprintable characters */ /* Don't post text events for unprintable characters */
if(StartsWith(SDL_GetKeyName(key.sym),"SDLK_KP")){
return false;
}
if (key.sym > 127) { if (key.sym > 127) {
return true; return true;
} }
@@ -115,13 +111,9 @@ static bool isUnprintableChar(SDL_keysym key, SDL_Keymod mod) {
return true; return true;
} }
if(mod) {
return true;
}
//printf("isUnprintableChar returns false for [%d]\n",key.sym); //printf("isUnprintableChar returns false for [%d]\n",key.sym);
return false; return false;
}
} }
Window::Window() { Window::Window() {
@@ -343,11 +335,10 @@ bool Window::handleEvent() {
} }
} }
// // Stop unprintable characters (ctrl+, alt+ and escape), // // Stop keys which would be handled twice ( one time as text input, one time as key down )
// // also prevent ` and/or ~ appearing in console every time it's toggled.
SDL_Keymod mod = SDL_GetModState(); SDL_Keymod mod = SDL_GetModState();
if (!isUnprintableChar(event.key.keysym,mod)) { if (!isUnprintableChar(event.key.keysym,mod)) {
printf("In SDL_KEYDOWN key SKIP [%d]\n",event.key.keysym.sym); //printf("In SDL_KEYDOWN key SKIP [%d]\n",event.key.keysym.sym);
break; break;
} }
codeLocation = "i"; codeLocation = "i";