diff --git a/indra/llwindow/llkeyboardsdl.cpp b/indra/llwindow/llkeyboardsdl.cpp index 86b97b23d8..3caa9912dc 100644 --- a/indra/llwindow/llkeyboardsdl.cpp +++ b/indra/llwindow/llkeyboardsdl.cpp @@ -40,20 +40,25 @@ LLKeyboardSDL::LLKeyboardSDL() // Virtual key mappings from SDL_keysym.h ... // SDL maps the letter keys to the ASCII you'd expect, but it's lowercase... - U16 cur_char; - for (cur_char = 'A'; cur_char <= 'Z'; cur_char++) - { - mTranslateKeyMap[cur_char] = cur_char; - } - for (cur_char = 'a'; cur_char <= 'z'; cur_char++) - { - mTranslateKeyMap[cur_char] = (cur_char - 'a') + 'A'; - } - for (cur_char = '0'; cur_char <= '9'; cur_char++) - { - mTranslateKeyMap[cur_char] = cur_char; - } + // Those are handled by SDL2 via text input, do not map them + + // U16 cur_char; + // for (cur_char = 'A'; cur_char <= 'Z'; cur_char++) + // { + // mTranslateKeyMap[cur_char] = cur_char; + // } + // for (cur_char = 'a'; cur_char <= 'z'; cur_char++) + // { + // mTranslateKeyMap[cur_char] = (cur_char - 'a') + 'A'; + // } + // + // for (cur_char = '0'; cur_char <= '9'; cur_char++) + // { + // mTranslateKeyMap[cur_char] = cur_char; + // } + + // Those are handled by SDL2 via text input, do not map them mTranslateKeyMap[SDLK_RETURN] = KEY_RETURN; mTranslateKeyMap[SDLK_LEFT] = KEY_LEFT; mTranslateKeyMap[SDLK_RIGHT] = KEY_RIGHT; @@ -111,17 +116,17 @@ LLKeyboardSDL::LLKeyboardSDL() mTranslateKeyMap[SDLK_F10] = KEY_F10; mTranslateKeyMap[SDLK_F11] = KEY_F11; mTranslateKeyMap[SDLK_F12] = KEY_F12; - mTranslateKeyMap[SDLK_PLUS] = '='; - mTranslateKeyMap[SDLK_COMMA] = ','; - mTranslateKeyMap[SDLK_MINUS] = '-'; - mTranslateKeyMap[SDLK_PERIOD] = '.'; - mTranslateKeyMap[SDLK_BACKQUOTE] = '`'; - mTranslateKeyMap[SDLK_SLASH] = KEY_DIVIDE; - mTranslateKeyMap[SDLK_SEMICOLON] = ';'; - mTranslateKeyMap[SDLK_LEFTBRACKET] = '['; - mTranslateKeyMap[SDLK_BACKSLASH] = '\\'; - mTranslateKeyMap[SDLK_RIGHTBRACKET] = ']'; - mTranslateKeyMap[SDLK_QUOTE] = '\''; + // mTranslateKeyMap[SDLK_PLUS] = '='; // Those are handled by SDL2 via text input, do not map them + // mTranslateKeyMap[SDLK_COMMA] = ','; // Those are handled by SDL2 via text input, do not map them + // mTranslateKeyMap[SDLK_MINUS] = '-'; // Those are handled by SDL2 via text input, do not map them + // mTranslateKeyMap[SDLK_PERIOD] = '.'; // Those are handled by SDL2 via text input, do not map them + // mTranslateKeyMap[SDLK_BACKQUOTE] = '`'; // Those are handled by SDL2 via text input, do not map them + // mTranslateKeyMap[SDLK_SLASH] = KEY_DIVIDE; // Those are handled by SDL2 via text input, do not map them + // mTranslateKeyMap[SDLK_SEMICOLON] = ';'; // Those are handled by SDL2 via text input, do not map them + // mTranslateKeyMap[SDLK_LEFTBRACKET] = '['; // Those are handled by SDL2 via text input, do not map them + // mTranslateKeyMap[SDLK_BACKSLASH] = '\\'; // Those are handled by SDL2 via text input, do not map them + // mTranslateKeyMap[SDLK_RIGHTBRACKET] = ']'; // Those are handled by SDL2 via text input, do not map them + // mTranslateKeyMap[SDLK_QUOTE] = '\''; // Those are handled by SDL2 via text input, do not map them // Build inverse map for (auto iter = mTranslateKeyMap.begin(); iter != mTranslateKeyMap.end(); iter++) diff --git a/indra/llwindow/llwindowsdl.cpp b/indra/llwindow/llwindowsdl.cpp index cc757e523b..ed42683b2e 100644 --- a/indra/llwindow/llwindowsdl.cpp +++ b/indra/llwindow/llwindowsdl.cpp @@ -1752,7 +1752,13 @@ void LLWindowSDL::gatherInput() { auto string = utf8str_to_utf16str( event.text.text ); for( auto key: string ) + { + mKeyScanCode = string[0]; + mKeyVirtualKey = string[0]; + mKeyModifiers = SDL_GetModState(); + mSDLSym = string[0]; handleUnicodeUTF16( key, gKeyboard->currentMask(FALSE)); + } break; } @@ -1760,9 +1766,9 @@ void LLWindowSDL::gatherInput() mKeyScanCode = event.key.keysym.scancode; mKeyVirtualKey = event.key.keysym.sym; mKeyModifiers = event.key.keysym.mod; - mSDLSym = event.key.keysym.sym; // Store the SDL Keysym too. + mSDLSym = event.key.keysym.sym & ~SDLK_SCANCODE_MASK; // Store the SDL Keysym too. - gKeyboard->handleKeyDown(event.key.keysym.sym, event.key.keysym.mod); + // gKeyboard->handleKeyDown(event.key.keysym.sym, event.key.keysym.mod); // part of the fix for SL-13243 if (SDLCheckGrabbyKeys(event.key.keysym.sym, TRUE) != 0) SDLReallyCaptureInput(TRUE); @@ -1771,7 +1777,10 @@ void LLWindowSDL::gatherInput() KEY dummyKey{}; if( gKeyboard->translateKey( mSDLSym, &dummyKey ) ) + { + gKeyboard->handleKeyDown(event.key.keysym.sym, event.key.keysym.mod); handleUnicodeUTF16( mSDLSym, gKeyboard->currentMask(FALSE)); + } } break; @@ -1779,12 +1788,20 @@ void LLWindowSDL::gatherInput() mKeyScanCode = event.key.keysym.scancode; mKeyVirtualKey = event.key.keysym.sym; mKeyModifiers = event.key.keysym.mod; - mSDLSym = event.key.keysym.sym; // Store the SDL Keysym too. + mSDLSym = event.key.keysym.sym & ~SDLK_SCANCODE_MASK; // Store the SDL Keysym too. if (SDLCheckGrabbyKeys(event.key.keysym.sym, FALSE) == 0) SDLReallyCaptureInput(FALSE); // part of the fix for SL-13243 - gKeyboard->handleKeyUp(event.key.keysym.sym, event.key.keysym.mod); + // gKeyboard->handleKeyUp(event.key.keysym.sym, event.key.keysym.mod); + { + KEY dummyKey{}; + + if( gKeyboard->translateKey( mSDLSym, &dummyKey ) ) + { + gKeyboard->handleKeyUp(event.key.keysym.sym, event.key.keysym.mod); + } + } break; case SDL_MOUSEBUTTONDOWN: