- bugfix to get proper typed character in sdl2
This commit is contained in:
parent
41ae158a9c
commit
95e5d2782c
|
@ -541,14 +541,10 @@ SDL_Keycode Config::translateStringToSDLKey(const string &value) const {
|
||||||
else {
|
else {
|
||||||
bool foundKey = false;
|
bool foundKey = false;
|
||||||
if(value.length() > 1) {
|
if(value.length() > 1) {
|
||||||
for(int i = SDLK_UNKNOWN; i < SDL_NUM_SCANCODES; ++i) {
|
SDL_Keycode lookup = SDL_GetKeyFromName(value.c_str());
|
||||||
SDL_Keycode key = static_cast<SDL_Keycode>(i);
|
if(lookup != SDLK_UNKNOWN) {
|
||||||
string keyName = SDL_GetKeyName(key);
|
result = lookup;
|
||||||
if(value == keyName) {
|
foundKey = true;
|
||||||
result = key;
|
|
||||||
foundKey = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -706,6 +706,7 @@ void MenuStateRoot::keyDown(SDL_KeyboardEvent key) {
|
||||||
Config &configKeys = Config::getInstance(std::pair<ConfigType,ConfigType>(cfgMainKeys,cfgUserKeys));
|
Config &configKeys = Config::getInstance(std::pair<ConfigType,ConfigType>(cfgMainKeys,cfgUserKeys));
|
||||||
//exit
|
//exit
|
||||||
//if(key == configKeys.getCharKey("ExitKey")) {
|
//if(key == configKeys.getCharKey("ExitKey")) {
|
||||||
|
//printf("Check Root menu exit key!\n");
|
||||||
if(isKeyPressed(configKeys.getSDLKey("ExitKey"),key) == true) {
|
if(isKeyPressed(configKeys.getSDLKey("ExitKey"),key) == true) {
|
||||||
Lang &lang= Lang::getInstance();
|
Lang &lang= Lang::getInstance();
|
||||||
showMessageBox(lang.getString("ExitGameQuestion"), "", true);
|
showMessageBox(lang.getString("ExitGameQuestion"), "", true);
|
||||||
|
|
|
@ -166,6 +166,7 @@ bool Window::handleEvent() {
|
||||||
|
|
||||||
//codeLocation = "b";
|
//codeLocation = "b";
|
||||||
|
|
||||||
|
SDL_StartTextInput();
|
||||||
while(SDL_PollEvent(&event)) {
|
while(SDL_PollEvent(&event)) {
|
||||||
try {
|
try {
|
||||||
codeLocation = "c";
|
codeLocation = "c";
|
||||||
|
@ -235,6 +236,7 @@ bool Window::handleEvent() {
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case SDL_KEYDOWN:
|
case SDL_KEYDOWN:
|
||||||
//printf("In [%s::%s] Line :%d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
//printf("In [%s::%s] Line :%d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
|
@ -681,7 +683,8 @@ bool isKeyPressed(SDL_Keycode compareKey, SDL_KeyboardEvent input,bool modifiers
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
bool isKeyPressed(SDL_Keycode compareKey, SDL_KeyboardEvent input,vector<int> modifiersToCheck) {
|
bool isKeyPressed(SDL_Keycode compareKey, SDL_KeyboardEvent input,vector<int> modifiersToCheck) {
|
||||||
Uint16 c = SDLK_UNKNOWN;
|
//Uint16 c = SDLK_UNKNOWN;
|
||||||
|
SDL_Keycode c = SDLK_UNKNOWN;
|
||||||
//if(input.keysym.unicode > 0 && input.keysym.unicode < 0x80) {
|
//if(input.keysym.unicode > 0 && input.keysym.unicode < 0x80) {
|
||||||
if(input.keysym.sym > 0) {
|
if(input.keysym.sym > 0) {
|
||||||
c = input.keysym.sym;
|
c = input.keysym.sym;
|
||||||
|
@ -780,6 +783,8 @@ bool isKeyPressed(SDL_Keycode compareKey, SDL_KeyboardEvent input,vector<int> mo
|
||||||
}
|
}
|
||||||
|
|
||||||
bool result = (c == compareKey);
|
bool result = (c == compareKey);
|
||||||
|
//printf("result = %d input = %d compare = %d\n",result,c,compareKey);
|
||||||
|
|
||||||
if(result == false) {
|
if(result == false) {
|
||||||
if(compareKey == SDLK_RETURN) {
|
if(compareKey == SDLK_RETURN) {
|
||||||
result = (c == SDLK_KP_ENTER);
|
result = (c == SDLK_KP_ENTER);
|
||||||
|
@ -963,7 +968,7 @@ SDL_Keycode extractKeyPressed(SDL_KeyboardEvent input) {
|
||||||
if(input.keysym.sym > 0) {
|
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(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 = (SDL_Keycode)input.keysym.sym;
|
c = input.keysym.sym;
|
||||||
// if(c <= SDLK_UNKNOWN || c >= SDLK_LAST) {
|
// if(c <= SDLK_UNKNOWN || c >= SDLK_LAST) {
|
||||||
// c = SDLKey(c & 0xFF);
|
// c = SDLKey(c & 0xFF);
|
||||||
// }
|
// }
|
||||||
|
@ -983,7 +988,7 @@ SDL_Keycode extractKeyPressed(SDL_KeyboardEvent input) {
|
||||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf ("In [%s::%s Line: %d] returning key [%d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,c);
|
if(SystemFlags::VERBOSE_MODE_ENABLED) printf ("In [%s::%s Line: %d] returning key [%d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,c);
|
||||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] returning key [%d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,c);
|
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] returning key [%d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,c);
|
||||||
|
|
||||||
string pressKeyName = SDL_GetKeyName((SDL_Keycode)c);
|
string pressKeyName = SDL_GetKeyName(c);
|
||||||
//string inputKeyName = SDL_GetKeyName(input.keysym.sym);
|
//string inputKeyName = SDL_GetKeyName(input.keysym.sym);
|
||||||
|
|
||||||
//printf ("PRESS pressed key [%d - %s] input.keysym.sym [%d] input.keysym.unicode [%d] mod = %d\n",
|
//printf ("PRESS pressed key [%d - %s] input.keysym.sym [%d] input.keysym.unicode [%d] mod = %d\n",
|
||||||
|
|
Loading…
Reference in New Issue
Block a user