|
|
@ -76,18 +76,15 @@ fCapsLockKeyDown(false), |
|
|
|
fAltKeyDown(false), |
|
|
|
fAltKeyDown(false), |
|
|
|
fCtrlKeyDown(false), |
|
|
|
fCtrlKeyDown(false), |
|
|
|
fCapsLockLock(false), |
|
|
|
fCapsLockLock(false), |
|
|
|
fPrevNumLockOn(false), |
|
|
|
|
|
|
|
fControlMode(STANDARD_MODE) |
|
|
|
fControlMode(STANDARD_MODE) |
|
|
|
{ |
|
|
|
{ |
|
|
|
fInstance = this; |
|
|
|
fInstance = this; |
|
|
|
fStartedUpWithNumLockOn = ((GetKeyState(VK_NUMLOCK) & 1) != 0); |
|
|
|
|
|
|
|
InitKeyboardState(); |
|
|
|
InitKeyboardState(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
plKeyboardDevice::~plKeyboardDevice() |
|
|
|
plKeyboardDevice::~plKeyboardDevice() |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (fStartedUpWithNumLockOn) |
|
|
|
|
|
|
|
ForceNumLock(true); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void plKeyboardDevice::InitKeyboardState() |
|
|
|
void plKeyboardDevice::InitKeyboardState() |
|
|
@ -168,29 +165,6 @@ void plKeyboardDevice::Shutdown() |
|
|
|
{ |
|
|
|
{ |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
#if HS_BUILD_FOR_WIN32 |
|
|
|
|
|
|
|
void plKeyboardDevice::ForceNumLock(hsBool on) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if (on != ((GetKeyState(VK_NUMLOCK) & 1) != 0)) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
OSVERSIONINFO info; |
|
|
|
|
|
|
|
info.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); |
|
|
|
|
|
|
|
GetVersionEx(&info); |
|
|
|
|
|
|
|
if (info.dwPlatformId == VER_PLATFORM_WIN32_NT) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
keybd_event( VK_NUMLOCK, 0, KEYEVENTF_EXTENDEDKEY | 0, 0 ); |
|
|
|
|
|
|
|
keybd_event( VK_NUMLOCK, 0, KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, 0 ); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
UInt8 keyState[256]; |
|
|
|
|
|
|
|
GetKeyboardState(keyState); |
|
|
|
|
|
|
|
keyState[VK_NUMLOCK] = keyState[VK_NUMLOCK] ^ 1; |
|
|
|
|
|
|
|
SetKeyboardState(keyState); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
#endif //HS_BUILD_FOR_WIN32
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void plKeyboardDevice::HandleKeyEvent(plOSMsg message, plKeyDef key, bool bKeyDown, hsBool bKeyRepeat) |
|
|
|
void plKeyboardDevice::HandleKeyEvent(plOSMsg message, plKeyDef key, bool bKeyDown, hsBool bKeyRepeat) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -199,13 +173,6 @@ void plKeyboardDevice::HandleKeyEvent(plOSMsg message, plKeyDef key, bool bKeyDo |
|
|
|
if ((key >= 0) && (key < 256)) |
|
|
|
if ((key >= 0) && (key < 256)) |
|
|
|
fKeyboardState[key] = bKeyDown; |
|
|
|
fKeyboardState[key] = bKeyDown; |
|
|
|
|
|
|
|
|
|
|
|
#if HS_BUILD_FOR_WIN32 |
|
|
|
|
|
|
|
if (key == VK_NUMLOCK && bKeyDown) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
ForceNumLock(false); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
#endif // HS_BUILD_FOR_WIN32
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (key == KEY_SHIFT) |
|
|
|
if (key == KEY_SHIFT) |
|
|
|
{ |
|
|
|
{ |
|
|
|
fShiftKeyDown = bKeyDown; |
|
|
|
fShiftKeyDown = bKeyDown; |
|
|
@ -242,27 +209,10 @@ void plKeyboardDevice::HandleWindowActivate(bool bActive, HWND hWnd) |
|
|
|
if (bActive) |
|
|
|
if (bActive) |
|
|
|
{ |
|
|
|
{ |
|
|
|
fCtrlKeyDown = false; |
|
|
|
fCtrlKeyDown = false; |
|
|
|
|
|
|
|
|
|
|
|
#if HS_BUILD_FOR_WIN32 |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
fPrevNumLockOn = ((GetKeyState(VK_NUMLOCK) & 1) != 0); |
|
|
|
|
|
|
|
ForceNumLock(false); |
|
|
|
|
|
|
|
hsBool oldLock = fCapsLockLock; |
|
|
|
|
|
|
|
fCapsLockLock = (GetKeyState(KEY_CAPSLOCK) & 1) != 0; |
|
|
|
|
|
|
|
if (fCapsLockLock != oldLock) |
|
|
|
|
|
|
|
plAvatarInputInterface::GetInstance()->ForceAlwaysRun(fCapsLockLock); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
else |
|
|
|
{ |
|
|
|
{ |
|
|
|
ReleaseAllKeys(); // send key-up events for everything since we're losing focus
|
|
|
|
ReleaseAllKeys(); // send key-up events for everything since we're losing focus
|
|
|
|
#if HS_BUILD_FOR_WIN32 |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if (fPrevNumLockOn) |
|
|
|
|
|
|
|
ForceNumLock(true); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|