From 9ab07771dff7528bdbc1d83c2dbc4daf03f4964e Mon Sep 17 00:00:00 2001 From: Adam Johnson Date: Fri, 18 Feb 2022 18:11:37 -0600 Subject: [PATCH] Fixes bug where avatar run-lock state can get confused after alt-tabbing (cherry picked from commit 69dac251b6742ab7f77bed1a676e8de52920bd90) --- .../Plasma/PubUtilLib/plInputCore/plInputDevice.cpp | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/Sources/Plasma/PubUtilLib/plInputCore/plInputDevice.cpp b/Sources/Plasma/PubUtilLib/plInputCore/plInputDevice.cpp index 90846201..5e74921f 100644 --- a/Sources/Plasma/PubUtilLib/plInputCore/plInputDevice.cpp +++ b/Sources/Plasma/PubUtilLib/plInputCore/plInputDevice.cpp @@ -176,19 +176,16 @@ void plKeyboardDevice::HandleKeyEvent(plOSMsg message, plKeyDef key, bool bKeyDo if (key == KEY_SHIFT) { fShiftKeyDown = bKeyDown; -// return; } if (key == KEY_CTRL) { fCtrlKeyDown = bKeyDown; -// return; } if (key == KEY_CAPSLOCK) { - // Keyboards toggle the light on key-down, so I'm going with that. - if (bKeyDown && !bKeyRepeat) + if (!bKeyRepeat) { - fCapsLockLock = !fCapsLockLock; + fCapsLockLock = (GetKeyState(KEY_CAPSLOCK) & 1) == 1; plAvatarInputInterface::GetInstance()->ForceAlwaysRun(fCapsLockLock); } } @@ -208,7 +205,8 @@ void plKeyboardDevice::HandleWindowActivate(bool bActive, HWND hWnd) { if (bActive) { - fCtrlKeyDown = false; + // Refresh the caps lock state + HandleKeyEvent(KEYDOWN, KEY_CAPSLOCK, nil, false); } else {