diff --git a/Sources/Plasma/PubUtilLib/plInputCore/plInputDevice.cpp b/Sources/Plasma/PubUtilLib/plInputCore/plInputDevice.cpp index 5fbc5d27..96d5deb3 100644 --- a/Sources/Plasma/PubUtilLib/plInputCore/plInputDevice.cpp +++ b/Sources/Plasma/PubUtilLib/plInputCore/plInputDevice.cpp @@ -173,19 +173,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); } } @@ -206,7 +203,8 @@ void plKeyboardDevice::HandleWindowActivate(bool bActive, HWND hWnd) { if (bActive) { - fCtrlKeyDown = false; + // Refresh the caps lock state + HandleKeyEvent(KEYDOWN, KEY_CAPSLOCK, nil, false); } else { diff --git a/Sources/Plasma/PubUtilLib/plInputCore/plInputManager.cpp b/Sources/Plasma/PubUtilLib/plInputCore/plInputManager.cpp index f961484d..9e804b45 100644 --- a/Sources/Plasma/PubUtilLib/plInputCore/plInputManager.cpp +++ b/Sources/Plasma/PubUtilLib/plInputCore/plInputManager.cpp @@ -297,15 +297,14 @@ void plInputManager::HandleWin32ControlEvent(UINT message, WPARAM Wparam, LPARAM Wparam == KEY_TAB || Wparam == 0x0D) break; - UINT scan = Lparam >> 16; - scan = MapVirtualKeyEx(scan, MAPVK_VSC_TO_VK, nil); - if (scan == 0) scan = -1; + BYTE scan = Lparam >> 16; + UINT vkey = MapVirtualKey(scan, MAPVK_VSC_TO_VK); bExtended = Lparam >> 24 & 1; hsBool bRepeat = ((Lparam >> 29) & 0xf) != 0; bool down = !(Lparam >> 31); for (int i=0; iHandleKeyEvent( CHAR_MSG, (plKeyDef)scan, down, bRepeat, (wchar_t)Wparam ); + fInputDevices[i]->HandleKeyEvent( CHAR_MSG, (plKeyDef)vkey, down, bRepeat, (wchar_t)Wparam ); } break; case MOUSEWHEEL: