- additional bugfixes for keyboard entry in sdl2

This commit is contained in:
SoftCoder
2015-10-08 18:25:28 -07:00
parent 6707343ac4
commit 45598620fa
2 changed files with 29 additions and 19 deletions

View File

@@ -492,10 +492,11 @@ void MenuStateKeysetup::keyDown(SDL_KeyboardEvent key) {
//printf("\nkeyDown [%d]\n",hotkeyChar);
string keyName = "";
if(hotkeyChar > SDLK_UNKNOWN && hotkeyChar < SDL_NUM_SCANCODES) {
//if(hotkeyChar > SDLK_UNKNOWN && hotkeyChar < SDL_NUM_SCANCODES) {
if(SystemFlags::VERBOSE_MODE_ENABLED) printf ("In [%s::%s Line: %d] keyName [%s] char [%d][%d]\n",__FILE__,__FUNCTION__,__LINE__,keyName.c_str(),hotkeyChar,key.keysym.sym);
keyName = SDL_GetKeyName(hotkeyChar);
}
//printf ("In [%s::%s Line: %d] keyName [%s] char [%d][%d]\n",__FILE__,__FUNCTION__,__LINE__,keyName.c_str(),hotkeyChar,key.keysym.sym);
//}
//key = hotkeyChar;
if(SystemFlags::VERBOSE_MODE_ENABLED) printf ("In [%s::%s Line: %d] keyName [%s] char [%d][%d]\n",__FILE__,__FUNCTION__,__LINE__,keyName.c_str(),hotkeyChar,key.keysym.sym);
@@ -524,6 +525,7 @@ void MenuStateKeysetup::keyDown(SDL_KeyboardEvent key) {
char szBuf[8096] = "";
snprintf(szBuf,8096," %s [%s][%d][%d][%d]",keyName.c_str(),utfStr,key.keysym.sym,hotkeyChar,key.keysym.mod);
labelTestValue.setText(szBuf);
//printf ("In [%s::%s Line: %d] szBuf [%s]\n",__FILE__,__FUNCTION__,__LINE__,szBuf);
delete [] utfStr;
@@ -541,9 +543,9 @@ void MenuStateKeysetup::keyUp(SDL_KeyboardEvent key) {
if(SystemFlags::VERBOSE_MODE_ENABLED) printf ("In [%s::%s Line: %d] char [%d][%d]\n",__FILE__,__FUNCTION__,__LINE__,hotkeyChar,key.keysym.sym);
string keyName = "";
if(hotkeyChar > SDLK_UNKNOWN && hotkeyChar < SDL_NUM_SCANCODES) {
//if(hotkeyChar > SDLK_UNKNOWN && hotkeyChar < SDL_NUM_SCANCODES) {
keyName = SDL_GetKeyName(hotkeyChar);
}
//}
key.keysym.sym = hotkeyChar;
if(SystemFlags::VERBOSE_MODE_ENABLED) printf ("In [%s::%s Line: %d] keyName [%s] char [%d][%d]\n",__FILE__,__FUNCTION__,__LINE__,keyName.c_str(),hotkeyChar,key.keysym.sym);

View File

@@ -97,7 +97,15 @@ static bool isUnprintableChar(SDL_keysym key) {
return true;
default:
// U+0000 to U+001F are control characters
return (key.sym < 0x20);
/* Don't post text events for unprintable characters */
if (key.sym > 127) {
return true;
}
if(key.sym < 0x20) {
return true;
}
//printf("isUnprintableChar returns false for [%d]\n",key.sym);
return false;
}
}
@@ -1067,22 +1075,22 @@ vector<int> extractKeyPressedUnicodeLength(string text) {
SDL_Keycode extractKeyPressed(SDL_KeyboardEvent input) {
SDL_Keycode c = SDLK_UNKNOWN;
//if(input.keysym.unicode > 0 && input.keysym.unicode < 0x80) {
if(input.keysym.sym > 0) {
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] input.keysym.sym = %d input.keysym.mod = %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,input.keysym.sym,input.keysym.mod);
//if(input.keysym.sym > 0) {
// if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] input.keysym.sym = %d input.keysym.mod = %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,input.keysym.sym,input.keysym.mod);
c = input.keysym.sym;
// c = input.keysym.sym;
// if(c <= SDLK_UNKNOWN || c >= SDLK_LAST) {
// c = SDLKey(c & 0xFF);
// }
//c = toupper(c);
if(SystemFlags::VERBOSE_MODE_ENABLED) printf ("In [%s::%s Line: %d] #1 (c & 0xFF) [%d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,(c & 0xFF));
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] #1 (c & 0xFF) [%d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,(c & 0xFF));
}
if(c <= SDLK_UNKNOWN) {
//if(SystemFlags::VERBOSE_MODE_ENABLED) printf ("In [%s::%s Line: %d] #1 (c & 0xFF) [%d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,(c & 0xFF));
//if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] #1 (c & 0xFF) [%d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,(c & 0xFF));
//}
//if(c <= SDLK_UNKNOWN) {
c = input.keysym.sym;
}
//}
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %u] c = [%d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,c);
@@ -1093,8 +1101,8 @@ SDL_Keycode extractKeyPressed(SDL_KeyboardEvent input) {
string pressKeyName = SDL_GetKeyName(c);
//string inputKeyName = SDL_GetKeyName(input.keysym.sym);
//printf ("PRESS pressed key [%d - %s] input.keysym.sym [%d] input.keysym.unicode [%d] mod = %d\n",
// c,pressKeyName.c_str(),input.keysym.sym,input.keysym.unicode,input.keysym.mod);
// printf ("PRESS pressed key [%d - %s] input.keysym.sym [%d] mod = %d\n",
// c,pressKeyName.c_str(),input.keysym.sym,input.keysym.mod);
if(SystemFlags::VERBOSE_MODE_ENABLED) printf ("In [%s::%s Line: %d] pressed key [%d - %s]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,c,pressKeyName.c_str());
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] pressed key [%d - %s]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,c,pressKeyName.c_str());