FIRE-32123 - Attempt to fix Right-ALT cam on non AltGr keyboards while still keeping AltGr on AltGr keyboards working

master
Zi Ree 2022-10-02 15:54:26 +02:00
parent be6671b6ec
commit e977975008
2 changed files with 38 additions and 5 deletions

View File

@ -148,7 +148,7 @@ void LLKeyboardSDL::resetMaskKeys()
mKeyLevel[KEY_CONTROL] = TRUE;
}
if(mask & KMOD_LALT)
if(mask & KMOD_ALT)
{
mKeyLevel[KEY_ALT] = TRUE;
}
@ -170,7 +170,7 @@ MASK LLKeyboardSDL::updateModifiers(const U32 mask)
out_mask |= MASK_CONTROL;
}
if(mask & KMOD_LALT)
if(mask & KMOD_ALT)
{
out_mask |= MASK_ALT;
}
@ -252,7 +252,7 @@ MASK LLKeyboardSDL::currentMask(BOOL for_mouse_event)
result |= MASK_SHIFT;
if (mask & KMOD_CTRL)
result |= MASK_CONTROL;
if (mask & KMOD_LALT)
if (mask & KMOD_ALT)
result |= MASK_ALT;
// For keyboard events, consider Meta keys equivalent to Control

View File

@ -1779,11 +1779,40 @@ void LLWindowSDL::gatherInput()
static U64 previousTextinputTime = 0;
SDL_Event event;
// mask to apply to the keyup/keydown modifiers to handle AltGr keys correctly
static U32 altGrMask = 0x00;
// Handle all outstanding SDL events
while (SDL_PollEvent(&event))
{
switch (event.type)
{
case SDL_SYSWMEVENT:
{
XEvent e = event.syswm.msg->msg.x11.event;
if (e.type == KeyPress || e.type == KeyRelease)
{
// XLookupKeysym doesn't work here because of the weird way the "index" is
// tied to the e->state and we don't get the necessary information at this
// point, so we use the more expensive XLookupString which apparently knows
// all of the secrets inside XKeyEvent. -Zi
KeySym ks;
static char str[256+1];
XLookupString((XKeyEvent *) &e, str, 256, &ks, nullptr);
if (ks == XK_ISO_Level3_Shift)
{
altGrMask = KMOD_RALT;
}
else if (ks == XK_Alt_R)
{
altGrMask = 0x00;
}
}
break;
}
case SDL_MOUSEWHEEL:
if( event.wheel.y != 0 )
mCallbacks->handleScrollWheel(this, -event.wheel.y);
@ -1803,6 +1832,10 @@ void LLWindowSDL::gatherInput()
{
auto string = utf8str_to_utf16str( event.text.text );
mKeyModifiers = gKeyboard->currentMask( FALSE );
if (altGrMask)
{
mKeyModifiers &= ~MASK_ALT;
}
mInputType = "textinput";
for( auto key: string )
{
@ -1821,7 +1854,7 @@ void LLWindowSDL::gatherInput()
case SDL_KEYDOWN:
mKeyVirtualKey = event.key.keysym.sym;
mKeyModifiers = event.key.keysym.mod;
mKeyModifiers = event.key.keysym.mod & (~altGrMask);
mInputType = "keydown";
// treat all possible Enter/Return keys the same
@ -1863,7 +1896,7 @@ void LLWindowSDL::gatherInput()
case SDL_KEYUP:
mKeyVirtualKey = event.key.keysym.sym;
mKeyModifiers = event.key.keysym.mod;
mKeyModifiers = event.key.keysym.mod & (~altGrMask);
mInputType = "keyup";
// treat all possible Enter/Return keys the same