mirror of
https://github.com/glest/glest-source.git
synced 2025-08-15 21:04:00 +02:00
- attempt to fix bugs related to sdl2 key handling
This commit is contained in:
@@ -1131,6 +1131,8 @@ void MainWindow::eventKeyDown(SDL_KeyboardEvent key) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//printf("In mainwindow checking keypress for key [%d] mod [%d] modvalue: %d\n",key.keysym.sym,keystate.mod,(keystate.mod & (KMOD_LCTRL | KMOD_RCTRL)));
|
||||||
|
|
||||||
if(program != NULL && program->isInSpecialKeyCaptureEvent() == false) {
|
if(program != NULL && program->isInSpecialKeyCaptureEvent() == false) {
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
|
@@ -78,7 +78,17 @@ static HWND GetSDLWindow()
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static bool isUnprintableChar(SDL_keysym key) {
|
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:
|
||||||
@@ -103,6 +113,11 @@ static bool isUnprintableChar(SDL_keysym key) {
|
|||||||
if(key.sym < 0x20) {
|
if(key.sym < 0x20) {
|
||||||
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;
|
||||||
}
|
}
|
||||||
@@ -335,7 +350,9 @@ bool Window::handleEvent() {
|
|||||||
// }
|
// }
|
||||||
// Stop unprintable characters (ctrl+, alt+ and escape),
|
// Stop unprintable characters (ctrl+, alt+ and escape),
|
||||||
// also prevent ` and/or ~ appearing in console every time it's toggled.
|
// also prevent ` and/or ~ appearing in console every time it's toggled.
|
||||||
if (!isUnprintableChar(event.key.keysym)) {
|
|
||||||
|
SDL_Keymod mod = SDL_GetModState();
|
||||||
|
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;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user