Browse Source

Merge branch 'ticket/11'

closes #11
tickets/11/11/2
rarified 3 years ago
parent
commit
5d0e4bb853
  1. 52
      Sources/Plasma/PubUtilLib/plInputCore/plInputDevice.cpp
  2. 8
      Sources/Plasma/PubUtilLib/plInputCore/plInputDevice.h

52
Sources/Plasma/PubUtilLib/plInputCore/plInputDevice.cpp

@ -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
} }
} }

8
Sources/Plasma/PubUtilLib/plInputCore/plInputDevice.h

@ -121,10 +121,6 @@ public:
virtual hsBool IsCapsLockKeyOn(); virtual hsBool IsCapsLockKeyOn();
virtual void Shutdown(); virtual void Shutdown();
#if HS_BUILD_FOR_WIN32
void ForceNumLock(hsBool on);
#endif
static hsBool IgnoreCapsLock() { return fIgnoreCapsLock; } static hsBool IgnoreCapsLock() { return fIgnoreCapsLock; }
static void IgnoreCapsLock(hsBool ignore) { fIgnoreCapsLock = ignore; } static void IgnoreCapsLock(hsBool ignore) { fIgnoreCapsLock = ignore; }
@ -133,10 +129,6 @@ public:
static plKeyboardDevice* GetInstance() { return fInstance; } static plKeyboardDevice* GetInstance() { return fInstance; }
static char KeyEventToChar( plKeyEventMsg *msg ); static char KeyEventToChar( plKeyEventMsg *msg );
protected:
hsBool fStartedUpWithNumLockOn; // maintaining a separate flag since apparently the other one can get confused
hsBool fPrevNumLockOn;
}; };
class plPlate; class plPlate;

Loading…
Cancel
Save